LoadError: Could not load the 'listen' gem (Rails 5)

前端 未结 10 489
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 05:36

I\'ve got an API mode Rails 5 app that won\'t let me run rake routes or rails s. The error I get is:

$ rake routes
rake aborted!
Lo         


        
相关标签:
10条回答
  • 2020-12-14 06:22

    I had similar problem today after upgrade from Rails 5.1.5 to 5.2.0. First time running the server there was the following 'missing assets' problem:

    ActionView::Template::Error (The asset "asterisk_orange.png" is not present in the asset pipeline.)
    

    Trying to precompile the assets shows the 'gem listen error':

    $ bundle exec rake assets:precompile
    rake aborted!
    LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
    

    My solution was to explicit set production environment:

    $ RAILS_ENV=production bundle exec rake assets:precompile
    

    This precompiles the assets w/o problems and the 'missing assets' problem was fixed.

    0 讨论(0)
  • 2020-12-14 06:25

    You might by mistake have set bundle install --without at some point, I sure did anyways.

    To revert this run:

    bundle config --delete without

    I also ran bundle config --delete with as I manually set with option as well by mistake. Running both should get you back to default behaviour.

    After having deleted the without config I could successfully run a bundle install again and afterwards my rails s, rails db:migrate etc. worked.


    You can confirm if this is your issue by running bundle install and look at the second last line in the output. If it states:

    Gems in the groups development and test were not installed.

    It's for sure above solution should work for you.

    0 讨论(0)
  • 2020-12-14 06:26

    I found an easy fix after a lot of trials of rebuild's

    bundle config --delete without
    bundle config --delete with
    bundle install
    

    If you accidentally built the gemset prior to seting your envirnoment correctly, then this may help clear out the problems.

    0 讨论(0)
  • 2020-12-14 06:26

    I had same error when trying to generate mongoid database file.

    but I created rails new project on ruby 2.5.1. Your ruby is 2.2. so the causality could be different in my situtation.

    when I used rails new project, it was created in version 5.2, then I changed gem to 5.1.2 and problem arises. When I created with rails _5.1.6_ new in Gemfile there is generated additional pack for development.

      group :development do
          # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
          gem 'web-console', '>= 3.3.0'
          gem 'listen', '>= 3.0.5', '< 3.2'
          # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
          gem 'spring'
          gem 'spring-watcher-listen', '~> 2.0.0'
        end
    

    this way 'listen' showed me in gemfile automaticaly

    0 讨论(0)
提交回复
热议问题