Page 1 of 1

Mavericks External tools classpath issue?

Posted: Thu Oct 24, 2013 5:57 pm
by joewiz
Hi,

Since upgrading to Mac OS X 10.9 (Mavericks), I am unable to fire off scripts via the External Tools toolbar. My scripts, which rely on ant, are set up like this (from my project.xpr file):

Code: Select all

    <xsltCustomEngines>
<field name="outEncoding">
<null/>
</field>
<field name="errEncoding">
<null/>
</field>
<field name="cmd">
<String xml:space="preserve">ant wipe-exist-data</String>
</field>
<field name="description">
<String xml:space="preserve">Completely deletes the contents of the database (eXist-db should not be running)</String>
</field>
<field name="name">
<String xml:space="preserve">wipe-exist-data</String>
</field>
<field name="workingDirectory">
<String xml:space="preserve">${pd}/build</String>
</field>
<field name="keyStroke">
<null/>
</field>
<field name="isBuiltin">
<Boolean xml:space="preserve">false</Boolean>
</field>
</xsltCustomEngines>
When I click on this item in the External Tools menu I get this error:
Could not start: Cannot run program "ant" (in directory "/Users/joe/workspace/paho-trunk/build"): error=2, No such file or directory
Process ended with exit code: -1234567
Ant is no longer bundled with Mac OS X under 10.9, but I installed ant via the homebrew package manager (http://brew.sh/). From the command line, I can run this same ant task successfully:

Code: Select all

$ cd ~/workspace/paho-trunk/build
$ ant wipe-exist-data
But oXygen isn't able to find ant. Do you have any suggestions? Thanks in advance!

Joe

Re: Mavericks External tools classpath issue?

Posted: Thu Oct 24, 2013 7:50 pm
by adrian
Hello,

Did you try restarting Oxygen or your Mac since you've installed the ANT homebrew package?
Changes in the system PATH are not immediately applied to already running applications.

Alternatively, note that Oxygen has its own ANT distribution in Oxygen/tools/ant, so you could refer that one in your external tool: ${oxygenHome}/tools/ant

Regards,
Adrian

Re: Mavericks External tools classpath issue?

Posted: Thu Oct 24, 2013 9:17 pm
by joewiz
Hi Adrian,
adrian wrote:Did you try restarting Oxygen or your Mac since you've installed the ANT homebrew package?
Changes in the system PATH are not immediately applied to already running applications.
Yes, after reading your message, I restarted the Mac, and even then, after reopening Oxygen, ant wasn't recognized.

If I replace the command Oxygen executes with the absolute path to /usr/local/bin/ant (the path where homebrew installed it), the command in Oxygen works:

Code: Select all

    <field name="cmd">
<String>/usr/local/bin/ant prepare-for-development</String>
</field>
Thanks for the tip about referencing Oxygen's built-in copy of Ant. I may need to use that one instead.

That said, I'd like to think that Oxygen should be able to execute commands that work on the command line. Since this worked just fine on Mac OS X 10.8, could it be that something changed with 10.9 that's messing with Oxygen's path?

Re: Mavericks External tools classpath issue?

Posted: Mon Oct 28, 2013 9:07 pm
by joewiz
Some updates on my attempts to fire an ant task from Oxygen's External Tools toolbar under Mavericks 10.9.

I tried Adrian's suggestion to use ${oxygenHome}/tools/ant - but I got an error:
Cannot run program "file:/Applications/oxygen//tools/ant"... error=2, No such file or directory
Seeing the double slash (//tools), I modified the .xpr file's command to use ${oxygenHome}tools/ant - but I got an error again:
Cannot run program "file:/Applications/oxygen/tools/ant"... error=2, No such file or directory
So I looked in oxygen's tools/ant directory and found that the ant binary is deeper: tools/ant/bin/ant. I tested this from the command line but got a permissions error:
$ /Applications/oxygen/tools/ant/bin/ant
-bash: /Applications/oxygen/tools/ant/bin/ant: Permission denied
So I ran chmod +x on this file, and then could execute the ant binary from the command line. But, even when I set my .xpr file to this new location, I get the same error:
Could not start: Cannot run program "file:/Applications/oxygen/tools/ant/bin/ant" (in directory "/Users/joe/workspace/paho-trunk/build"): error=2, No such file or directory
Process ended with exit code: -1234567
Figuring that the file:/ prefix might be the cause of the problem, I replaced the ${oxygenHome} variable with ${oxygenInstallDir}. Once I re-added the / (slash) following this variable, I was finally able to execute ant via my External Tools toolbar.

But note that the execute permission for this version of Ant is not on by default. I think two steps may be needed - the first seems like the longer term fix, and the second a no-brainer but not very helpful:

1. Investigate why 10.9 broke oXygen's ability to run a command like /usr/local/bin, even though it has execute permissions. Is it some kind of sandboxing policy by the OS or a recent Java security setting?

2. Ship oXygen's tools/ant with execute permissions on by default.

Thanks for your consideration. I'm happy to try more troubleshooting steps or report any info that could be helpful.

Re: Mavericks External tools classpath issue?

Posted: Tue Oct 29, 2013 12:25 pm
by adrian
Hi,

Sorry about the confusion with ${oxygenHome} (URL). ${oxygenInstallDir}/tools/ant/bin/ant is the right way to go. You can even work around the lack of executable flag by using:

Code: Select all

/bin/sh "${oxygenInstallDir}/tools/ant/bin/ant"
1. '/usr/local/bin' is not in the system PATH and that's why Oxygen doesn't find the ant located there. I created a new external tool in Oxygen that runs printenv and the PATH was:

Code: Select all

PATH=/usr/bin:/bin:/usr/sbin:/sbin
If I run the same in the Terminal window I get:

Code: Select all

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Note the '/usr/local/bin' at the end which explains why ant works in the Terminal but not in Oxygen.
I've checked in OS X 10.8 and the paths were the same, the difference between 10.8 and 10.9 is that in 10.8 ant was located in '/usr/bin' and in 10.9 it is installed in '/usr/local/bin' (which is not set in the system PATH).
There's a rather extensive topic on StackOverflow about setting environment variables and the PATH variable in particular in OS X:
Setting environment variables in OS X?

2. I've submitted an issue to set the executable flag for the ant script bundled with Oxygen.

Regards,
Adrian

Re: Mavericks External tools classpath issue?

Posted: Thu Oct 31, 2013 7:08 am
by joewiz
Dear Adrian,

Your suggestion to prepend the command with 'sh' worked perfectly. Thanks so much for providing not only great oXygen support but also expert support of the host operating system! Relying on oXygen's bundled Ant app really simplifies the task of setting up new systems for my team, particularly now that Macs running Mavericks no longer can count on having Ant.

Many thanks, as always,
Joe