【问题标题】:Heroku Ruby version won't upgrade?Heroku Ruby 版本不会升级?
【发布时间】:2014-01-14 12:36:41
【问题描述】:

我正在努力更改 Heroku 上的 Ruby 版本。 我使用 Ruby 2.0.0 和 rails 4。

我的 Gemfile 有:

source 'https://rubygems.org'
ruby '2.0.0'
...

Heroku 中的路径指向:

$ heroku config -s | grep PATH
PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin

当我推送我的应用时,我可以看到:

Fetching repository, done.
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 431 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment 
       Using rake (10.1.1) 
       Using i18n (0.6.9)
       Using minitest (4.7.5)
       Using multi_json (1.8.2)
       Using atomic (1.1.14)
       Using thread_safe (0.1.3)
       Using tzinfo (0.3.38)
       Using activesupport (4.0.0.rc1)
       Using builder (3.1.4)
       Using erubis (2.7.0)
       Using rack (1.5.2)
       Using rack-test (0.6.2)
       Using actionpack (4.0.0.rc1)
       Using mime-types (1.25.1)
       Using polyglot (0.3.3)
       Using treetop (1.4.15)
       Using mail (2.5.4)
       Using actionmailer (4.0.0.rc1)
       Using activemodel (4.0.0.rc1)
       Using activerecord-deprecated_finders (1.0.3)
       Using arel (4.0.1)
       Using activerecord (4.0.0.rc1)
       Using addressable (2.3.5)
       Using bcrypt-ruby (3.1.2)
       Using coffee-script-source (1.6.3)
       Using execjs (2.0.2)
       Using coffee-script (2.2.0)
       Using thor (0.18.1)
       Using railties (4.0.0.rc1)
       Using coffee-rails (4.0.0)
       Using orm_adapter (0.5.0)
       Using warden (1.2.3)
       Using devise (3.0.4)
       Using excon (0.25.3)
       Using geocoder (1.1.9)
       Using gmapsjs (0.2.30.1)
       Using heroku-api (0.3.15)
       Using launchy (2.4.2)
       Using netrc (0.7.7)
       Using rest-client (1.6.7)
       Using rubyzip (1.1.0)
       Using heroku (3.2.1)
       Using hike (1.2.3)
       Using jbuilder (1.0.2)
       Using jquery-rails (3.0.4)
       Using jquery-ui-rails (4.1.1)
       Using json (1.8.1)
       Using libv8 (3.16.14.3)
       Using nifty-generators (0.4.6)
       Using pg (0.17.1)
       Using bundler (1.3.2)
       Using tilt (1.4.1)
       Using sprockets (2.10.1)
       Using sprockets-rails (2.0.1)
       Using rails (4.0.0.rc1)
       Using rails_serve_static_assets (0.0.2)
       Using rails_stdout_logging (0.0.3)
       Using rails_12factor (0.0.2)
       Using rdoc (3.12.2)
       Using ref (1.0.5)
       Using sass (3.2.13)
       Using sass-rails (4.0.0)
       Using sdoc (0.3.20)
       Using therubyracer (0.12.0)
       Using turbolinks (2.1.0)
       Using uglifier (2.4.0)
       Using will_paginate (3.0.5)
       Your bundle is complete! It was installed into ./vendor/bundle
       Bundle completed (0.46s)
       Cleaning up the bundler cache.
       Removing rails_log_stdout (01b5bcc572e3)
       Removing rails3_serve_static_assets (84910ceb4ca2)
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       Asset precompilation completed (3.59s)
       Cleaning assets
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for Ruby  -> console, rake, web, worker

-----> Compressing... done, 33.3MB
-----> Launching... done, v17
       http://rocky-shore-1207.herokuapp.com deployed to Heroku

To git@heroku.com:rocky-shore-1207.git
   05cf948..73b6cfa  master -> master

由于 Heroku 说 Using Ruby version: ruby-2.0.0,它检测到我的 Ruby 版本。 但是,当我运行 $ heroku run rake db:migrateheroku run 'ruby -v' 它返回:

Your Ruby version is 1.9.2, but your Gemfile specified 2.0.0

如何在 Heroku 上将 Ruby 版本更改为 2.0.0?

结论: 我注意到我的 rails 应用程序有 .bash_profile 文件,但路径错误。这条路径扰乱了我的 ruby​​ 版本的 heroku 路径。

谢谢大家的帮助:)

【问题讨论】:

    标签: ruby-on-rails ruby git heroku


    【解决方案1】:

    您使用的是 Bundler 版本 1.3.2

    确保升级到 Bundler 2.0+ 版本

    然后最后一次捆绑一个并将您的更改推送到 Heroku

    希望对你有帮助..

    【讨论】:

    • 谢谢你的回答 :) 正如你所指出的,我的 heroku 有一个旧版本的 bundler 呵呵我更新了它然后现在它有了最新的但我认为它是 bundler-1.5.0.rc .2 ?
    • 所以阅读本文的人不会像我一样感到困惑,他的意思是处理 Ruby 2.0+ 的 Bundler。在撰写本文时,Bundler 的最高版本是 1.6.2
    【解决方案2】:

    您是否在本地执行了:bundle update,然后提交了文件Gemfile.lock

    服务器使用的是Ruby 2,但如果没有推送新的锁文件,应用程序仍然配置为使用旧版本。

    查看正在运行的版本:

    $ heroku run console
    > RUBY_VERSION
    

    如果版本是正确的,即您指定的版本,那么您遇到了捆绑程序问题。只需重新安装即可。

    gem install bundler
    

    我推荐一个完整且干净的构建:

    bundle clean --force
    gem install bundler
    bundle install
    

    【讨论】:

    • 是的,我已经尝试了好几次,但到目前为止都无法正常工作....但是当您说“如果新的锁定文件仍将应用程序配置为使用旧版本时,我很好奇没有被推。”你知道如何确定我的应用程序是否使用旧版本的 ruby​​ 吗?可能是这个问题的原因呵呵
    • 感谢您更新答案 :) 我尝试了您的方法,但仍然遇到同样的错误 :( 您能想到这个错误吗??
    • 我刚刚发现我的应用出了什么问题。我的应用程序有一个 .bash_profile 文件,并且该文件扰乱了更改 ruby​​ 的版本。删除文件后,它现在可以正常工作了:)感谢您的帮助 givanse 和 Callum
    • @RyutaroMatsuda 你能详细解释一下吗? .bash_profile 文件是您在应用根级别创建的某个文件吗?
    【解决方案3】:

    这是一个充满希望的远景,但也许可以尝试运行 heroku ps:restart 并希望它选择新的 Ruby 版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-05
      • 2020-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多