[英]LoadError: cannot load such file — travis on Heroku Ruby on Rails
I am using Travis CI for a Ruby on Rails application and my Build was successful and pushed to Heroku. 我将Travis CI用于Ruby on Rails应用程序,并且我的构建成功并将其推送到Heroku。 When I try to check the endpoint on Heroku, I get Application Error.
当我尝试检查Heroku上的端点时,出现应用程序错误。
What I have done to investigate the problem is by running heroku rake db:migrate --app AppNameHere
from the root of my application, and it populates the below error: 我要研究的问题是通过从应用程序的根目录运行
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 (Note line 11 from the error is `require 'travis') 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 (In case anything can shed light to fix my problem) Travis Build(以防万一可以解决我的问题)
https://travis-ci.org/AfolabiOlaoluwa/LawVille/builds/166891343
https://travis-ci.org/AfolabiOlaoluwa/LawVille/builds/166891343
My application with what is in application.rb works on development. 我的应用程序与application.rb中的内容一起在开发中工作。
What can I do to solve this problem? 我该怎么做才能解决这个问题? Thanks in advance.
提前致谢。
What I figured out that caused the problem is because I was having my gems in development group which is wrong and in turns made Heroku having a load error. 我发现导致问题的原因是因为我在开发组中放置了宝石,这是错误的,进而使Heroku出现了加载错误。
After removing the gems from development group and made it global, I removed also all the gems I required myself from my config/application.rb
, such the my application.rb
becomes: 从开发组中删除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
Then it worked. 然后它起作用了。
Remove require 'travis'
from application.rb 从application.rb中删除
require 'travis'
Pretty sure travis just has a hook for post push to your project repo. 可以肯定的是,travis仅具有将发布后推送到项目存储库的钩子。 The reason this did not error for you in development is because you (most likely) have the travis gem installed.
在开发中没有对您造成错误的原因是,您(最有可能)已安装travis gem。 Heroku however does not.
Heroku却没有。 Thus the failure in production.
从而导致生产失败。
For a clearer picture see the Travis Ruby Docs . 有关更清晰的图片,请参见Travis Ruby Docs 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.