Shell script to switch between MRI and jruby
Working on a project that uses jRuby, but locally when I work I use MRI a lot because it's faster.
Now switching between them is a major annoyance, this is how I switch from jruby to MRI:
rvm use ruby-2.1.5
sed -i.bak 3s/.*/ruby" '2.1.5'"/ Gemfile
Which replaces my Gemfile and indicates the correct ruby โโversion. Now I wanted to create two executables from bin/
my rails project folder, one titled mri
and one more jruby
so that I could switch between them with one command and so that everyone working in the command can use the same.
The problem is that when executing the shell, RVM does not change the ruby โโversion in my current session. So naturally I get this message:
Your Ruby version is 2.0.0, but your Gemfile is listed as 2.1.5
-
Is this a good approach to what I am trying to do? pretty sure i'm not the first person to try this
-
Do you already have something that works for you?
source to share
As pointed out in the comments, you need to re-download the rvm scripts. You could probably use ~/.bash_profile
or again ~/.bash_rc
, since they should be found there.
I didn't have this issue with rbenv , but I only exchange between MRI versions. There is also a specification for the .ruby-version
file here , which is both RVM and rbenv honor.
For binding boxes, you can specify the path to bin with bundle binstubs --path mri-bin
.
source to share