Fix LoadError on Windows when loading RuboCop from symlinks#12062
Fix LoadError on Windows when loading RuboCop from symlinks#12062bbatsov merged 1 commit intorubocop:masterfrom
LoadError on Windows when loading RuboCop from symlinks#12062Conversation
There is a particular edge case when RuboCop is loaded from a fully symlinked environment. This is the default for Bazel which creates a tree of symlinks for every dependency, mimicking the real file tree structure. In such a setup, RuboCop would fail to load with an error. Resolving the path to an absolute one fixes it. ``` No such file or directory - //?/D:/_bazel/external/bundle/ruby/3.0.0/gems/rubocop-1.36.0/lib/rubocop/../../exe ... //?/D:/_bazel/external/bundle/ruby/3.0.0/gems/rubocop-1.36.0/lib/rubocop/result_cache.rb:208:in `each' ```
Does it work differently on Unix-like OSes? I'm just trying to understand if this is truly Windows-specific. |
It works the same way on Unix-like OSes, but the issue with Windows is that its symlink support is way different - as far as I know there is no real symlinks at all. You can see the I wish I could find a way configure Windows to avoid these problems rather than patching gems. If you are not willing to merge the PR, I can totally understand that. |
|
The patch seems harmless enough and it does solve a real problem. I'll merge it as is, given that adding tests for this would be quite complicated. |
|
Ops, just noticed you forgot to add a changelog entry for this. |
There is a particular edge case when RuboCop is loaded from a fully symlinked environment. This is the default for Bazel which creates a tree of symlinks for every dependency, mimicking the real file tree structure.
In such a setup, RuboCop would fail to load with an error. Resolving the path to an absolute one fixes it.
I am not sure what is the best way to write a test for this, I could use some guidance.
Before submitting the PR make sure the following are checked:
[Fix #issue-number](if the related issue exists).master(if not - rebase it).bundle exec rake default. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.mdif the new code introduces user-observable changes. See changelog entry format for details.