-
Notifications
You must be signed in to change notification settings - Fork 22k
Closed
Description
Steps to reproduce
After setting up a new application with Rails main, create a controller in the empty application.
$ ruby bin\rails g controller home welcome
Expected behavior
The generate command should complete successfully without any errors from Rubocop.
$ ruby bin\rails g controller home welcome --force
identical app/controllers/home_controller.rb
route get "home/welcome"
invoke erb
exist app/views/home
identical app/views/home/welcome.html.erb
invoke helper
identical app/helpers/home_helper.rb
Inspecting 2 files
..
Actual behavior
The command completes but ends with an error from Rubocop.
$ ruby bin\rails g controller home welcome
create app/controllers/home_controller.rb
route get "home/welcome"
invoke erb
create app/views/home
create app/views/home/welcome.html.erb
invoke helper
create app/helpers/home_helper.rb
D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/configuration.rb:138:in `system': Exec format error - bin/rubocop -A --fail-level=E app/controllers/home_controller.rb app/helpers/home_helper.rb (Errno::ENOEXEC)
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/configuration.rb:138:in `block in apply_rubocop_autocorrect_after_generate!'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/generators.rb:317:in `block in run_after_generate_callback'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/generators.rb:316:in `each'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/generators.rb:316:in `run_after_generate_callback'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/generators.rb:263:in `invoke'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/commands/generate/generate_command.rb:26:in `perform'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/command/base.rb:178:in `invoke_command'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/command/base.rb:73:in `perform'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/command.rb:71:in `block in invoke'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/command.rb:149:in `with_argv'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/command.rb:69:in `invoke'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-284baa18c2c6/railties/lib/rails/commands.rb:18:in `<main>'
from D:/Ruby33-x64/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
from D:/Ruby33-x64/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
from D:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from bin/rails:4:in `<main>'
System configuration
Rails version: 7.2.0-alpha
remote: https://github.com/rails/rails.git
revision: 284baa18c2c62abec170b61e285aefbd9604f675
branch: main
Ruby version: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x64-mingw-ucrt]
Fix
The issue is fixed by installing binstubs for rubocop (unfortunately, right now, I do not know where the fix would be applied in the Rails codebase).
$ bundle binstubs rubocop --force
If you point me to where it should go, I am happy to open a PR. Else, I'm happy for someone to do this at the correct place. Thanks!
Other Information
Detailed links:
- The setup is basic Rails main for a new application on Windows. However, detailed steps are available here: https://notepad.onghu.com/2024/how-to-use-rails-main-for-development/
- The problem and fix are also detailed here: https://notepad.onghu.com/2024/fix-rails-main-on-windows-rubocop-error/
Metadata
Metadata
Assignees
Labels
No labels