LoginSignup
1
1

More than 5 years have passed since last update.

.rvmrc を .ruby-version に移行する

Last updated at Posted at 2013-08-28

rvm をアップデートしてから、rvm 使っている Rails Project に cd したら、以下のメッセージが表示された。

$ cd hoge-rails-project
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/hoge/hoge-rails-project/.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-version に変更してみる。

.rvmrc 内の rvm use しているところを抜き出し、.ruby-version にバージョンのみ記載すれば移行としては完了する。

rvm use 2.0.0

2.0.0

にするだけである。他に記述がなければ、.rvmrc は削除してしまって構わない。

Pow を併用している場合は、以下のようになっているはずなので、

if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
  source "$rvm_path/scripts/rvm"
  source ".rvmrc"
fi

ここも合わせて変更する。

if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ]; then
  source "$rvm_path/scripts/rvm"
  rvm use `cat .ruby-version`
fi

追記) デプロイ先が rbenv を使っているようなめんどくさい環境だった場合、この変更の影響を受けてしまう。上記の例のように 2.0.0 と短縮形のままだと弊害が発生するので、rbenv のプラグインである rbenv-aliases で手を打っておく。

私の環境では、/usr/local/rbenv にインストールしていたので、plugin も /usr/local/rbenv/plugins 以下にインストールする必要があった。

$ git clone git://github.com/tpope/rbenv-aliases.git /usr/local/rbenv/plugins/rbenv-aliases
$ rbenv alias --auto

$ rbenv versions
  system
  2.0.0
* 2.0.0-p247 (set by /usr/local/rbenv/version)
1
1
0

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
1
1