thisisnic commented on issue #47937:
URL: https://github.com/apache/arrow/issues/47937#issuecomment-3458352956

   I had a bit more of a look into it, that wasn't the actual problem and it 
doesn't solve the issue.  The rubocop hook itself is configured to run on only 
Ruby files, so including the `files` filter or not becomes redundant.
   
   There is still the issue that it tries to install regardless of whether it's 
a Ruby PR or not.
   
   See below for LLM summary of what I tried. 
   
   I'm going to remove the instructions to use pre-commit from the R docs as it 
creates a barrier for new contributors, but otherwise I think no changes needed 
here as none of the alternatives suggested seem like good options.  
   
   I feel this is going to create barriers for new contributors in other 
implementations if they try to use pre-commit.  Maybe we want to update the 
docs to mention that it'll install everything?
   
   CC @AlenkaF  as well.
   
   
   ## claude summary below
   -------------------------------------
   
    After investigating, the proposed fix (files: \.rb$ filter) doesn't 
actually solve the issue. Here's why:
   
     What we found:
     - The files filter in pre-commit only controls which files are checked, 
not whether the environment is installed
     - Pre-commit attempts to install ALL hook environments upfront, regardless 
of file filters
     - The rubocop environment installation requires gem to build the 
rubocop.gemspec file
     - Without Ruby/gem installed, installation fails with "Executable gem not 
found" before it even gets to the file filtering stage
   
     Testing:
     - Uninstalled Ruby completely
     - Tested with and without files: \.rb$ filter
     - Both cases failed with the same error when pre-commit tried to 
initialize environments
     - The error occurs even when committing only non-Ruby files
   
     Why this is problematic:
     - IDE git integration (RStudio, VS Code) runs pre-commit automatically
     - Can't use workarounds like SKIP=rubocop environment variable from an IDE
     - Can't control which pre-commit command the IDE runs
   
     Possible solutions:
     1. Make rubocop a local hook with a wrapper script that checks if Ruby 
exists first
     2. Accept that Ruby needs to be installed as a dev dependency for anyone 
using pre-commit
     3. Use a custom git hook wrapper that sets SKIP automatically
     4. Remove rubocop from pre-commit entirely and run it separately
   
   The fundamental issue is that pre-commit's design installs all environments 
upfront, and there's no way to make an environment optional based on what's 
available on the system.
   


-- 
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]

Reply via email to