简体   繁体   中英

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. When I try to check the endpoint on Heroku, I get Application Error.

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:

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')

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)

https://travis-ci.org/AfolabiOlaoluwa/LawVille/builds/166891343

My application with what is in application.rb works on development.

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.

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:

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

Pretty sure travis just has a hook for post push to your project repo. The reason this did not error for you in development is because you (most likely) have the travis gem installed. Heroku however does not. Thus the failure in production.

For a clearer picture see the Travis Ruby Docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM