Rvm in script not respecting .ruby-version and .ruby-gemset

From FVue
Jump to: navigation, search

Problem

So Rvm should support .ruby-version and .ruby-gemset (and do without .rvmrc)? So how can I make Rvm in this shell script use ruby-2.1.1? And no, I don't want to repeat the ruby-version in the shell script because that would be redundant with the .ruby-version file and could cause inconsistency.

$ cat migrate.sh
#!/bin/bash
cd proj
cat .ruby-version
rvm list
$ ./migrate.sh
ruby-2.1.1
...
=* ruby-1.9.3-p194 [ i686 ]
   ruby-2.1.0 [ i686 ]
   ruby-2.1.1 [ i686 ]
 
# => - current
# =* - current && default
#  * - default

Whereas this is what I see if I cd to the project in a terminal:

$ cd proj
$ rvm list
...
 * ruby-1.9.3-p194 [ i686 ]
   ruby-2.1.0 [ i686 ]
=> ruby-2.1.1 [ i686 ]

Environment

  • rvm-1.25.32

Workaround

Use rvm-shell.

$ cat migrate2.sh
#!/bin/bash
cd proj
rvm-shell $(<.ruby-version)@$(<.ruby-gemset) -c "rvm list"
$ ./migrate2.sh
...
 * ruby-1.9.3-p194 [ i686 ]
   ruby-2.1.0 [ i686 ]
=> ruby-2.1.1 [ i686 ]
...

Journal

20151113

Tried sourcing ~/.rvm/scripts/rvm, but that doesn't help:

$ cat migrate3.sh
#!/bin/bash
cd /home/freddy/work/telfort/cms/telfortcms2
. ~/.rvm/scripts/rvm
rvm list
$ ./migrate3.sh
...
=* ruby-1.9.3-p194 [ i686 ]
   ruby-2.1.0 [ i686 ]
   ruby-2.1.1 [ i686 ]
...

Comments

blog comments powered by Disqus