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

Expand base dir to avoid exception from Pathname #968

Merged
merged 1 commit into from
Apr 7, 2014

Conversation

bquorning
Copy link
Contributor

I have a .rubocop.yml in my project’s main folder, and a .rubocop.yml in my spec folder. After upgrading from 0.19.1 to 0.20.1, I have this issue when running Rubocop from my spec folder:

~$ cd spec && rubocop -c ./.rubocop.yml
different prefix: "/" and "."
/Users/bquorning/.rubies/ruby-2.1.0/lib/ruby/2.1.0/pathname.rb:500:in `relative_path_from'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/path_util.rb:10:in `relative_path'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/config.rb:91:in `path_relative_to_config'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/config.rb:71:in `file_to_include?'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/target_finder.rb:61:in `block in target_files_in_dir'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/target_finder.rb:57:in `select'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/target_finder.rb:57:in `target_files_in_dir'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/target_finder.rb:25:in `find'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/lib/rubocop/cli.rb:28:in `run'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/bin/rubocop:14:in `block in <top (required)>'
/Users/bquorning/.rubies/ruby-2.1.0/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/Users/bquorning/.gem/ruby/2.1.0/gems/rubocop-0.20.1/bin/rubocop:13:in `<top (required)>'
/Users/bquorning/.gem/ruby/2.1.0/bin/rubocop:23:in `load'
/Users/bquorning/.gem/ruby/2.1.0/bin/rubocop:23:in `<main>'

Always using an expanded path solves the problem.

cc/ @jonas054

@jonas054
Copy link
Collaborator

jonas054 commented Apr 6, 2014

Thanks! I'm sure it's a good correction, but could you also add a spec example (in cli_spec.rb) that fails without your change?

@bquorning
Copy link
Contributor Author

Spec added.

@jonas054
Copy link
Collaborator

jonas054 commented Apr 7, 2014

I'm sorry. I forgot to mention that you should also add an entry in CHANGELOG.md. But the code looks good!

@bquorning
Copy link
Contributor Author

No problem, I’m fine with doing one thing at a time ;-)

I’ve added a line (and myself) to the changelog.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 7, 2014

@bquorning Please, squash the 3 commits into 1.

The bug would appear when using the value of
`Rubocop::ConfigLoader::DOTFILE` as the command line argument for the
`-c` flag.
@bquorning
Copy link
Contributor Author

Done

bbatsov added a commit that referenced this pull request Apr 7, 2014
Expand base dir to avoid exception from Pathname
@bbatsov bbatsov merged commit f8dfa0a into rubocop:master Apr 7, 2014
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 7, 2014

Thanks!

@bquorning bquorning deleted the expand-config-path branch April 7, 2014 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants