no such file to load Issue
I have some code that calls a few gems that looks like this:
require 'rubygems'
require 'sinatra'
require 'date'
require 'sanitize'
And when I try to run this I get this error:
LoadError: no such file to load -- sanitize
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:54:in `gem_original_require'
And so I then followed the guide and did the following:
noahclark$ gem list sanitize
*** LOCAL GEMS ***
sanitize (2.0.3)
So then:
noahclark$ ruby -rubygems -e 'require "sanitize"'
noahclark$
noahclark$ which ruby
/opt/local/bin/ruby
noahclark$ gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /opt/local/bin/ruby
So then I tried:
noahclark$ which gem
/opt/local/bin/gem
noahclark$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/noahclark/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
You'll notice my which gem path and my gem environment are not the same. Is this the issue? how do I fix it?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Eric Hodel on 13 Sep, 2011 06:19 PM
Yes, the differing paths are the issue. How is "some code that calls a few gems" run?
3 Posted by Noah Clark on 13 Sep, 2011 06:30 PM
Shotgun maine.rb
4 Posted by Noah Clark on 13 Sep, 2011 09:33 PM
Weird, I replied by e-mail and it cut it short.
I am using the command 'shotgun main.rb'
It also causes issues in irb when I try to important it.
I was playing around with nokogiri and it's doing the same thing.
Can I just uninstall all of it and start over? I'd be okay doing that if I knew how.
Any other thoughts? Thanks!
Support Staff 5 Posted by Eric Hodel on 14 Sep, 2011 08:32 PM
Reinstalling the gem that provided shotgun should switch the ruby used to the /opt installation.
If that doesn't fix it, can you paste the contents of
which shotgun?6 Posted by Brad on 15 Sep, 2011 09:37 PM
I'm having a similar problem. I can require a gem no problems from irb, but when I put the same require into an app, I get the "no such file to load" error. Is it possible to get some more information about how to resolve this? I'm a complete newcomer to all this.
7 Posted by noah on 15 Sep, 2011 09:51 PM
Brad, did you run through the steps I went through? http://docs.rubygems.org/read/chapter/19#page105
Also see:
http://stackoverflow.com/questions/7417143/gem-path-issue-rubygems-...
I'm not sure, but it might be better to open your own issue.
Also, I have resolved my issues.
8 Posted by Brad on 15 Sep, 2011 11:30 PM
Thanks for the reply, Noah. I went through those steps and had much the same problem. In my case, the easiest thing to do was to install RVM, set it to the latest Ruby version, and re-build and re-install the gems I was working with. Easy!
Support Staff 9 Posted by Nick Quaranto on 23 Sep, 2011 02:57 PM
Cool, closing this out since it seems resolved :) Feel free to reopen if not!
Nick Quaranto closed this discussion on 23 Sep, 2011 02:57 PM.