Unable to run jshint command
amnesia7 opened this issue · comments
I installed the gem and ran the config command to setup the config yml file.
When I then run bundle exec rake jshint
I get:
rake aborted!
undefined method `[]' for nil:NilClass
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/jshint-1.3.1/lib/jshint/tasks/jshint.rake:9:in `block (2 levels) in <top (required)>'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/bin/ruby_noexec_wrapper:14:in `eval'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => jshint => jshint:all => jshint:lint
(See full trace by running task with --trace)
Any suggestions what's going wrong here?
I've just tried uninstalling it (removing it from the gemfile and running bundle clean --force
to tidy the gems up, which also removed a few others that were lying round).
I then re-installed the gem again by re-adding it to the gemfile and running bundle install
.
However, I'm still getting the same error message.
Here's the full trace for bundle exec rake jshint --trace
if it helps:
** Invoke jshint (first_time)
** Invoke jshint:all (first_time)
** Invoke jshint:lint (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute jshint:lint
rake aborted!
undefined method `[]' for nil:NilClass
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/jshint-1.3.1/lib/jshint/tasks/jshint.rake:9:in `block (2 levels) in <top (required)>'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:228:in `call'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:228:in `block in execute'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:223:in `each'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:223:in `execute'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/amnesia7/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:185:in `each'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:185:in `invoke_prerequisites'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/home/amnesia7/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:185:in `each'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:185:in `invoke_prerequisites'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/home/amnesia7/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/task.rb:152:in `invoke'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:143:in `invoke_task'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:101:in `each'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:101:in `block in top_level'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:110:in `run_with_threads'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:95:in `top_level'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:73:in `block in run'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:160:in `standard_exception_handling'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/lib/rake/application.rb:70:in `run'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/gems/rake-0.9.6/bin/rake:37:in `<top (required)>'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/bin/rake:23:in `load'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/bin/rake:23:in `<main>'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/bin/ruby_noexec_wrapper:14:in `eval'
/home/amnesia7/.rvm/gems/ruby-2.0.0-p481@blog/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => jshint => jshint:all => jshint:lint
I would try updating rake to see if that helped but the dependencies say it isn't necessary and other gems in my gemfile prevent me from going beyond v0.9.6
anyway.
I've just tried temporarily updating rake just to see if it would help and after updating to 10.4.2
the jshint command ran and listed a load of stuff but then after the errors it said:
483 errors
rake aborted!
....then had the same error text as shown in my opening comment above
Any ideas @damian why it could be failing for me?
Updating rake is not an option for me. This quick test was only to check if it was rake that was preventing the jshint command from running successfully.
I'm not sure to be honest. It appears that this line of code is causing your issue. The only thing that I can infer is that args.extras
is not returning an Array. Could I trouble you to do some debugging to find out if args.extras
is an Array? Or perhaps give me some information on your environment so I can potentially try to replicate this issue myself?
Hi @damian
p _
shows <Rake::Task jshint:lint => [environment]>
in the console.
p args
shows {}
in the console.
I tried adding a load of puts in the gem itself to try to figure out where it was going wrong but no joy so I tried creating a brand new app to figure out where it was going wrong:
rails new jshint_test
I forgot this ran a bundle on creation so I edited the gemfile to be:
source 'https://rubygems.org'
gem 'rails', '4.1.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'rake', '~> 0.9.6'
gem 'jshint'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '>= 3.2'
gem 'coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
and then bundled again - to update rails to my version, set rake as my version and add jshint gem.
Since this changed the rails version I ran through the rails update command rake rails:update
(http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#the-rake-task) overwriting each of the files.
I then tried running the bundle exec rake jshint
command for this app and it failed in the same way as for my app.
For this attempt it was using ruby 1.9.3p484 but for my actual app I'm using ruby 2.0.0p481.
I'm running this on ubuntu 12.04 LTS on 32bit.
How do the args
get generated that are passed into the task?
Am I able to check that somehow?
I think it's because of the Rake version your locked to.
These two lines in the JSHint Rake task make use of args.extras
which was only introduced in Rake v10.1.0. Consequently this feature will not be available in the older version of Rake your using(I know this because I've downgraded and received the error that's manifesting above).
I've upgraded to Rake v10.4.2 and it seems to work ok. Can you confirm, that when you upgraded to Rake v10.4.2 that your still receiving the same error as above, or is it different?
Upgraded:
Using rake 10.4.2 (was 0.9.6)
Then ran rake task command:
0 errors
All works fine after updating rake.
Is there anything that can be done to allow for 0.9.6
?
@damian just wondered if you had had chance to have a think about whether it could work for 0.9.6 yet?
Nevermind, I've gone with this one (https://github.com/stereobooster/jshintrb) instead and all seems to be working fine for me.