无法将Rails应用程序部署到Heroku,“无效的RUBY_VERSION”

时间:2022-03-03 20:40:28

I'm trying to push my app to Heroku, but I can't get past this error:

我想把我的应用推给Heroku,但是我不能忘记这个错误:

Delta compression using up to 2 threads.
Compressing objects: 100% (1554/1554), done.
Writing objects: 100% (1652/1652), 23.93 MiB | 369 KiB/s, done.
Total 1652 (delta 859), reused 0 (delta 0)

-----> Ruby/Rails app detected
 !
 !     Invalid RUBY_VERSION specified: There-was-an-error-in-your-Gemfile,-and-Bundler-    cannot-continue.
 !     Valid versions: ruby-2.0.0, ruby-1.9.3, ruby-1.9.2, ruby-1.8.7, ruby-1.9.3-jruby-    1.7.0, ruby-1.8.7-jruby-1.7.0, ruby-1.9.3-jruby-1.7.1, ruby-1.8.7-jruby-1.7.1, ruby-1.9.3-rbx-2.0.0dev, ruby-1.8.7-rbx-2.0.0dev
 !

 !     Push rejected, failed to compile Ruby/Rails app

To git@heroku.com:myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:myapp.git'

I'm running ruby 1.9.3p448. I followed the steps here, and the top of my Gemfile includes:

我运行ruby 1.9.3p448。我遵循了这里的步骤,我的Gemfile顶部包括:

source 'http://rubygems.org'
ruby '1.9.3'

gem 'rails', '3.2.13'

When I run "heroku run 'ruby -v'" it returns ruby 1.9.2p290. What's going on?

当我运行“heroku运行‘ruby -v’”时,它返回ruby 1.9.2p290。这是怎么呢

Edit: Here's my whole Gemfile:

编辑:这是我的全部Gemfile:

source 'http://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.13'

gem 'pg'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

gem 'devise'
gem 'nokogiri'
gem 'i18n'
gem 'paperclip'
gem 'kaminari'
gem 'rest-client'
require 'addressable/uri'

group :development do
  gem 'better_errors'
end

2 个解决方案

#1


4  

You have an error in your Gemfile, in the line require 'addressable/uri'. You can’t use require inside a Gemfile. The load path hasn’t been set up yet, so you get a LoadError which Bundler catches and produces an error message.

在Gemfile中有一个错误,在“可寻址/uri”行中。你不能在Gemfile里面使用require。加载路径尚未设置,因此您将获得一个LoadError, Bundler捕获并生成错误消息。

Heroku is trying to use bundle platform --ruby to determine the version of Ruby you want to use, but is not properly detecting the error condition and treating the error message as the version. This is obviously not a valid version, and so it produces the error you are seeing.

Heroku正在尝试使用bundle平台——ruby来确定要使用的ruby版本,但是没有正确地检测错误条件并将错误消息作为版本来处理。这显然不是一个有效的版本,因此会产生您正在看到的错误。

I’m guessing you’re using require because to use the Addressable gem you need to require either addressable/uri or addressable/template (or both) and you can’t just use require 'addressable'. In this case you can use the :require option of Bundler:

我猜您使用的是require,因为要使用可寻址gem,您需要要么使用可寻址/uri,要么使用可寻址/模板(或两者都需要),而且您不能只使用require '可寻址'。在这种情况下,您可以使用Bundler的:require选项:

gem 'addressable', :require => 'addressable/uri'

If you do need to require more than one thing, you can use an array:

如果你确实需要多于一件东西,你可以使用数组:

gem 'addressable', :require => ['addressable/uri', 'addressable/template']

#2


0  

Just wondering if this changes your situation, as your Gemfile almost looks like mine, but for these changes.

只是想知道这是否改变了你的情况,因为你的Gemfile看起来和我的差不多,但是为了这些变化。

1)Of course, assuming you are in your Rails Root folder and your less Gemfile is the actual one above. You did also bundle too after changes.

1)当然,假设您在Rails根文件夹中,而较小的Gemfile是上面的实际文件夹。您在更改之后也打包了。

2) change source 'https://rubygems.org'

2)改变源“https://rubygems.org”

3) optional Heck, try switching version to ruby '2.0.0' just to get passed it.

3)可选的见鬼,试着将版本切换到ruby的“2.0.0”来通过测试。

4) I think this is needed too:

我认为这也是需要的:

gem 'rails_12factor'

宝石的rails_12factor

All these tricks should make it work at least.

所有这些技巧至少可以让它发挥作用。

EDIT

编辑

Why is require 'addressable/uri' there? remove this and add gem 'addressable' instead.

为什么这里有require 'addressable/uri' ?删除它并添加gem“addressable”。

#1


4  

You have an error in your Gemfile, in the line require 'addressable/uri'. You can’t use require inside a Gemfile. The load path hasn’t been set up yet, so you get a LoadError which Bundler catches and produces an error message.

在Gemfile中有一个错误,在“可寻址/uri”行中。你不能在Gemfile里面使用require。加载路径尚未设置,因此您将获得一个LoadError, Bundler捕获并生成错误消息。

Heroku is trying to use bundle platform --ruby to determine the version of Ruby you want to use, but is not properly detecting the error condition and treating the error message as the version. This is obviously not a valid version, and so it produces the error you are seeing.

Heroku正在尝试使用bundle平台——ruby来确定要使用的ruby版本,但是没有正确地检测错误条件并将错误消息作为版本来处理。这显然不是一个有效的版本,因此会产生您正在看到的错误。

I’m guessing you’re using require because to use the Addressable gem you need to require either addressable/uri or addressable/template (or both) and you can’t just use require 'addressable'. In this case you can use the :require option of Bundler:

我猜您使用的是require,因为要使用可寻址gem,您需要要么使用可寻址/uri,要么使用可寻址/模板(或两者都需要),而且您不能只使用require '可寻址'。在这种情况下,您可以使用Bundler的:require选项:

gem 'addressable', :require => 'addressable/uri'

If you do need to require more than one thing, you can use an array:

如果你确实需要多于一件东西,你可以使用数组:

gem 'addressable', :require => ['addressable/uri', 'addressable/template']

#2


0  

Just wondering if this changes your situation, as your Gemfile almost looks like mine, but for these changes.

只是想知道这是否改变了你的情况,因为你的Gemfile看起来和我的差不多,但是为了这些变化。

1)Of course, assuming you are in your Rails Root folder and your less Gemfile is the actual one above. You did also bundle too after changes.

1)当然,假设您在Rails根文件夹中,而较小的Gemfile是上面的实际文件夹。您在更改之后也打包了。

2) change source 'https://rubygems.org'

2)改变源“https://rubygems.org”

3) optional Heck, try switching version to ruby '2.0.0' just to get passed it.

3)可选的见鬼,试着将版本切换到ruby的“2.0.0”来通过测试。

4) I think this is needed too:

我认为这也是需要的:

gem 'rails_12factor'

宝石的rails_12factor

All these tricks should make it work at least.

所有这些技巧至少可以让它发挥作用。

EDIT

编辑

Why is require 'addressable/uri' there? remove this and add gem 'addressable' instead.

为什么这里有require 'addressable/uri' ?删除它并添加gem“addressable”。