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

Problem in Gemfile-less folder #6939

Closed
zverok opened this issue Apr 16, 2019 · 1 comment · Fixed by #6944
Closed

Problem in Gemfile-less folder #6939

zverok opened this issue Apr 16, 2019 · 1 comment · Fixed by #6944
Labels

Comments

@zverok
Copy link
Contributor

zverok commented Apr 16, 2019

In a small folder with only one file (even empty one), attempt to run rubocop file.rb now leads to:

$ rubocop file.rb
/home/zverok/.rvm/gems/ruby-2.4.2/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:34:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
	from /home/zverok/.rvm/gems/ruby-2.4.2/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:39:in `default_lockfile'
	from /home/zverok/.rvm/gems/ruby-2.4.2/gems/bundler-1.16.1/lib/bundler.rb:318:in `default_lockfile'
	from /home/zverok/.rvm/gems/ruby-2.4.2/gems/rubocop-0.67.2/exe/rubocop:13:in `<top (required)>'
	from /home/zverok/.rvm/gems/ruby-2.4.2/bin/rubocop:23:in `load'
	from /home/zverok/.rvm/gems/ruby-2.4.2/bin/rubocop:23:in `<main>'
	from /home/zverok/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `eval'
	from /home/zverok/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `<main>'

The problem is here: https://github.com/rubocop-hq/rubocop/blob/master/exe/rubocop#L12
Rubocop assumes that if the Bundler constant is defined, it should be able to load a Gemfile. It proves to be generally wrong, at least on my system, Bundler constant gets defined in RubyGem's ruby_executable_hooks executable.

Environment:

$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
$ gem -v
2.6.14
$ bundler -v
Bundler version 1.16.1
$ rubocop -V 
# ooops same error...
$ gem which rubocop
/home/zverok/.rvm/gems/ruby-2.4.2/gems/rubocop-0.67.2/lib/rubocop.rb
@koic koic added the bug label Apr 16, 2019
koic added a commit to koic/rubocop that referenced this issue Apr 17, 2019
Fixes rubocop#6939.
Fixes rubocop#6917.

This warning should not be displayed if users don't use Performance cops
as follows:

- rubocop#6845 (comment)
- rubocop#6919 (comment)

In the future, it will be better to replace it with a mechanism that
displays a warning only when the user need Performance cops.

This PR removes a warning for rubocop-performance when runinng `rubocop`
command.

It just leave a warning just to `gem install rubocop`.
https://github.com/rubocop-hq/rubocop/blob/v0.67.2/rubocop.gemspec#L47
@koic
Copy link
Member

koic commented Apr 17, 2019

Thanks for the feedback. I opened a PR #6944.

bbatsov pushed a commit that referenced this issue Apr 17, 2019
Fixes #6939.
Fixes #6917.

This warning should not be displayed if users don't use Performance cops
as follows:

- #6845 (comment)
- #6919 (comment)

In the future, it will be better to replace it with a mechanism that
displays a warning only when the user need Performance cops.

This PR removes a warning for rubocop-performance when running `rubocop`
command.

It leaves a warning just for `gem install rubocop`.
https://github.com/rubocop-hq/rubocop/blob/v0.67.2/rubocop.gemspec#L47
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