-
Notifications
You must be signed in to change notification settings - Fork 9
ruby versions
ppworks edited this page May 21, 2012
·
1 revision
Gemileにrubyキーワードを用いてruby versionを指定することが可能です。
# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
...h
上記のように指定することで、Heroku に push しdeploy した際、ruby 1.9.3と識別されることが分かります。
-----> Heroku receiving push
-----> Ruby/Rack app detected
-----> Using Ruby version: 1.9.3
-----> Installing dependencies using Bundler version 1.2.0.pre
...
Gemfileにrubyキーワードを記述するにはbunlderのバージョンを1.2.0.pre以降にアップグレードする必要があります。
Herokuでサポートされている ruby の version に関しては、wiki/ruby support を御覧ください。
デフォルトversion以外のrubyにPATHが通るようPAT環境変数を設定する必要があります。環境変数PATHは、heroku configを用いて設定します。
:::term
$ heroku config -s | grep PATH
PATH=vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
heroku config:addを用いて上記のようにbin:を加えます。
:::term
$ heroku config:add PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
PATHが正確にセットされるとheroku run "ruby -v"コマンドでruby の version が確認出来ます。
PATHが正確にセットされないと、以下の様なエラーが発生するでしょう。
Your Ruby version is 1.9.2, but your Gemfile specified 1.9.3
もし、1.2.0.pre 以下のbundlerを使っている場合、以下の様なエラーが発生するでしょう。
undefined method `ruby' for #<Bundler::Dsl:0x0000000250acb0> (NoMethodError)
その場合は、1.2.0.pre 以上に bundlerの version をアップグレードして下さい。
gem install bundler --pre
RUBY_VERSION という環境変数は非推奨となりました。もし利用している場合は、上記のようにGemfileにて指定して下さい。Gemfileはパッチレベルの指定はサポートしておりません。サポートされているrubyのバージョンはwiki/supported versions をご覧ください。