gruntjs / grunt-cli

Grunt's command line interface.
http://gruntjs.com/
MIT License
706 stars 248 forks source link

grunt --gruntfile some/path/Gruntfile.js cannot find local grunt since grunt-cli 1.0.0 #101

Closed EtienneMiret closed 8 years ago

EtienneMiret commented 8 years ago

Since the release of grunt-cli 1.0.0, the command grunt --gruntfile some/path/Gruntfile.js issues the following error message :

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to your project. For more information about installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started

Before that release, the same command would work fine.

I have my package.json and my node_modules inside the directory some/path, next to Gruntfile.js.

Using :

vladikoff commented 8 years ago

Thanks for the report!

vladikoff commented 8 years ago

What OS are you on?

I cannot reproduce this issue, i made a test repo: https://github.com/vladikoff/issue-grunt-cli-101

Running grunt --gruntfile some/Gruntfile.js gives me

Running "jshint:all" (jshint) task
ERROR: Can't find config file: .jshintrc

So it can find everything. Let me know!

vladikoff commented 8 years ago

@shama thoughts?

EtienneMiret commented 8 years ago

Hello @vladikoff.

I'm having the issue with Travis-ci (can't link to a build though, because it is private) and with the release of Ubuntu you get with docker's digitallyseamless/nodejs-bower-grunt:latest.

vladikoff commented 8 years ago

@EtienneMiret the dockerfile does nothing special here: https://hub.docker.com/r/digitallyseamless/nodejs-bower-grunt/~/dockerfile/

Could you try my test repo above and see if it is the same setup as your private project?

EtienneMiret commented 8 years ago

I can reproduce the issue with your test repo:

$ git clone https://github.com/vladikoff/issue-grunt-cli-101.git
$ docker pull digitallyseamless/nodejs-bower-grunt:latest
$ docker run -it -v /home/etienne/workspace/issue-grunt-cli-101:/data digitallyseamless/nodejs-bower-grunt:latest
# npm --prefix some install
# ls some/
Gruntfile.js  etc  node_modules  package.json
# grunt --gruntfile some/Gruntfile.js 
grunt-cli: The grunt command line interface (v1.0.0)

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

http://gruntjs.com/getting-started
# cd some
# grunt 
Running "jshint:all" (jshint) task
ERROR: Can't find config file: .jshintrc
vladikoff commented 8 years ago

I can reproduce the issue with your test repo:

Not true, see the output it actually loads the jshint task. Running "jshint:all" (jshint) task. By the time it throws the Can't find config file: .jshintrc everything is loaded.

vladikoff commented 8 years ago

Oh wait nevermind

vladikoff commented 8 years ago

Okay I'm checking on my Ubuntu 14 now...

EtienneMiret commented 8 years ago

Thanks. I reproduced it on Travis, if that's of any help to you : https://travis-ci.org/EtienneMiret/issue-grunt-cli-101/builds/117728404.

vladikoff commented 8 years ago

@EtienneMiret Ok I think I have it reproducible on Ubuntu 14 locally. thanks for testing it out...

vladikoff commented 8 years ago

Ok the issue is the nopt update

vladikoff commented 8 years ago
New:
{ gruntfile: true,
  argv: 
   { remain: [ 'some/Gruntfile.js' ],
     cooked: [ '--gruntfile', 'some/Gruntfile.js' ],
     original: [ '--gruntfile', 'some/Gruntfile.js' ] } }

Old:
{ gruntfile: 'some/Gruntfile.js',
  argv: 
   { remain: [],
     cooked: [ '--gruntfile', 'some/Gruntfile.js' ],
     original: [ '--gruntfile', 'some/Gruntfile.js' ],
     toString: [Function] } }
vladikoff commented 8 years ago

@EtienneMiret your build should be fixed now via: https://github.com/gruntjs/grunt-cli/commit/190d90c3f310b384834391bc53457c964bba9587

EtienneMiret commented 8 years ago

Indeed, it is. Thanks a lot.

shama commented 8 years ago

This behavior is expected with grunt@1.0.0. See the release notes regarding nopt: http://gruntjs.com/blog/2016-02-11-grunt-1.0.0-rc1-released#api-changes

The new syntax should be grunt --gruntfile=some/path/Gruntfile.js.

EtienneMiret commented 8 years ago

Oh, OK. Sorry about that. I read CHANGELOG.md before submitting this issue, maybe you want to put a link to gruntjs.com there.

shama commented 8 years ago

@EtienneMiret That is a good idea. We've got this specific change now listed in the changelog and will try to make this change more prominent in the upcoming release notes for grunt@1.0.0. Thanks!