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

Missing grunt-cli for Node.js 0.11.16, 0.12.0 and io.js 1.2.0 #3231

Closed
dancek opened this issue Feb 14, 2015 · 11 comments
Closed

Missing grunt-cli for Node.js 0.11.16, 0.12.0 and io.js 1.2.0 #3231

dancek opened this issue Feb 14, 2015 · 11 comments
Labels

Comments

@dancek
Copy link

dancek commented Feb 14, 2015

Apparently grunt is not available in Node.js 0.12 and io.js environments, as seen eg. in this build: https://travis-ci.org/dancek/grunt-more-css/builds/50741238

sh: 1: grunt: not found

Documentation suggests that grunt-cli is provided for Node.js >= 0.8.

@dancek
Copy link
Author

dancek commented Feb 14, 2015

The same goes for Node.js 0.11.16: https://travis-ci.org/dancek/grunt-more-css/jobs/50738884

@dancek dancek changed the title Missing grunt-cli for Node.js 0.12 and io.js Missing grunt-cli for Node.js 0.11.16, 0.12.0 and io.js 1.2.0 Feb 14, 2015
@BanzaiMan
Copy link
Contributor

The document is a bit inaccurate. The pre-installed versions, iojs-v1.1.0 and 0.11.15, have grunt pre-installed, but these more recent versions are installed on demand by NVM, and as such, does not have grunt.

@ljharb Is there a way to make this easier on users?

@ljharb
Copy link

ljharb commented Feb 14, 2015

@BanzaiMan the only options I can think of are:

  1. pre-prepare the newer versions on the VM with grunt preinstalled
  2. change the VM to nvm install X && npm install -g grunt (but I never use grunt, so I'd prefer not to slow down my tests for it)
  3. symlink $(nvm use iojs-v1.1 && npm root -g)/grunt and …/.bin/grunt etc automatically on nvm install, but this almost certainly will break across node/iojs versions, so I don't recommend it.
  4. if a dev needs X, then they can configure their travis.yml before_install script to install X.

The general community convention is that if a module requires X, X should be in package.json as a dependency/devDependency, and if it's a cli, it should be run via npm run - relying on grunt being globally installed is already making life harder for users, so I'm not sure it's beneficial for travis-ci to be implicitly encouraging it.

@dancek
Copy link
Author

dancek commented Feb 14, 2015

@ljharb I agree that it's best to have as little as possible installed globally. Unfortunately the Grunt plugin convention seems to be to define the test script as grunt test. I'm new to this, but at least that's the way grunt-init gruntplugin suggests and most plugins I've seen do in practice.

My suggestion is to mention in the documentation that Travis CI used to have grunt-cli pre-installed, but it is deprecated and current versions don't have that anymore. Preferably suggest a way to run grunt without a global grunt-cli, or mention the before_install option.

@BanzaiMan
Copy link
Contributor

I've cleared up this point in the update announcement.

Given the options, I am of the opinion that there is no clean way to provide grunt-cli for versions that are not pre-installed on the image.

@ljharb
Copy link

ljharb commented Feb 14, 2015

@dancek Any task begun underneath an npm run command will have node_modules/.bin in the PATH, and thus grunt test will work just fine. As long as grunt is a dependency, and any grunt tasks are initiated somewhere within an npm run-script command, you'll be fine - no globals needed.

@joshk
Copy link
Contributor

joshk commented Feb 15, 2015

I am totally for not pre-installing grunt and instead advise people to use npm run

@dancek
Copy link
Author

dancek commented Feb 15, 2015

@ljharb thanks for clearing that up. I added a dev dependency to grunt-cli and wrote the scripts section in package.json this way:

  "scripts": {
    "grunt-test": "grunt test",
    "test": "npm run grunt-test"
  },

I see no downsides to this approach, so I'm going to suggest it for grunt-init-gruntplugin.

@ljharb
Copy link

ljharb commented Feb 15, 2015

@dancek Great! You could also shorten that to "test": "grunt test" since npm test is shorthand for npm run-script test, but I tend to keep my individual tests separate and then npm run them one by one in test as well :-)

@BanzaiMan
Copy link
Contributor

I've clarified the announcement, and there is no mention of grunt in the language page. There is nothing to do here, right? I'm closing this.

@ErisDS
Copy link

ErisDS commented Apr 22, 2015

We're suddenly running into this in TryGhost/Ghost. Our build matrix looks like:

 - "0.10"
 - "0.12"
 - "iojs-v1.2.0"

Our npm test command is:

"test": "./node_modules/.bin/grunt validate --verbose"

I spoke to @henrikhodne on IRC who pointed me here.

Our full build has been using that matrix for over a month and passing, and then randomly started failing yesterday (during the difficulties). Sometimes node v0.12 runs ok, sometimes iojs-v1.2.0 runs ok and sometimes they both fail. It's seemingly completely random:

I understand if we need to make some changes, but I'd like to understand what's going on and why we are only just affected? This thread mentions an update announcement but there is no link so I'm not sure if there is more info there.

Is this somehow dependent on what exact versions of node are preinstalled on a given VM? Has something only just changed? Or are we running into a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants