【问题标题】:Getting error while deploying rails app on heroku在heroku上部署rails应用程序时出错
【发布时间】:2016-04-25 03:58:57
【问题描述】:

我在 Heroku 上从 github 部署我的应用程序时遇到此错误...

构建日志 -->

-----> Ruby app detected

-----> Compiling Ruby/Rails

-----> Using Ruby version: ruby-2.2.0

-----> Installing dependencies using bundler 1.11.2

       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment

       Fetching gem metadata from https://rubygems.org/...........

       Fetching version metadata from https://rubygems.org/...

       Fetching dependency metadata from https://rubygems.org/..

       Installing json 1.8.3 with native extensions

       Installing i18n 0.7.0

       Installing rake 10.5.0

       Installing minitest 5.8.3

       Installing thread_safe 0.3.5

       Installing builder 3.2.2

       Installing erubis 2.7.0

       Installing mini_portile2 2.0.0

       Installing rack 1.6.4

       Installing mime-types 2.99

       Installing sass 3.4.21

       Installing thor 0.19.1

       Installing coffee-script-source 1.10.0

       Installing formtastic_i18n 0.6.0

       Using bundler 1.11.2

       Installing arel 6.0.3

       Installing execjs 2.6.0

       Installing concurrent-ruby 1.0.0

       Installing tilt 1.4.1

       Installing bcrypt 3.1.7 with native extensions

       Installing cancan 1.6.10

       Installing orm_adapter 0.5.0

       Installing multi_json 1.11.2

       Installing request_store 1.3.0

       Installing puma 2.16.0 with native extensions

       Installing rails_serve_static_assets 0.0.4

       Installing rails_stdout_logging 0.0.4

       Installing tzinfo 1.2.2

       Installing rack-test 0.6.3

       Installing nokogiri 1.6.7.1 with native extensions

       Installing warden 1.2.6

       Installing rdoc 4.2.1

       Installing mail 2.6.3

       Installing bourbon 4.2.7

       Installing coffee-script 2.4.1

       Installing uglifier 2.5.3

       Installing autoprefixer-rails 6.3.1

       Installing sprockets 3.5.2

       Installing rails_12factor 0.0.2

       Installing sdoc 0.4.0

       Installing activesupport 4.2.2

       Installing bootstrap-sass 3.3.6

       Installing rails-deprecated_sanitizer 1.0.3

       Installing globalid 0.3.6

       Installing arbre 1.0.3

       Installing activemodel 4.2.2

       Installing jbuilder 2.2.3

       Installing pundit 1.1.0

       Installing activejob 4.2.2

       Installing activerecord 4.2.2

       Installing polyamorous 1.3.0

       Installing rails-dom-testing 1.0.7

       Installing loofah 2.0.3

       Installing rails-html-sanitizer 1.0.2

       Installing actionview 4.2.2

       Installing actionpack 4.2.2

       Installing actionmailer 4.2.2

       Installing railties 4.2.2

       Installing formtastic 3.1.4

       Installing has_scope 0.6.0

       Installing sprockets-rails 3.0.0

       Installing kaminari 0.16.3

       Installing ransack 1.7.0

       Installing draper 2.1.0

       Installing coffee-rails 4.1.0

       Installing responders 2.1.1

       Installing jquery-ui-rails 5.0.5

       Installing jquery-rails 4.0.3

       Installing rails 4.2.2

       Installing turbolinks 2.3.0

       Installing sass-rails 5.0.2

       Installing inherited_resources 1.6.0

       Installing devise 3.5.6

       Installing activeadmin 1.0.0.pre2

       Bundle complete! 24 Gemfile dependencies, 74 gems now installed.

       Gems in the groups development and test were not installed.

       Bundled gems are installed into ./vendor/bundle.

       Post-install message from rdoc:

       Depending on your version of ruby, you may need to install ruby rdoc/ri data:

       <= 1.8.6 : unsupported

       = 1.8.7 : gem install rdoc-data; rdoc-data --install

       = 1.9.1 : gem install rdoc-data; rdoc-data --install

       >= 1.9.2 : nothing to do! Yay!

       Bundle completed (23.34s)

       Cleaning up the bundler cache.

sh: 2: Syntax error: Unterminated quoted string

sh: 2: Syntax error: Unterminated quoted string

 !

 !     Could not detect rake tasks

 !     ensure you can run `$ bundle exec rake -P` against your app

 !     and using the production group of your Gemfile.

 !     rake aborted!

 !     Bundler::GemRequireError: There was an error while trying to load the gem 'activeadmin'.

 !     /tmp/build_e5688395917c72f2956d14c05dd2fdf5/nischaynamdev-hostel_mess_pay-a993b86d6645abbdfb41cb6de99c6900648d588f/vendor/bundle/ruby/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'

 !     /tmp/build_e5688395917c72f2956d14c05dd2fdf5/nischaynamdev-hostel_mess_pay-a993b86d6645abbdfb41cb6de99c6900648d588f/vendor/bundle/ruby/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'

 !     /tmp/build_e5688395917c72f2956d14c05dd2fdf5/nischaynamdev-hostel_mess_pay-a993b86d6645abbdfb41cb6de99c6900648d588f/vendor/bundle/ruby/2.2.0/gems/bundler-1.11

我的 production.rb 文件:

    Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.
  # Code is not reloaded between requests.
  config.cache_classes = true
  config.force_ssl = true
  config.serve_static_assets = true
  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Enable Rack::Cache to put a simple HTTP cache in front of your application
  # Add `rack-cache` to your Gemfile before enabling this.
  # For large-scale production use, consider using a caching reverse proxy like
  # NGINX, varnish or squid.
  # config.action_dispatch.rack_cache = true

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile =true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

  # Specifies the header that your server uses for sending files.
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true

  # Use the lowest log level to ensure availability of diagnostic information
  # when problems arise.
  config.log_level = :debug

  # Prepend all log lines with the following tags.
  # config.log_tags = [ :subdomain, :uuid ]

  # Use a different logger for distributed setups.
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

  # Use a different cache store in production.
  # config.cache_store = :mem_cache_store

  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  # config.action_controller.asset_host = 'http://assets.example.com'

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation cannot be found).
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners.
  config.active_support.deprecation = :notify

  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new

  # Do not dump schema after migrations.
  config.active_record.dump_schema_after_migration = false
  config.assets.precompile +=
      %w( #{Rails.root}/vendor/assets/stylesheets/active_admin.css.scss)
  config.assets.precompile +=
      %w( #{Rails.root}/vendor/assets/javascripts/active_admin.js.coffee)

  RAILS_ENV=production bundle exec rake assets:precompile

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  host = 'messpay.herokuapp.com'
  config.action_mailer.default_url_options = { host: host }
  ActionMailer::Base.smtp_settings = {
      :address        => 'smtp.sendgrid.net',
      :port           => '587',
      :authentication => :plain,
      :user_name      => ENV['SENDGRID_USERNAME'],
      :password       => ENV['SENDGRID_PASSWORD'],
      :domain         => 'heroku.com',
      :enable_starttls_auto => true
end

rakefile

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks

宝石文件:

source 'https://rubygems.org'
gem 'jquery-ui-rails'

gem 'activeadmin', '~> 1.0.0.pre2'
gem 'devise'
gem 'cancan'
gem 'draper'
gem 'pundit'
gem 'rails',        '4.2.2'
gem 'bcrypt',               '3.1.7'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
gem 'sass-rails',   '5.0.2'
gem 'uglifier',     '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks',   '2.3.0'
gem 'jbuilder',     '2.2.3'
gem 'sdoc',         '0.4.0', group: :doc

group :development, :test do
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'

  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '~> 1.1', '>= 1.1.7'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'rails_12factor', '0.0.2'
  gem 'puma', '~> 2.16'
end

我已经尝试了大多数预编译命令选项,您可以检查我的 production.rb,但构建日志在活动管理 gem 中显示问题!

请帮帮我,谢谢

【问题讨论】:

  • 我会尝试使用heroku run bash 连接到heroku 机器并尝试手动安装activeadmin gem。这样你可能会看到更多有用的错误。
  • 收到此错误!
  • ERROR: While executing gem ... (Gem::DependencyError)@maxpleaner
  • 当你得到一个不同的错误时,它通常是一个很好的薄。很多时候 gems 都有外部依赖。请在您的问题中发布此 DependencyError 的完整错误跟踪*
  • 好的,我正在添加.. 等一下

标签: ruby-on-rails ruby heroku deployment


【解决方案1】:

查看您的 gem 文件。尝试为生产环境加载 gem ActiveAdmin 似乎有问题,我将从那里开始,可能会将其上传以查看。

**在查看 Gemfile 之后...我认为这可能还可以。

所以我正在考虑将config.assets.compile =true 更改为config.assets.compile = true 所以基本上添加一个空格以防出现问题。然后我会运行bundle exec rake -P,就像错误本身所暗示的那样。然后尝试rake assets:precompile 看看是否能解决问题。您可能还需要运行heroku run rake db:migrate。我之前在 Heroku 上遇到过这样的问题。

【讨论】:

  • 我需要把activeadmin gem放到gem文件的生产组吗?
  • 不看 Gemfile 本身就不确定.... 我认为生产组设置有问题。您可以编辑问题以添加 Gemfile 内容吗?
猜你喜欢
  • 2017-08-22
  • 2014-08-13
  • 1970-01-01
  • 2015-03-17
  • 2015-09-22
  • 2015-12-09
  • 1970-01-01
  • 2020-05-15
相关资源
最近更新 更多