no such file to load Issue

Noah Clark's Avatar

Noah Clark

13 Sep, 2011 03:54 PM

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?

  1. Support Staff 2 Posted by Eric Hodel on 13 Sep, 2011 06:19 PM

    Eric Hodel's Avatar

    Yes, the differing paths are the issue. How is "some code that calls a few gems" run?

  2. 3 Posted by Noah Clark on 13 Sep, 2011 06:30 PM

    Noah Clark's Avatar

    Shotgun maine.rb

  3. 4 Posted by Noah Clark on 13 Sep, 2011 09:33 PM

    Noah Clark's Avatar

    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!

  4. Support Staff 5 Posted by Eric Hodel on 14 Sep, 2011 08:32 PM

    Eric Hodel's Avatar

    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?

  5. 6 Posted by Brad on 15 Sep, 2011 09:37 PM

    Brad's Avatar

    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.

  6. 7 Posted by noah on 15 Sep, 2011 09:51 PM

    noah's Avatar

    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.

  7. 8 Posted by Brad on 15 Sep, 2011 11:30 PM

    Brad's Avatar

    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!

  8. Support Staff 9 Posted by Nick Quaranto on 23 Sep, 2011 02:57 PM

    Nick Quaranto's Avatar

    Cool, closing this out since it seems resolved :) Feel free to reopen if not!

  9. Nick Quaranto closed this discussion on 23 Sep, 2011 02:57 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

29 Aug, 2014 06:23 PM
28 Aug, 2014 07:18 PM
27 Aug, 2014 12:03 PM
26 Aug, 2014 07:09 PM
26 Aug, 2014 07:07 PM