Heroku:由于gem文件而导致推送失败

时间:2019-06-18 22:28:41

标签: ruby heroku rubygems bundler

我有一个非常简单的应用程序,试图将其推送到Heroku并遇到问题。我没有安装任何特殊的宝石,也没有做任何特殊的事情,但是在解析我的Gemfile时仍然遇到错误。

我看到了一些示例,这些示例添加了Gem'rails_12factor'来定义Bundler版本,Ruby版本,更新捆绑程序,更新系统。完成任何这些修复后,该错误不会更改。我最近安装了RailsInstaller,所以我正在运行所有版本的当前版本。

这是我的Gemfile

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

ruby '~> 2.3.3'
gem 'bundler', '~> 2.0.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.7'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and viewrubys
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more:     https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug',  '11.0.1'

  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'

  # Use sqlite3 as the database for Active Record
  gem "sqlite3", "~> 1.3.6"

end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

这是我得到的错误:

$ git push herokustaging master
Enumerating objects: 300, done.
Counting objects: 100% (300/300), done.
Delta compression using up to 8 threads
Compressing objects: 100% (275/275), done.
Writing objects: 100% (300/300), 59.91 KiB | 1.50 MiB/s, done.
Total 300 (delta 96), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:                         Detected buildpacks: Ruby,Node.js
remote:                         See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote:
remote:  !
remote:  !     There was an error parsing your Gemfile, we cannot continue
remote:  !     /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
remote:  !     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
remote:  !     from /tmp/d20190618-120-vf683l/bundler-2.0.1/bin/bundle:23:in `<main>'
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to sojournsb.

2 个答案:

答案 0 :(得分:1)

错误消息的相关部分似乎是

can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

您不需要在Heroku上安装bundler,而且我不确定Gemfile甚至在开发中对您有多大帮助。如果您没有Bundler,那么首先如何运行bundle install

尝试从bundler(和Gemfile)中取出Gemfile.lock,然后重新部署。

答案 1 :(得分:0)

我的问题是我使用的是与Heroku不兼容的旧版Ruby。我安装了最新版本的Ruby,并重建了我的应用程序。然后,我得以成功推送到Heroku。

确实很简单,但是错误消息并不完全有用。

任何人,谢谢!