Rubocop: Rubocop failure if no `Gemfile` or `.bundle` dir

Created on 2 Dec 2020  路  6Comments  路  Source: rubocop-hq/rubocop

Actual behavior

Seems rubocop trying to analyze Gemfile and .bundle dir by default and if there is no such file\dir - there is failure
I understand that is not common behavior for ruby script to not to have Gemfile, but I dont think this failure is looking good

Steps to reproduce the problem

  1. mkdir /tmp/rubocop-bug
  2. cd /tmp/rubocop-bug
  3. touch test.rb
  4. rubocop test.rb

Result is:

rubocop test.rb
Inspecting 1 file
W

Offenses:

test.rb:1:1: W: Lint/EmptyFile: Empty file detected.

1 file inspected, 1 offense detected
Could not locate Gemfile or .bundle/ directory
/usr/share/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler.rb:281:in `rescue in root'
/usr/share/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler.rb:277:in `root'
/usr/share/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler.rb:178:in `load'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:57:in `dependent_gems'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `block in extensions'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `select'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `extensions'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:15:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli/command.rb:11:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli.rb:65:in `run_command'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli.rb:77:in `suggest_extensions'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `block in execute_runners'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `tap'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `execute_runners'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/lib/rubocop/cli.rb:41:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/exe/rubocop:13:in `block in <top (required)>'
/usr/share/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.5.0/exe/rubocop:12:in `<top (required)>'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/rubocop:23:in `load'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/rubocop:23:in `<main>'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:24:in `eval'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:24:in `<main>'

RuboCop version

$ [bundle exec] rubocop -V
1.5.0 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.7.2 x86_64-linux)
bug

All 6 comments

@dvandersluis Guess you know what to do. :-)

On it.

@bbatsov this is a duplicate of #9145.

@dvandersluis I think it's better to change name of #9145, I searched before posting this bug, but JRuby in #9145 title make me ignore it

@ShockwaveNN I agree, but don't have access to change it 馃槄. In any case #9149 will fix both!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mlammers picture mlammers  路  3Comments

millisami picture millisami  路  3Comments

Aqualon picture Aqualon  路  3Comments

Ana06 picture Ana06  路  3Comments

bbatsov picture bbatsov  路  3Comments