[英]How can I specify the ruby version to use on Heroku from the RVM configuration files
[英]How can I choose Ruby version on Heroku?
我在我的Rails 3應用程序中使用了Ruby 1.9.x語法,但在將其推送到Heroku后,由於舊的Ruby版本(1.8)而崩潰。 我該如何控制它?
Heroku目前的堆棧Cedar默認使用1.9.2。 Cedar還支持在Gemfile中指定Ruby版本 。 目前, 1.9.2和1.9.3是有效選項 。
# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
...
有關更多詳細信息,請參閱Ruby支持文章: https : //devcenter.heroku.com/articles/ruby-support
如果您當前正在使用Aspen或Bamboo,則可以使用stack:migrate
命令切換到1.9.2:
$ heroku stack:migrate bamboo-mri-1.9.2
您目前無法自動遷移到Cedar堆棧,但有關於如何執行此操作的指南: https : //devcenter.heroku.com/articles/cedar-migration
您現在可以在Heroku上顯式指定Ruby版本 。
只需設置您的Gemfile
# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
# Gems go here
我想使用我已經在.ruby-version
文件中定義.ruby-version
所以我最終創建了一個buildpack,可以在heroku-buildpack-ruby之前使用,它將.ruby-version中的版本注入到Gemfile
。 它還支持沒有補丁或別名的版本。
https://github.com/platanus/heroku-buildpack-ruby-version
這樣,您只能在一個地方定義您的版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.