0

我正在尝试通过 heroku 使用 Publify gem 托管一个 RoR 应用程序。但是我不断收到以下错误。我已按照有关 Heroku 的 Publify github 页面上的说明进行操作,https://github.com/publify/publify。另一个有趣的事情是它在我自己的服务器(rails s)上完美运行,这表明 gemfile 中的环境有问题。

在此先感谢您的帮助。

这是我收到的错误(heroku push):

Your version of git is 1.9.3. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
Checking for app files to sync... done, 590 files needed
Uploading: 100.0% (ETA: 0s)
Launching build process...  done
Preparing app for compilation... done
Fetching buildpack... done
Detecting buildpack... done, Buildkit+Ruby
Fetching cache... empty
Compiling app...
  Compiling for Ruby
  Compiling Ruby/Rails
sh: Syntax error: Unterminated quoted string
 !
    ERROR: There was an error parsing your Gemfile, we cannot continue
    ERROR: Unfortunately, a fatal error has occurred. Please see the Bundler
    ERROR: troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
    ERROR: /tmp/compile_unHgf/Gemfile:19:in `eval_gemfile': You need to configure config/database.yml first (RuntimeError)
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/dsl.rb:36:in `instance_eval'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/dsl.rb:36:in `eval_gemfile'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/dsl.rb:10:in `evaluate'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/definition.rb:26:in `build'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler.rb:153:in `definition'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli/platform.rb:10:in `block in run'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/ui/shell.rb:69:in `silence'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli/platform.rb:9:in `run'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli.rb:358:in `platform'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor/command.rb:27:in `run'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor.rb:363:in `dispatch'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/vendor/thor/base.rb:440:in `start'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/cli.rb:9:in `start'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/bin/bundle:20:in `block in <top (required)>'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/gems/bundler-1.6.3/bin/bundle:20:in `<top (required)>'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/bin/bundle:19:in `load'
    ERROR: from /tmp/d20150118-87-1khnax5/bundler-1.6.3/bin/bundle:19:in `<main>'
 !
ERROR: Build failed, exited 1

由于问题是由gemfile引起的,这里是我的,

source 'https://rubygems.org'

if ENV["HEROKU"]
  ruby '2.1.3'

  gem "pg"
  gem "thin" # Change this to another web server if you want (ie. unicorn, passenger, puma...)
  gem "rails_12factor"
else

  require 'yaml'
  env = ENV["RAILS_ENV"] || 'development'
  dbfile = File.expand_path("../config/database.yml", __FILE__)

  unless File.exists?(dbfile)
    if ENV['DB']
      FileUtils.cp "config/database.yml.#{ENV['DB'] || 'postgres'}", 'config/database.yml'
    else
      raise "You need to configure config/database.yml first"
    end
  end

  conf = YAML.load(File.read(dbfile))
  environment = conf[env]
  adapter = environment['adapter'] if environment
  raise "You need define an adapter in your database.yml or set your RAILS_ENV variable" if adapter == '' || adapter.nil?
  case adapter
  when 'sqlite3'
    gem 'sqlite3'
  when 'postgresql'
    gem 'pg'
  when 'mysql2'
    gem 'mysql2'
  else
    raise "Don't know what gem to use for adapter #{adapter}"
  end
end

gem 'rails', '~> 4.1.7'
gem 'htmlentities'
gem 'bluecloth', '~> 2.1'
gem 'coderay', '~> 1.1.0'
gem 'kaminari'
gem 'RedCloth', '~> 4.2.8'
gem 'addressable', '~> 2.1', :require => 'addressable/uri'
gem 'mini_magick', '~> 3.8.1', :require => 'mini_magick'
gem 'uuidtools', '~> 2.1.1'
gem 'flickraw-cached'
gem 'rubypants', '~> 0.2.0'
gem 'rake', '~> 10.3.2'
#gem 'acts_as_list'
#gem 'acts_as_tree_rails3'
gem 'fog'
gem 'recaptcha', :require => 'recaptcha/rails', :branch => 'rails3'
gem 'carrierwave', '~> 0.10.0'
gem 'akismet', '~> 1.0'
gem 'twitter', '~> 5.6.0'

gem "jquery-rails", "~> 3.1.0"
gem "jquery-ui-rails", "~> 5.0.2"

gem 'rails-timeago', '~> 2.0'

gem 'rails_autolink', '~> 1.1.0'
gem 'dynamic_form', '~> 1.1.4'

gem 'non-stupid-digest-assets'

# removed from Rails-core as Rails 4.0
gem 'actionpack-page_caching', '~> 1.0.2'
gem 'rails-observers', '~> 0.1.2'

group :assets do
  gem 'sass-rails', " ~> 4.0.3"
  gem 'coffee-rails', " ~> 4.0.1"
  gem 'uglifier'
end

group :development, :test do
  gem 'thin'
  gem 'factory_girl', '~> 4.5.0'
  gem 'capybara'
  gem 'rspec-rails', '~> 3.1.0'
  gem 'simplecov', :require => false
  gem 'pry-rails'
  gem 'better_errors', '~> 2.0.0'
  gem 'binding_of_caller'
  gem 'guard-rspec'
end

# Install gems from each theme
Dir.glob(File.join(File.dirname(__FILE__), 'themes', '**', "Gemfile")) do |gemfile|
  eval(IO.read(gemfile), binding)
end
4

1 回答 1

1

看起来Gemfile您要使用的部分,即该if ENV["HEROKU"]块没有被执行。相反,else会调用该块,这会在您发布的日志片段中引发错误。

有几个可能的原因,我将按概率顺序写下来

  • 您没有heroku config:set HEROKU=true按照发布文档中的说明进行设置
  • heroku 忽略环境变量
  • 您正在使用的自定义构建包会干扰您想要实现的目标
  • 别的东西坏了
于 2015-01-18T11:50:02.730 回答