4

I am able to run my Jasmin tests in Karma using the karma command line and maven command line, but when trying to run maven (eg. mvn install) from within STS 3.2.0.RELEASE (Eclipse Juno 4.2) I get the following error:

Failed to execute goal com.kelveden:maven-karma-plugin:1.2:start (default) on project store-webapp: There was an error executing Karma. Cannot run program "karma": error=2, No such file or directory -> [Help 1]

It's as if when Eclipse shells maven, it does not have /usr/local/bin in the path. Is there a way to configure the path eclipse uses when invoking maven?

My environment is:

  • Mac OSX 10.8.4
  • STS 3.2.0.RELEASE (Eclipse Juno 4.2)
  • maven-karma-plugin 1.2
  • karma 0.8.6 (installed globally via npm install -g karma)
  • Node.js 0.10.12 (installed using the OSX package)

Jean

Jean Marois
  • 1,510
  • 11
  • 19
  • It appears in Mac OS X 10.8 (and possible earlier), GUI apps do not get the same path as the terminal. To add `/usr/local/bin` to the global path, you need to edit (and possibly create) `/etc/launchd.conf` to include `setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin` You must edit/create this file with admin privs so use sudo with vi or nano `sudo nano /etc/launchd.conf` **You will need to reboot your Mac before this change can take effect.** This information was found on ServerFault [link](http://serverfault.com/questions/16355/how-to-set-global-path-on-os-x/277034#277034) – Jean Marois Jul 09 '13 at 03:14
  • Nubes are allowed to answer their own questions for 8 hours, so I've answered it in the above comment. – Jean Marois Jul 09 '13 at 03:16

1 Answers1

1

It appears in Mac OS X 10.8 (and possible earlier), GUI apps do not get the same path as the terminal. To add /usr/local/bin to the global path, you need to edit (and possibly create) /etc/launchd.conf to include setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin You must edit/create this file with admin privs so use sudo with vi or nano sudo nano /etc/launchd.conf You will need to reboot your Mac before this change can take effect. This information was found on ServerFault https://serverfault.com/questions/16355/how-to-set-global-path-on-os-x/277034#277034

Community
  • 1
  • 1
Jean Marois
  • 1,510
  • 11
  • 19
  • I already have /etc/launchd.conf file. It has "setenv PATH /usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin". But still running NPM from eclipse give me the same error: "Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/some_user/git/yg-crprate/yg-crp-ui"): error=2, No such file or directory" – Raj Apr 09 '15 at 13:36
  • 1
    @Raj This should work for OSX 10.8 and 10.9. For 10.10 (Yosemite) see [http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite] – Jean Marois Apr 10 '15 at 14:29
  • I have the same issue: Cannot run program "npm" (in directory "/Users/some_user/git/yg-crprate/yg-crp-ui"): error=2, No such file or directory" – Sacky San Jul 20 '17 at 06:00