thisisnic opened a new issue, #47937:
URL: https://github.com/apache/arrow/issues/47937
### Describe the bug, including details regarding any error messages,
version, and platform.
The below description and proposed solution was generated by claude when I
ran into this issue, so while I'm happy to make the change myself, please can
someone verify this makes sense to do?
__________________________
### Describe the bug
The rubocop pre-commit hook attempts to install its environment even when
committing changes that don't touch any Ruby files. This causes errors for
developers who don't have Ruby installed, even when they're only working on R,
Python, or other components.
**Current behavior:**
When committing changes to non-Ruby files (e.g., R package files),
pre-commit tries to install the rubocop environment and fails if Ruby is not
installed:
[INFO] Installing environment for https://github.com/rubocop/rubocop.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('gem',
'build', 'rubocop.gemspec')
return code: 1
stdout:
Executable gem not found
**Root cause:**
In `.pre-commit-config.yaml`, the rubocop hook (lines 247-258) has an
`exclude` filter but is missing a `files` filter:
```yaml
- repo: https://github.com/rubocop/rubocop
rev: "v1.71.0"
hooks:
- id: rubocop
name: Ruby Format
alias: ruby
args:
- "--autocorrect"
exclude: >-
(
?^dev/tasks/homebrew-formulae/.*\.rb$|
)
```
Without a files filter, pre-commit attempts to set up the hook environment
for all commits, regardless of which files are being modified.
Proposed fix:
Add a files filter to only activate rubocop for Ruby files:
```
- repo: https://github.com/rubocop/rubocop
rev: "v1.71.0"
hooks:
- id: rubocop
files: \.rb$ # <-- Add this line
name: Ruby Format
alias: ruby
args:
- "--autocorrect"
exclude: >-
(
?^dev/tasks/homebrew-formulae/.*\.rb$|
)
```
This pattern is already used correctly in other hooks in the same config
file.
Expected behavior:
The rubocop hook should only attempt to install/run when Ruby files are
being committed.
### Component(s)
Developer Tools
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]