Solucionado (ver solução)
Solucionado
(ver solução)
5
respostas

gem 'listen' não encontrada ao tentar levantar o servidor

Quando executo o rails server vejo a seguinte pilha de erros, dizendo que não foi possível carregar a gem 'listen':

/Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require': Could not load the 'listen' gem. Addgem 'listen'to the development group of your Gemfile (LoadError) from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inblock in require' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in load_dependency' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inrequire' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/evented_file_update_checker.rb:55:in block in initialize' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/kernel/reporting.rb:13:inblock in silence_warnings' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/kernel/reporting.rb:26:in with_warnings' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/kernel/reporting.rb:13:insilence_warnings' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/evented_file_update_checker.rb:53:in initialize' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/i18n_railtie.rb:59:innew' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/i18n_railtie.rb:59:in initialize_i18n' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/i18n_railtie.rb:15:inblock in ' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:36:in execute_hook' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:45:inblock in run_load_hooks' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:in each' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:inrun_load_hooks' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:65:in block in <module:Finisher>' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:ininstance_exec' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in run' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:inblock in run_initializers' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in block in tsort_each' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:inblock (2 levels) in each_strongly_connected_component' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in each_strongly_connected_component_from' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:inblock in each_strongly_connected_component' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in each' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:incall' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in each_strongly_connected_component' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:intsort_each' from /Users/icaro/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in tsort_each' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:inrun_initializers' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/application.rb:352:in initialize!' from /Users/icaro/Desenvolvimento/workspace2/lojadecamisetas/config/environment.rb:5:in' from /Users/icaro/Desenvolvimento/workspace2/lojadecamisetas/config.ru:3:in require_relative' from /Users/icaro/Desenvolvimento/workspace2/lojadecamisetas/config.ru:3:inblock in ' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in instance_eval' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:55:ininitialize' from /Users/icaro/Desenvolvimento/workspace2/lojadecamisetas/config.ru:in new' from /Users/icaro/Desenvolvimento/workspace2/lojadecamisetas/config.ru:in' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in eval' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:49:innew_from_string' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:40:in parse_file' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/server.rb:318:inbuild_app_and_options_from_config' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/server.rb:218:in app' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands/server.rb:59:inapp' from /Users/icaro/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/server.rb:353:in wrapped_app' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands/server.rb:124:inlog_to_stdout' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands/server.rb:77:in start' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:90:inblock in server' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in tap' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:inserver' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in run_command!' from /Users/icaro/.rvm/gems/ruby-2.3.0@global/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in' from bin/rails:9:in require' from bin/rails:9:in'

5 respostas

Opa,

Addgem 'listen'to the development group of your Gemfile (LoadError)

Você tentou adicionar a gem? Só estou perguntando pq foi justamente a dica da exception.

Oi Ícaro, tudo bem? Você poderia mostrar seu Gemfile e Gemfile.lock? Pode ter alguma incosistência nas versão de alguma gem que utilize a gem 'listen' com o seu Gemfile.

Meu Gemfile estava igualzinho ao do material escrito. Só que pra funcionar eu tive que adicionar a dependência do listen nele.

A única diferença entre o meu gemfile e o da aula é na versão do rails. Será que é por isso?

Segue abaixo o conteúdo: Gemfile

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks'

