I'm completely stumped by this one. I'm trying to debug some code that creates a FirstRun file as a marker that the program has already done its first run setup. It tries to create this in the specified working directory, given by the absworkingdir variable. However, when it tries to create the file with File.new I get the following error
`initialize': No such file or directory '
Here's the relevant code:
#First run setup
puts workingdir#debug
absworkingdir = File.expand_path(workingdir)
puts absworkingdir#debug
if File.exist?("#{absworkingdir}/FirstRun.lock") == false
puts "This appears to be the first run of FigShare Sync. We'll setup a few things."
print "Where would you like to store settings and files? [~./figsharesync]: "
@input = gets.chomp
puts @input#debug
if @input.empty? == false
workingdir = @input
absworkingdir = File.expand_path(workingdir)
end
print "Please enter OAuth consumer key: "
consumerkey = gets.chomp
print "Please enter OAuth consumer key secret: "
consumersecret = gets.chomp
print "Please enter OAuth access token: "
accesstoken = gets.chomp
print "Please enter OAuth access token secret: "
accesstokensecret = gets.chomp
puts "Great! we'll get running now..."
puts absworkingdir#debug
File.new("#{absworkingdir}/FirstRun.lock", "r")
end
Here's the output from the debugging lines:
~/.figsharesync/
/var/lib/stickshift/5165dc1e4382ec92040001a8/app-root/data/.figsharesync
This appears to be the first run of FigShare Sync. We'll setup a few things.
Where would you like to store settings and files? [~./figsharesync]:
Please enter OAuth consumer key:
Please enter OAuth consumer key secret:
Please enter OAuth access token:
Please enter OAuth access token secret:
Great! we'll get running now...
/var/lib/stickshift/5165dc1e4382ec92040001a8/app-root/data/.figsharesync
source/figsharesync2.rb:38:in `initialize': No such file or directory - /var/lib/stickshift/5165dc1e4382ec92040001a8/app-root/data/.figsharesync/FirstRun.lock(Errno::ENOENT)
from source/figsharesync2.rb:38:in `new'
from source/figsharesync2.rb:38:in `<main>'
You want to use write mode with File.new, otherwise you're saying you want to open a non-existent file in read mode:
f = File.new("#{absworkingdir}/FirstRun.lock", "w")
f.close
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With