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

Rubocop fails with File name too long when finding target files #9593

Closed
koppen opened this issue Mar 11, 2021 · 2 comments · Fixed by #9594
Closed

Rubocop fails with File name too long when finding target files #9593

koppen opened this issue Mar 11, 2021 · 2 comments · Fixed by #9594
Labels

Comments

@koppen
Copy link

koppen commented Mar 11, 2021

In one of our projects, we've started seeing the following error when running Rubocop:

File name too long - /Users/jakob/Projects/Customer/project//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

The error is followed by a huge stacktrace that seems to indicate some kind of recursion not stopping correctly, see full output below.

Steps to reproduce

Unfortunately I cannot provide a reproducible project (closed source, proprietary etc etc), but all I have to do to reproduce the problem is run:

$ rubocop --force-default-config --list-target-files

Expected behavior

I would expect Rubocop to output a list of the files it's about to process. Curiously, it is only this folder that seems to result in that behavior. If I cd app fx and rerun rubocop --force-default-config --list-target-files it works as expected.

Actual behavior

$ rubocop --force-default-config --list-target-files --debug                                                                                         Default configuration from /Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/config/default.yml
File name too long - /Users/jakob/Projects/Customer/project//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:99:in `glob'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:99:in `wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `block in wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `each'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `flat_map'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `block in wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `each'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `flat_map'
... cut 3868 similar lines...
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `block in wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `each'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `flat_map'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:89:in `find_files'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:32:in `find'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/runner.rb:77:in `find_target_files'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/runner.rb:42:in `run'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli/command.rb:11:in `run'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli/environment.rb:18:in `run'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli.rb:65:in `run_command'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/cli.rb:41:in `run'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/exe/rubocop:13:in `block in <top (required)>'
/Users/jakob/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/exe/rubocop:12:in `<top (required)>'
/Users/jakob/.rvm/gems/ruby-2.7.2/bin/rubocop:23:in `load'
/Users/jakob/.rvm/gems/ruby-2.7.2/bin/rubocop:23:in `<main>'
/Users/jakob/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `eval'
/Users/jakob/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `<main>'
Finished in 14.88650400005281 seconds

RuboCop version

$ rubocop -V
1.11.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-darwin19)
  - rubocop-performance 1.10.1
@koppen
Copy link
Author

koppen commented Mar 11, 2021

Oho, I've managed to reproduce this, full steps below:

$ mkdir sample

$ cd sample

$ rubocop --list-target-files --debug
For /Users/jakob/sample: Default configuration from /Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/config/default.yml
Finished in 0.07365999999456108 seconds

$ mkdir {}

$ rubocop --list-target-files --debug
For /Users/jakob/sample: Default configuration from /Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/config/default.yml
File name too long - /Users/jakob/sample/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:99:in `glob'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:99:in `wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `block in wanted_dir_patterns'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `each'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `flat_map'
/Users/jakob/.rvm/gems/ruby-2.7.2/gems/rubocop-1.11.0/lib/rubocop/target_finder.rb:103:in `wanted_dir_patterns'
... etc etc...

It seems the presence of a directory entry called {} triggers the above behavior. Remove that directory again fixes the issue.

Why I had that directory entry, I don't know - probably something I fat fingered at some point. Wether or not this is a bug in Rubocop, I'll let someone else be the judge of. Was I surprised by this behavior; very much so.

Do you want me to merge these extra details into the main issue description?

@koic koic added the bug label Mar 12, 2021
koic added a commit to koic/rubocop that referenced this issue Mar 12, 2021
…`{}`

Fixes rubocop#9593.

This PR fixes the following error when processing a directory is named `{}`.

```console
% mkdir {}
% rubocop
(snip)

File name too long - /tmp//////////////////////////////////////////////...
```
@koic
Copy link
Member

koic commented Mar 12, 2021

Thank you for the feedback and investigation. That extra details comment does not have to be merged. I have reproduced this issue and opened #9594.

bbatsov pushed a commit that referenced this issue Mar 12, 2021
Fixes #9593.

This PR fixes the following error when processing a directory is named `{}`.

```console
% mkdir {}
% rubocop
(snip)

File name too long - /tmp//////////////////////////////////////////////...
```
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 a pull request may close this issue.

2 participants