[Rails]No such file or directoryのエラーメッセージ

に公開

今回のエラー

rails s
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.18.4/lib/bootsnap/compile_cache/iseq.rb:64:in fetch': No such file or directory - bs_fetch:open_current_file:open: C:/Users/xxx/Desktop/学習用/calendar-sample/config/application.rb (Errno::ENOENT)
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.18.4/lib/bootsnap/compile_cache/iseq.rb:64:in fetch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.18.4/lib/bootsnap/compile_cache/iseq.rb:89:in load_iseq'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require'       
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require'       
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.10/lib/active_support/dependencies.rb:332:in block in require'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.10/lib/active_support/dependencies.rb:299:in load_dependency'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.10/lib/active_support/dependencies.rb:332:in require'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.7.10/lib/rails/commands/server/server_command.rb:138:in block in perform'       
        from <internal:kernel>:90:in tap'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.7.10/lib/rails/commands/server/server_command.rb:135:in perform'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/command.rb:28:in run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in invoke_command'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor.rb:538:in dispatch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.7.10/lib/rails/command/base.rb:69:in perform'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.7.10/lib/rails/command.rb:48:in invoke'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.7.10/lib/rails/commands.rb:18:in <main>'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require'       
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require'       
        from bin/rails:5:in <main>'

config/application.rb があるのに、見つからないというエラーが出る。

rails db:migrate                                                                 
rails aborted!
Errno::ENOENT: No such file or directory - bs_fetch:open_current_file:open: C:/Users/xxx/Desktop/学習用/calendar-sample/Rakefile
bin/rails:5:in <main>'
(See full trace by running task with --trace)

上記も Rakefile があるのに見つからないというエラーが出てる。

解決策

今回は初歩的なミスでした。
Rails・Rubyは、日本語フォルダを適切に処理できないため、 学習用 のような 日本語を含むパスが問題を引き起こすことがある。

C:/Users/.../Desktop/学習用/sample_app2/config/application.rb

これを「learning」のような英語のフォルダ名にしたところ、問題なく処理できるようになりました。

Discussion