Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:45:28+00:00 2026-06-15T20:45:28+00:00

tl;dr: Groovy cannot find a program ( phantomjs , which is on my $PATH

  • 0

tl;dr: Groovy cannot find a program (phantomjs, which is on my $PATH) when I attempt to execute the shell command from a class — it’s otherwise finds it just fine from the Groovy Console or from a Grails CLI script. What gives?

We have a Grails script to execute JavaScript unit tests in PhantomJS (“the headless WebKit”). When these tests are executed in a stand-alone script (call it grails test-js) things work just fine. The relevant line from the Grails/Gant script was:

// where 'jsTests' is a List with the paths to each test
def failures = 0
jsTests.each {
  Process p = "phantomjs lib/phantom-jasmine/lib/run_jasmine_test.coffee file://${it}".execute()
  failures += p.exitValue()
}

But since we want this to run as part of the usual grails test-app cycle, we created an implementation of org.codehaus.groovy.grails.test.GrailsTestType. When we get to the part in that implementation where we need to execute the tests, that same code (as above) doesn’t work, and Groovy/Grails complains that:

java.io.IOException: Cannot run program "phantomjs": error=2, No such file or directory

My first thought was that phantomjs was not on my $PATH — but I know that it is, and again: it worked when run from the Grails/Gant script. So I tried it in the Groovy Console, and it works OK from there.

Now, if I switch from phantomjs to /absolute/path/to/phantomjs, then it works fine. But hard-coding an absolute filesystem path into the class cannot be the solution.

So: why isn’t Groovy finding phantomjs under those circumstances?

Update: I suspect that this might have something to do with my IDE (IntelliJ Idea), as this error doesn’t appear to be happening when running this from the command line.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:45:30+00:00Added an answer on June 15, 2026 at 8:45 pm

    As it turns out, this had everything to do with trying to run the tests from within my IDE (IntelliJ IDEA) and, more specifically, trying to do this on an OS X machine.

    The solution was to add phantomjs to my PATH using launchd.conf. I…

    1. created /etc/launchd.conf

    2. added the following line to it: (note: I installed PhantomJS with Homebrew)

      setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

    3. restarted my machine so that the new launchd config would take effect.

    4. went back into my IDE and re-ran the tests.

    And all the tests ran successfully.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My java/groovy program receives table names and table fields from the user input, it
In Groovy, how do I extract a new list from the following: def people
I am executing groovy script in java: final GroovyClassLoader classLoader = new GroovyClassLoader(); Class
I'm working in Groovy 1.8.6, running on JDK 1.6.0u33. When my program is starting
I am using Groovy Sql to fetch results. This is the output from my
I tried to compile the groovy quickstart example which comes with gradle (in samples/groovy/quickstart
Somehow I cannot find and answer to this in griffon documentation nor googling... I
I am new to groovy and I cannot understand, if it is possible to
I want to use the @Mixin annotation in Groovy which does exactly what I
Grails have cofig for spring bean called resources.groovy . And as i understand from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.