Broken install
carlpaten opened this issue · comments
To reproduce:
- From a blank repo/machine, add
jshint
to theGemfile
. bundle exec jshint
Error message:
/Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/configuration.rb:86:in `initialize': No such file or directory - /Users/carl/Google Drive/Documents/W2015/ECSE 428/mcbuddy/config/jshint.yml (Errno::ENOENT)
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/configuration.rb:86:in `open'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/configuration.rb:86:in `read_config_file'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/configuration.rb:90:in `parse_yaml_config'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/configuration.rb:15:in `initialize'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/lint.rb:20:in `new'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/lint.rb:20:in `initialize'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/cli.rb:4:in `new'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/lib/jshint/cli.rb:4:in `run'
from /Library/Ruby/Gems/2.0.0/gems/jshint-1.3.1/bin/jshint:12:in `<top (required)>'
from /usr/bin/jshint:23:in `load'
from /usr/bin/jshint:23:in `<main>'
Based on your error message, it appears that your missing the jshint.yml
configuration file that's documented as part of the installation process.
You can run the following generator to give you this configuration file in your codebase:
bundle exec rake jshint:install_config
I did try that, but this is what happens:
wpa151018:mcbuddy carl$ bundle exec rake jshint:install_config
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
(See full trace by running task with --trace)
wpa151018:mcbuddy carl$ bundle exec rake jshint:install_config --trace
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:684:in `raw_load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:94:in `block in load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:93:in `load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:77:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Hi @LilRed,
It sounds like your missing a Rakefile
from the root of your Rails project, it should contain the following:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
Can you confirm that the project your integrating the JSHint gem with is Rails?
Thanks for the update. I guess the issue is that the Rakefile doesn't get created+updated if it doesn't already exist.
That's correct. When you scaffold a new Rails project it generates a Rakefile for you, along with a bunch of other files / directories e.g.
Gemfile README.rdoc app config db log test vendor
Gemfile.lock Rakefile bin config.ru lib public tmp
So what if I want to use this in a non-Rails project :o
At present I'd hazard a guess that this gem isn't compatible with a non-Rails project. But I don't think it'd take too much work / refactoring to loosen this coupling so that it could be less Rails agnostic.
I've made a separate issue to loosen this dependency based on your feedback, as this is something that I'd also like to see. If your able to chime in on that, with some requirements / thoughts that'd be great.
I added the Rakefile you provided and it worked fine for a non-Rails project.
Hehe happy days! 👍
If your interested in contributing some documentation around how this is achieved in a non Rails project, it'd be very much appreciated :)