heroku 无法部署我的应用程序

heroku failing to deploy my app

我无法在 heroku 上推送我的 rails 应用程序。以下是我尝试在 heroku 上推送 rails 应用程序时收到的错误消息。

Ruby app detected Compiling Ruby/Rails sh: 1: Gemfile: not found ! ! There was an error parsing your Gemfile, we cannot continue ! ! [!] There was an error parsing Gemfile: syntax error, unexpected ':', expecting end-of-input - group: production do ! ^. Bundler cannot continue. ! ! # from /tmp/build_c114d933dd903e377866500bea22e827/Gemfile:50 ! # ------------------------------------------- ! # ! > group: production do ! # gem 'pg' ! # ------------------------------------------- ! ! Push rejected, failed to compile Ruby app.

这就是我的 gemfile 的样子。

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use sqlite3 as the database for Active Record

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

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

group :development, :test do
gem 'sqlite3'

  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

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

好的,我明白了。您收到此错误是因为您在 gem 文件

中犯了两个错误

(1) 您忘记在 gem 文件中定义 gem 'byebug' 的版本。

(2) 您写的 group: production do 应该是 group :production do 我敢肯定,在您解决这两个问题之前,您将无法在本地 运行 您的应用程序。

在您的 gem 文件中添加 gem 'byebug', '3.4.0'。你只有 gem 'byebug' 如果你只是添加 '3.4.0' 然后在 gem 文件

底部的第 4 行写 group :production do 而不是 group: production do

将这些更改添加到 gem 文件后,确保 运行 bundle install 然后 bundle update

成功完成上述过程后,您可以 运行 下面的命令将您的应用程序上传到 heroku。

git init

git add .

git commit -am "some comment"

git push heroku master

heroku open 

解析 Gemfile 时出错:语法错误,意外的“:”,预期输入结束 - 组:生产

如上日志...只是语法错误

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

更新自

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