I have the following lines in my .sh file
#! /usr/bin/env /Users/myuser/Development/tools/groovy
println "this is a test"
env: /Users/myuser/tools/groovy: Permission denied
when I run the command /usr/bin/env groovy I don’t get any errors. Any clues why it would be happening on an OS X ?
The purpose of the
#!/usr/bin/envtrick is to avoid having to specify the full path to the interpeter. See this question (and my answer) for more information. Since you’re specifying the full absolute path anyway, you might as well use:As for why this isn’t working, most likely you have a
groovycommand somewhere else in your$PATH, and/usr/bin/env groovyis invoking that other copy.This:
will tell you which
groovyexecutable is in your$PATH. And this:should tell you why you’re getting the “Permission denied” error; most likely that file is not executable.
Another possibility: some systems limit the length of a
#!line. I don’t know whether OSX does so. If it does, the path to yourgroovycommand might be truncated. If this is the problem, you might consider moving or copying thegroovycommand to a directory with a shorter absolute path.