gem 'listen', '~> 3.1.5'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (5.0.0.1)
      actionpack (= 5.0.0.1)
      nio4r (~> 1.2)
      websocket-driver (~> 0.6.1)
    actionmailer (5.0.0.1)
      actionpack (= 5.0.0.1)
      actionview (= 5.0.0.1)
      activejob (= 5.0.0.1)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.0.0.1)
      actionview (= 5.0.0.1)
      activesupport (= 5.0.0.1)
      rack (~> 2.0)
      rack-test (~> 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.0.0.1)
      activesupport (= 5.0.0.1)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    activejob (5.0.0.1)
      activesupport (= 5.0.0.1)
      globalid (>= 0.3.6)
    activemodel (5.0.0.1)
      activesupport (= 5.0.0.1)
    activerecord (5.0.0.1)
      activemodel (= 5.0.0.1)
      activesupport (= 5.0.0.1)
      arel (~> 7.0)
    activesupport (5.0.0.1)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (~> 0.7)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    arel (7.1.4)
    builder (3.2.2)
    concurrent-ruby (1.0.2)
    erubis (2.7.0)
    ffi (1.9.14)
    globalid (0.3.7)
      activesupport (>= 4.1.0)
    i18n (0.7.0)
    jquery-rails (4.2.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.4)
      mime-types (>= 1.16, < 4)
    method_source (0.8.2)
    mime-types (3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0521)
    mini_portile2 (2.1.0)
    minitest (5.10.1)
    nio4r (1.2.1)
    nokogiri (1.6.8.1)
      mini_portile2 (~> 2.1.0)
    rack (2.0.1)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (5.0.0.1)
      actioncable (= 5.0.0.1)
      actionmailer (= 5.0.0.1)
      actionpack (= 5.0.0.1)
      actionview (= 5.0.0.1)
      activejob (= 5.0.0.1)
      activemodel (= 5.0.0.1)
      activerecord (= 5.0.0.1)
      activesupport (= 5.0.0.1)
      bundler (>= 1.3.0, < 2.0)
      railties (= 5.0.0.1)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.1)
      activesupport (>= 4.2.0, < 6.0)
      nokogiri (~> 1.6.0)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    railties (5.0.0.1)
      actionpack (= 5.0.0.1)
      activesupport (= 5.0.0.1)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (11.3.0)
    rb-fsevent (0.9.8)
    rb-inotify (0.9.7)
      ffi (>= 0.5.0)
    ruby_dep (1.5.0)
    sprockets (3.7.0)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.0)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.3.12)
    thor (0.19.4)
    thread_safe (0.3.5)
    turbolinks (5.0.1)
      turbolinks-source (~> 5)
    turbolinks-source (5.0.0)
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    websocket-driver (0.6.4)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.2)

PLATFORMS
  ruby

DEPENDENCIES
  jquery-rails
  listen (~> 3.1.5)
  rails (~> 5.0.0, >= 5.0.0.1)
  sqlite3
  turbolinks
  tzinfo-data

BUNDLED WITH
1.13.6
solução!

Obrigado, Ícaro! Não acho provável que a versão do Rails seja o problema. Vejo dois possíveis problemas, vamos ver se consigo te ajudar.

Vejo duas possibilidades:

Primeiro a mais simples: Você tentou iniciar o server com o comando bundle exec?

bundle exec rails s

Dessa forma, o bundler se responsabiliza pelo gerenciamento de dependências e versões das suas gemas.


Segunda possibilidade:

Você está utilizando Windows? No repositório da gem listen eles recomendam instalar uma outra gem caso você utilize Windows (mais informações aqui). Se você utiliza Windows, sugiro seguir a recomendação do repositório adicionando isso ao seu gemfile:

gem 'wdm', '>= 0.1.0' if Gem.win_platform?

Você precisou adicionar a gem listen por causa justamente desse erro, ou por algum outro motivo?

Teoricamente, não deveria ser necessário, pois o próprio ActiveSupport do Rails já utiliza essa gem e ele mesmo resolveria essa dependência. Por isso estou estranhando esse comportamento.

Pode essas sugestões?

Valeu pelas dicas Rodrigo.

Eu estava tentando no OS X. Tive que adicionar a dependência do listen no gemfile pra poder levantar a aplicação, senão ficava aparecendo o erro que coloquei na primeira postagem.

Na verdade eu queria entender porque não está funcionando. No Windows até tentei fazer mas tive algumas complicações pra instalar o rails e utilizar o gem, e aí perdi a paciência rs.

De qualquer forma vou marcar a dúvida como solucionada.

Obrigado pela ajuda pessoal! :)