0

I recently used RVM to update Ruby from 1.8.3 to 2.0.0. The update was successful, and I'm able to run 2.0.0 in the command line just fine.

The problem is, I went to work on a project that uses the Compass/Sass gem, and when I tried running the compass watch command from the shell, I got this error:

/Library/Ruby/Site/1.8/rubygems/dependency.rb:298:in `to_specs': Could not find 'compass' (>= 0) among 7 total gem(s) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems/dependency.rb:309:in `to_spec'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /usr/bin/compass:22

My original version of Ruby stores all the gems I've installed here:

/Library/Ruby/Gems

But the RVM update to 2.0.0 lists the gems as being kept here:

/Users/Jim/.rvm/gems/ruby-2.0.0-p481@global/gems

How do I get RVM to update the original gems so that I can use them with my current version of Ruby? And will this require me to reinstall the gems on the project I have that depends upon compass?

I've read lots of the documentation at rvm.io, and thought the 'rvm gemset update' would work. I also tried 'rvm do gemset update' and 'rvm all do gemset update' but it's not finding the old gems.

Does anyone have ideas how I might point RVM to my old gems and get it to update them into a gemset that 2.0.0 can use?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Jim
  • 400
  • 4
  • 17

3 Answers3

3

Try this:

/usr/bin/gem list --no-version > ~/Desktop/old_gems
xargs gem install < ~/Desktop/old_gems

The first command will tell the old gem to list the gems associated with the old Ruby, without their version numbers, which will be stored on your Desktop as "old_gems".

The second command tells xargs to tell the new gem to install the gems listed in "~/Desktop/old_gems". xargs will keep gem from getting overwhelmed if there are too many gems to fit on the command-line.

I use a very similar method when I install new versions of Ruby and need to have a pristine set of gems to accompany it.


The first command throws an uninitialized constant error...

.../Library/Ruby/Site/1.8...

The problem is probably due to the age of your Ruby. 1.8 is really old and has been deprecated for years, and, as a result, I suspect that gem doesn't know the --no-version flag. Instead, try this:

/usr/bin/gem list | awk '{print $1}' > ~/Desktop/old_gems
xargs gem install < ~/Desktop/old_gems

I found the rvm use system command...

Um... it'd be really smart for you to take the time to read through the RVM documentation so you know what the tool does. rvm use system is one of the most basic of its commands, and the primary reason for using a sandbox like RVM or rbenv. See "Setting the default Ruby" for that information.

Additionally, it's really important that you keep on top of your RVM version so that bug fixes, and new versions of Ruby are available to you. See "Upgrading RVM" for how to do that.

Finally, any time you need to know what is where in your Ruby/RVM ecosystem, use rvm info.

Community
  • 1
  • 1
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • Thanks for the command suggestions. This sounds exactly like what I'm hoping to do. The first command throws an uninitialized constant error: – Jim Jul 09 '14 at 14:24
  • `Jim$ /usr/bin/gem list --no-version > ~/Desktop/old_gems /Library/Ruby/Site/1.8/rubygems/config_file.rb:39: uninitialized constant Gem::UserInteraction (NameError)` It then lists about 30 Ruby files that are having trouble with this, all found in /Library/Ruby/Site?1.8/rubygems Will I or my projects come to any harm if I manually reinstall the gems? Will running a gem install through my terminal install gems as part of my 2.0.0 gemset? Thanks. – Jim Jul 09 '14 at 14:32
  • Looks like the problem originates in the existing projects looking for the system ruby version. While running 2.0.0 with rvm, I was unable to use `compass watch` on any projects or push code on these projects to github. I started to really worry I had broken something bigtime, but after reading the docs a little more on rvm, I found the `rvm use system` command, which restored ruby to original version. Now able to successfully use compass and push to github. Phew! – Jim Jul 09 '14 at 17:02
1

If you are using bundler and a Gemfile, then you should not have this kind of problem. In fact, the benefit to using Bundler and the Gemfile is to help ensure others that are working on your project are able to have the same gems installed as well.

The /Library/Ruby/Gems folder is very likely from a system installation, rather than an RVM installation of your gems.

I believe that is why you are not finding the documentation matching with your experience, as your prior configuration seems to be based on a system installation of Ruby, rather than a project set up using RVM.

You will have a few options to correct this, but I would suggest using a Gemfile, and using Bundler to help manage your project.

vgoff
  • 10,980
  • 3
  • 38
  • 56
  • All gems prior to my rvm installation were installed to the system installation version of Ruby, as you said. Do you suggest running the bundler through rvm? I currently have `rubygems-bundler (1.4.4)` and `bundler (1.6.2)` in my local gem list (accessible to rvm). If I wanted to just reinstall the gems manually for 2.0.0, what's the best way to do this so that, on my next ruby update, I can just run a simple command to update all gems? – Jim Jul 09 '14 at 14:39
  • 1
    I would have the gems specified either in `Gemfile`, or if it is a gem that you are building, then `name.gemspec` would be the place I would put that information. If you do not specify versions, or specify minimum versions, without a max, then doing a `bundle install` will install the latest appropriate versions of each specified gem. `bundle update` will update the gems to their current versions, as described in [documentation](http://bundler.io/v1.6/man/bundle-update.1.html). – vgoff Jul 09 '14 at 15:57
1

Given the setup of your system, it seems like you're on a mac and want to update your existing gems that you installed prior to learning about RVM.

My best suggestion is using the following to obtain a list of your original gems.

/usr/bin/gem list

If you would rather not install them one by one, give this code a try: http://www.krzywanski.net/archives/451

A little ruby code would do the trick as well, for the latest versions anyway. ;)

$ /usr/bin/gem list | ruby -ne 'puts("gem install #{$_.chomp.split[0]}")' >  ~/oldgems.sh
$ chmod +x ~/oldgems.sh && cd
$ ./oldgems.sh
W4t3randWind
  • 631
  • 1
  • 7
  • 16
  • I like the energy. This would give you everything installed in the system install, though you may still need to edit that list to remove things that are not project specific. But it would definitely get you that list to isolate those. – vgoff Jul 09 '14 at 16:02