【问题标题】:How can I choose Ruby version on Heroku?如何在 Heroku 上选择 Ruby 版本?
【发布时间】:2010-08-31 23:29:49
【问题描述】:

我在 Rails 3 应用程序中使用 Ruby 1.9.x 语法,但在将其推送到 Heroku 后,由于 Ruby 版本 (1.8) 较旧,它会崩溃。怎么控制?

【问题讨论】:

标签: ruby-on-rails heroku ruby-1.9


【解决方案1】:

Heroku 当前的堆栈 Cedar 默认使用 1.9.2。 Cedar 还支持specifying the Ruby version in your Gemfile。目前,1.9.2 and 1.9.3 are valid options

# 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

【讨论】:

    【解决方案2】:

    您现在可以explicitly specify a Ruby version on Heroku

    只需像这样设置您的Gemfile

    # Gemfile
    source "https://rubygems.org"
    ruby "1.9.3"
    
    # Gems go here
    

    【讨论】:

      【解决方案3】:

      我想使用我已经在.ruby-version 文件中定义的版本,所以我最终创建了一个可以在 heroku-buildpack-ruby 之前使用的 buildpack,它从 . ruby 版本到Gemfile。它还支持没有补丁或别名的版本。

      https://github.com/platanus/heroku-buildpack-ruby-version

      这样您可以只在一个地方定义您的版本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-02-24
        • 1970-01-01
        • 2017-04-02
        • 1970-01-01
        • 2015-05-30
        • 2014-01-14
        • 2011-03-22
        相关资源
        最近更新 更多