1

I create a gemset with

$ rvm gemset create r3
$ rvm gemset use r3
$ gem install rails -v3.2.13

At this point

$ rails -v

now shows

$ Rails 3.2.13

but every time I do bundle with a project I've forked, I find that

rails -v

shows Rails 4.0.1 - which then gives issue with the project in question when running tests
(4.0.1 conflicts with 3.2.13).

My question is - if my Gemfile only has:

$ cat Gemfile
source 'https://rubygems.org'

gemspec

how is this happening? How can I make my command line ruby version stay at 3.2.13 and not switch to 4.0.1 Once it switches to 4.0.1 I seem to be stuck with that for that gemset and to create a 3.2.13 gemset I have to start over again.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497

2 Answers2

1

Bundle works by finding the most up-to-date version of the gems that are compatible with the restrictions from the Gemfile. In this case, those restrictions are coming from the gemspec file, which presumably allows versions of Rails greater than 3.2.13. So it's picking the most up-to-date version of Rails allowed - which is 4.0.1. Your RVM configuration is not relevant here.

To lock your particular fork to Rails 3.2.13, just add the following:

gem 'rails', '3.2.13'

to the Gemfile in your fork. This will lock the local version to 3.2.13 when you run bundle.

Peter Goldstein
  • 4,479
  • 2
  • 19
  • 17
0

if you wish to explicitly use different version of rails then the one that would be calculated from Gemfile then you need to use:

NOEXEC_DISABLE=1 rails ...

you can make it permanent for single shell session with:

export NOEXEC_DISABLE=1
rails ...

and to disable loading gems in versions calculated via Gemfile put it in you shell initialization file (like ~/.bash_profile or ~/.zlogin):

export NOEXEC_DISABLE=1

this happens because RVM installs gem rubygems-bundler which automatically analyzes your Gemfile when you run gem binaries and if a version specified via this file is available then it is loaded (even if it is specified only as dependency of your gems).

mpapis
  • 52,729
  • 14
  • 121
  • 158