0

Using OSX Maveriks, iTerminal, zsh.

Problem: Grunt runs only the default task regardless of the task you specify. Problem: It only happens in 1 computer.

What can be the reason for grunt not to run but the default task. I've been working with Grunt for a long time now and we use it at the company I work at. Everything has been working perfectly smooth except for 1 single coworker that when he runs grunt myTask is like if he were running just grunt, even if I run a made up task like grunt myNotExistentTask it ignores it and again looks like it runs grunt.

I did check for stupid errors:

  1. Checked that I'm accessing the same project folder (multiple times).
  2. I deleted the default task to see if it complained and it does.
  3. I checked that the Gruntfile was not throwing errors. Then I forced to throw errors to see if it would complain, and it does.
  4. Runned npm install.
  5. Check both bashrc and zshrc for a grunt command or something.
  6. Obviously grunt is accessible.
  7. Runned it in the default terminal and in iTerm.
  8. "Have you try to turn it on and off?" Yes I did restar the laptop.
  9. I tried with multiple coworkers laptops and it only happens in the one laptop.

I did not have time to (but I will check for these):

  1. test creating a simple Gruntfile somewhere else in his laptop, but I have a weird feeling that it would behave the same way.
  2. reinstall grunt. Would that help?
  3. grunt --version or others for that matter, I assumed that it has the specified version in the package.json.

we are using:

"grunt-cli": "^0.1.13",
"grunt": "^0.4.4"

The code is not causing the issue here because every computer runs it but one. I can't show the actual code but I can give you the boilerplate just in case there is some mysterious thing I don't know about:

module.exports = function(grunt) {

  grunt.initConfig({

    pkg : grunt.file.readJSON("package.json"),

    someTask : {
      options : {

      },
      target1 : {

      }
    }
  });

  grunt.loadNpmTasks("dependency1");
  grunt.loadNpmTasks("dependency2");
  grunt.loadNpmTasks("etc");

  grunt.registerTask("default", function () {
    // creates a server with one of the dependencies
  });

  grunt.registerTask("w", function () {
    // creates a watch with one of the dependencies
  });

};

There is a reason behind why we are not simply doing something like grunt.registerTask("default", [".."]). Basically, our projects are too big and we need to change settings for each task to increase performance (e.g. not to watch too many files, etc).

I googled this different ways and couldn't find anything about this happening before. Any ideas are welcomed.

Edit

I forgot to mention that he has been working with the project for a while, we just recently noticed because he never needed to use any other task but the default task until a few days ago when he needed to use a different task, in summary, we don't know when or why it started.

pgarciacamou
  • 1,602
  • 22
  • 40
  • Hi camou, I've the same environment but I never been in trouble with this kind of issue. I'd like following the thread to find out what could be the problem. A stupid question: all modules in your project are installed with root permission (when needed)? – Pierfrancesco Sep 26 '15 at 17:02
  • What tasks are listed when you run `grunt --help`? – GarlicFries Sep 26 '15 at 17:02
  • and what is the result of running `which grunt` on his machine? – Xavier Priour Sep 28 '15 at 07:00
  • Ok, so we manage to find what it was thanks to you @XavierPriour. We run `type -a grunt` and it turned out to have 2 paths for grunt. I'm going to add it as the answer. – pgarciacamou Sep 28 '15 at 17:33

1 Answers1

0

After:

  1. Deleting and cloning the repo.
  2. Deleting npm_modules.
  3. Reinstalling everything.
  4. Creating an isolated project to test this issue.

and failing, we checked for the paths to grunt thanks to a comment by @XavierPriour

Using zsh with iTerm:

➜  folder git:(branch) which grunt
/usr/local/bin/grunt
➜  folder git:(branch) type -a grunt
grunt is /usr/local/bin/grunt
grunt is /usr/bin/grunt

We deleted the extra grunt binary:

➜  folder git:(branch) cd /usr/bin
➜  bin sudo -rm grunt

And everything started working correctly. I assume the issue is he installed grunt globally instead of just grunt-cli, although I'm not sure.

The most popular answer to this question shows the dos and don'ts of how to install grunt.

Community
  • 1
  • 1
pgarciacamou
  • 1,602
  • 22
  • 40