Search code examples
rubyrubygemsbundlerrbenv

Updating ruby version with Rbenv but gems apparently not updated


I have just updated Ruby from version 1.9.3-p448 to 1.9.3-p484 using rbenv on a Ubuntu Production server. The updating seems to be successful. Ruby version shows the latest version I just updated.

However when I look at the gems for this version 1.9.3-p484 under the directory: .rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems.

I only find a few gems in that directory. And when I looked at the directory of the previous version, there is a whole bunch of gems in there. Did I miss a step somewhere in the ruby update process?

Now that I am using the new ruby version, do I need to reinstall all the gems for this version? If so, will running bundle install does the job?


Solution

  • Yes, you need to run bundle install for the active ruby version. Please make sure that the active ruby version, and the gemset for the application are set properly. Just do the following (in Linux/MacOS):

    $ cat .ruby-version
    ruby-1.9.3-p484
    
    $ cat .ruby-gemset
    your_app_name
    

    And before gem update, please re-neter into the your application/gem folder.

    $ cd ..
    $ cd your_app_name
    

    I have an additional note. If your application is a gem, there is no reason to add the .ruby-version, and .ruby-gemset files into the git repository, just add them into .gitignore file. When your application is a rails app, adding the files along with the Gemfile.lock into git repo has make sense, because you fix ruby version, and gem set for web-application to one that are those, which uniquely will work. Also some cloud services like heroku requires Gemfile.lock to be added into a git repo.