Skip to content

Instantly share code, notes, and snippets.

@tralston
Last active December 26, 2015 00:19
Show Gist options
  • Save tralston/7063431 to your computer and use it in GitHub Desktop.
Save tralston/7063431 to your computer and use it in GitHub Desktop.
Ruby gem commands
# Remove unused gems, clean up broken dependencies
# Use with bundle show <gem> to resolve LoadError problems for gems that are installed but not seen by Rails
gem clean <gem>
# Remove accumulated gem documentation (ri and rdoc)
rm -r `gem env gemdir`/doc
@tralston
Copy link
Author

I was getting an error message from Phusion Passenger (4.0.20) and nginx (1.4.3) for a project that had previous run fine until I upgraded to Rails 4.0.0:

cannot load such file -- rack (LoadError) ...

I knew rack was installed, because it was there in Gemfile.lock, gem list, and bundle list. The problem was that the particular version referenced by all of these things was for some reason not linked properly, or deleted. The way I finally figured it out was to run the following:

bundle show rack

and it gave:

The gem rack has been deleted. It was installed at:
/usr/local/rvm/gems/ruby-2.0.0-head/gems/rack-1.5.2

So then I ran

gem clean rack

I thought that worked, but "bundle show rack" still said the gem had been deleted. So I manually installed it again with:

gem install rack -v '1.5.2'

Then "bundle show rack" didn't report any errors. I hope this helps someone else too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment