I am using Mechanize to fill out a file upload form for an image file.
My script is telling me that an image file DOESN’T exist:
/opt/local/lib/ruby/gems/1.8/gems/mechanize-0.7.2/lib/www/mechanize/form.rb:273:in
`initialize’: No such file or directory -
/Users/dbit/Sites/fuseme/fuseme_rails/app/models/scrapers/web20/web20_logos/evenspacer.gif
(Errno::ENOENT)
Does anybody have a clue as to why it would happen?
When I use the UNIX ‘ls’ command to ls the file name using the absolute
path name of the image “evenspacer.gif” (as seen in the above error
message), the UNIX prompt lists that file, meaning that it’s there!
I thought it might be because the file name was named in a different
character set, but I changed the XML file from which the name of the
file was being taken and retyped in both the XML file and renamed the
file by hand using my keyboard( thereby overwriting whatever character
set it was previously represented in).
Does anybody have any ideas as to what’s going on here? I’m a bit
stumped!
One possible source of error might be the user that your rails script is
running as. If your normal user (as you were with the one liner test) is
not the same as the user assigned to run the rails script then it might
be that the rails script / user does not have permission to read the
file or some part of the path (to be sure you could set all files and
directories to a+r and all directories to a+x on the path to the file in
question).
exists?: false
expanded path:
/Users/dbit/Sites/fuseme/fuseme_rails/app/models/scrapers/web20/web20_logos/evenspacer.gif
exists?: false
/opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize/form.rb:294:in initialize': No such file or directory - /Users/dbit/Sites/fuseme/fuseme_rails/app/models/scrapers/web20/web20_logos/evenspacer.gif (Errno::ENOENT) from /opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize/form.rb:294:inopen’
from
/opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize/form.rb:294:in file_to_multipart' from /opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize/form.rb:200:inrequest_data’
from
/opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize/form.rb:200:in each' from /opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize/form.rb:200:inrequest_data’
from
/opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize.rb:380:in post_form' from /opt/local/lib/ruby/gems/1.8/gems/mechanize-0.8.3/lib/www/mechanize.rb:324:insubmit’
from web20.rb:47:in `submit_new_thing’
from web20.rb:90
There was a space at the end of the file name in the XML file, but not
in the actual file name . . . . . sigh
Peter H. wrote:
One possible source of error might be the user that your rails script is
running as. If your normal user (as you were with the one liner test) is
not the same as the user assigned to run the rails script then it might
be that the rails script / user does not have permission to read the
file or some part of the path (to be sure you could set all files and
directories to a+r and all directories to a+x on the path to the file in
question).
Thats all that I can think of.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.