質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

4192閲覧

rails aborted! LoadError: cannot load such file -- listen

退会済みユーザー

退会済みユーザー

総合スコア0

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/08/01 14:51

前提・実現したいこと

M1 macで rails sとrails (railsバージョン) (app名) -d mysql を実行したい

発生している問題・エラーメッセージ

% rails 6.1.4 new bpp -d mysql
create

〜省略しました〜

Using sass-rails 6.0.0
Bundle complete! 17 Gemfile dependencies, 56 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use bundle info [gemname] to see where a bundled gem is installed.
run bundle binstubs bundler
rails webpacker:install
rails aborted!
LoadError: cannot load such file -- listen
/Users/machu/app/bpp/config/environments/development.rb:72:in block in <main>' /Users/machu/app/bpp/config/environments/development.rb:3:in <main>'
/Users/machu/app/bpp/config/environment.rb:5:in `<main>'
Tasks: TOP => app:template => environment
(See full trace by running task with --trace)

エラーメッセージ rails aborted! LoadError: cannot load such file -- listen /Users/machu/app/bpp/config/environments/development.rb:72:in `block in <main>' /Users/machu/app/bpp/config/environments/development.rb:3:in `<main>' /Users/machu/app/bpp/config/environment.rb:5:in `<main>' Tasks: TOP => app:template => environment (See full trace by running task with --trace) ### 該当のソースコード development.rb require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp', 'caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise exceptions for disallowed deprecations. config.active_support.disallowed_deprecation = :raise # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true end enviroment.rb # Load the Rails application. require_relative "application" # Initialize the Rails application. Rails.application.initialize!

試したこと

初心者なので色々ネット検索したり噛み砕いたりして検索しましたがよくわかりませんでした。

補足情報(FW/ツールのバージョンなど)

brew -v
Homebrew 3.2.5
Homebrew/homebrew-core (git revision 7d0ba234a1; last commit 2021-07-28)
rbenv -v
rbenv 1.1.2
ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
rails -v
Rails 6.1.4
yarn -v
1.22.10
matsuimasateru@machu ~ % node -v
v16.5.0

このエラーでかなり困ってます
前に進めず何をしたらいいのかわからないのでご教授お願いします

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

一度development.rbの
config.file_watcher = ActiveSupport::EventedFileUpdateCheckerをコメントアウトにして試してみてください

投稿2021/08/02 13:33

J_O

総合スコア143

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2021/08/05 13:00

回答ありがとうございます!! development.rbの config.file_watcher = ActiveSupport::EventedFileUpdateCheckerをコメントアウトしたんですけど /Users/machu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': dlopen(/Users/machu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.7/lib/bootsnap/bootsnap.bundle, 9): no suitable image found. Did find: (LoadError) が出たままです。。
J_O

2021/08/05 23:33

ちなみにgemに'bootsnap', require: falseやconfig/boot.rb に require 'bootsnap/setup'が記述されていますか? もし記述されされているのであればこちらもコメントアウトの上、bundle installを行って、一度試してみてください。
退会済みユーザー

退会済みユーザー

2021/08/06 15:26

二つとも記述されていたのでコメントアウトしました! bundle installしてから動かそうとすると Webpacker configuration file not found /Users/machu/app/bpp/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /Users/machu/app/bpp/config/webpacker.yml (RuntimeError) と出てきます エラー文にあるwebpacker:instalをしようとすると rails webpacker:install rails aborted! Don't know how to build task 'webpacker:install' (See the list of available tasks with `rails --tasks`) Did you mean? webpacker:install webpacker:install:vue webpacker:install:erb webpacker:install:elm webpacker:binstubs /Users/machu/app/bpp/bin/rails:5:in `require' /Users/machu/app/bpp/bin/rails:5:in `<top (required)>' /Users/machu/app/bpp/bin/spring:10:in `block in <top (required)>' /Users/machu/app/bpp/bin/spring:7:in `<top (required)>' (See full trace by running task with --trace) と出てしまいます rails6にはWebpackerが元から入っていると記事で読んだことがあるのですがインストールしなければならないのですか? 勉強不足で質問ばかりすいません
J_O

2021/08/07 14:55

おっしゃるようにwebpackerはデフォでgemによってインストールされていますが、恐らく今回初めのエラーに記載があるようにdevelopment(開発環境)とtest(テスト環境)のgemがinstallされていないので、webpackerもインストールされていないものと思われます。(Gems in the groups 'development' and 'test' were not installed.) まだエラー原因の詳細が掴めていませんが、group :development doとendの間に gem 'listen'を追加してbundle installして試してみてください。(恐らくエラーになると思いますが、、、) あと併せてgemファイルの追記をお願いします。
退会済みユーザー

退会済みユーザー

2021/08/09 13:06

gem 'listen'追加しましたがエラーになりました。 gemfileです source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.0.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.4' # Use mysql as the database for Active Record gem 'mysql2', '~> 0.5' # Use Puma as the app server gem 'puma', '~> 5.0' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 5.0' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb #gem 'bootsnap', '>= 1.4.4', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 4.1.0' # Display performance information such as SQL time and flame graphs for each request in your browser. # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem 'rack-mini-profiler', '~> 2.0' gem 'listen' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 3.26' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] これです!! 毎回お手伝いいただきありがとうございます!!
J_O

2021/08/12 07:07

gemファイルにある、 gem 'rails', '~> 6.1.4'を下記に変更して試してみてください。 gem 'rails', '= 6.1.4'
退会済みユーザー

退会済みユーザー

2021/08/12 11:23

gem 'rails', '= 6.1.4'これに変更しました!! /Users/machu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/psych.rb:581:in `initialize': No such file or directory @ rb_sysopen - /Users/machu/app/bpp/config/webpacker.yml (Errno::ENOENT) これが出ました!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問