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

require': cannot load such file -- onfgaton fo bocop (LoadError) #1504

Closed
suchisubhra opened this issue Dec 16, 2014 · 3 comments · Fixed by #1511
Closed

require': cannot load such file -- onfgaton fo bocop (LoadError) #1504

suchisubhra opened this issue Dec 16, 2014 · 3 comments · Fixed by #1511

Comments

@suchisubhra
Copy link

I have added .rubocop.yml file in cookbook root dir and started getting this error

  • rubocop
    /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- onfgaton fo bocop (LoadError) from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/config_loader.rb:39:in block in load_file' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/config_loader.rb:39:ineach'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/config_loader.rb:39:in load_file' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/config_loader.rb:93:inconfiguration_from_file'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/config_store.rb:40:in for' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/target_finder.rb:111:inexcluded_dirs'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/target_finder.rb:90:in find_files' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/target_finder.rb:60:intarget_files_in_dir'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/target_finder.rb:31:in find' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/runner.rb:47:infind_target_files'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/runner.rb:18:in run' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/lib/rubocop/cli.rb:24:inrun'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/bin/rubocop:13:in block in <top (required)>' from /opt/chef/embedded/lib/ruby/1.9.1/benchmark.rb:295:inrealtime'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rubocop-0.28.0/bin/rubocop:12:in <top (required)>' from /opt/chef/embedded/bin/rubocop:23:inload'
    from /opt/chef/embedded/bin/rubocop:23:in `'

any help is really appreciated

@bquorning
Copy link
Contributor

“onfgaton fo bocop”? I wonder what is in your .rubocop.yml file – maybe the string “configuration for Rubocop”?

If you're unsure whether your config file is in the right format or not, try removing it and have Rubocop create one for you, using rubocop --auto-gen-config.

@bquorning
Copy link
Contributor

Yes, that’s it! If the configuration file is malformed (e.g. doesn’t define a hash), ConfigLoader#load_file will cause this exception. This is because the String#delete is very different from Hash#delete:

# rubocop-0.28.0/lib/rubocop/config_loader.rb:39
Array(hash.delete('require')).each { |r| require(r) }

{ "require" => %w(one_file another_file) }.delete("require")
#=> ["one_file", "another_file"]

"Configuration for rubocop".delete("require")
#=> "Confgaton fo bocop"

Maybe we should ensure that hash is of the correct type first, e.g. by calling hash.to_h or hash.to_hash? Or Hash(YAML.load(yaml_code)) in line 34?

@jonas054
Copy link
Collaborator

@bquorning Sounds like a good idea to me. Thanks for the explanation!

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 a pull request may close this issue.

3 participants