![](/img/trans.png)
[英]Heroku - How to fix “cannot load such file — foreman/cli (LoadError)” ? - [Java, Windows, Ruby-on-rails]
[英]LoadError: cannot load such file — travis on Heroku Ruby on Rails
我将Travis CI用于Ruby on Rails应用程序,并且我的构建成功并将其推送到Heroku。 当我尝试检查Heroku上的端点时,出现应用程序错误。
我要研究的问题是通过从应用程序的根目录运行heroku rake db:migrate --app AppNameHere
来进行的,它填充了以下错误:
Running rake db:migrate on lawville... up, run.9338 (Free)
rake aborted!
LoadError: cannot load such file -- travis
/app/config/application.rb:11:in `require'
/app/config/application.rb:11:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
app / config / application.rb (错误的第11行是`require'travis')
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
require 'travis'
require 'nokogiri'
require 'carrierwave'
require 'simple_form'
require 'social-share-button'
require 'redactor-rails'
require 'devise'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module LawVille
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
end
Travis Build(以防万一可以解决我的问题)
https://travis-ci.org/AfolabiOlaoluwa/LawVille/builds/166891343
我的应用程序与application.rb中的内容一起在开发中工作。
我该怎么做才能解决这个问题? 提前致谢。
我发现导致问题的原因是因为我在开发组中放置了宝石,这是错误的,进而使Heroku出现了加载错误。
从开发组中删除gems并将其全局化后,我还从config/application.rb
删除了我自己需要的所有gems,因此我的application.rb
变成了:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module LawVille
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
end
然后它起作用了。
从application.rb中删除require 'travis'
可以肯定的是,travis仅具有将发布后推送到项目存储库的钩子。 在开发中没有对您造成错误的原因是,您(最有可能)已安装travis gem。 Heroku却没有。 从而导致生产失败。
有关更清晰的图片,请参见Travis Ruby Docs 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.