LoginSignup
36

More than 5 years have passed since last update.

.rvmrcから.ruby-gemsetと.ruby-versionに移行

Last updated at Posted at 2013-05-16

rvmのversionを1.20.9にしたら、warningが出た。

You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version'
or ignore this warnings with 'rvm rvmrc warning ignore /Users/prinum/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.

 
調べてみると、rbenv等のrubyのrubyのveision管理ツールでも.ruby-versionでrubyのversionを切り替えることが出来るらしいです。
tool間での互換性をあげるためにそうするようになったようです。
.ruby-gemsetはrvmにおいて、gemsetを切り替えるために必要なようです。

.rvmrcがあるdirectoryで以下のコマンドを打つことによって、.rvmrcを元に、.ruby-gemsetと.ruby-versionを生成するようです。

$ rvm rvmrc to .ruby-version
.rvmrc
rvm 1.9.3-p125@hoge --create
.ruby-version
ruby-1.9.3-p125
.ruby-gemset
hoge

.rvmrcはshellコマンドを実行することが出来るので、自動で実行させたいコマンドがあるなら使用すると良いようです。

.rvmrc
#bundlerが入ってなかったら、bundlerをinstallする。
if ! command -v bundle ; then
  gem install bundler
fi

参考サイト
Use rvmrc or ruby-version file to set a project gemset with RVM?

rvmrc files


次のコマンドで.ruby-version.ruby-gemsetが作成される。
作成した上でそのgemsetを選択する。

もしすでに.ruby-version.ruby-gemsetがあったら古いのは別名を付けられてバックアップされるので既存のものを上書きして消すことはない。

rvm --create --ruby-version use ruby-2.1-head@appname
rvm gemset list

gemsets for ruby-2.1-head (found in /Users/daichi/.rvm/gems/ruby-2.1-head)
   (default)
=> appname
   global

.ruby-version
ruby-2.1-head
.ruby-version
appname

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
36