Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RuboCop autocorrect for Windows compatibility #51779

Merged

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented May 10, 2024

Motivation / Background

New behaviour was added in #50506 which runs RuboCop after a generator, but the approach fails on Windows.

Detail

As documented in the Rails Guides, when calling a binstub on Windows, we need to prefix it with ruby:
https://guides.rubyonrails.org/getting_started.html#starting-up-the-web-server

Otherwise it will fail with:

D:/Ruby33-x64/lib/ruby/gems/3.3.0/bundler/gems/rails-fc4407eed00e/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-fc4407eed00e/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-fc4407eed00e/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-fc4407eed00e/railties/lib/rails/generators.rb:316:in `each'

I am not a Windows user so I cannot fully test the fix myself, but it was reported here.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

cc @koic

@andyw8
Copy link
Contributor Author

andyw8 commented May 10, 2024

(CI failure seems unrelated)

@byroot byroot force-pushed the andyw8/fix-rubocop-autocorrect-for-windows branch from 7d94c90 to 99924b6 Compare May 11, 2024 23:23
@byroot byroot merged commit 3af5c07 into rails:main May 11, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants