ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn McAllister <gl...@somanetworks.com>
Subject Re: Environment not being passed to Apply task command (I think) - Win2k
Date Tue, 10 Jul 2001 13:41:33 GMT
"healey, alex" wrote:

> Having some problems with Ant not passing environment to a command line
> in Apply etc. I am running on Win2k and have latex working fine on my
> command prompt so that I get expected operation when I run...
>
> latex D:\Project\doc\design\SomeDoc.tex
>
> Now I try to use apply like this...
>
> <target name="texToDVI" depends="init">
>         <property environment="env"/>
>         <echo message="${env.Path}" />
>         <apply executable="latex" dest=".">
>             <fileset dir="." includes="**/*.tex"
> excludes="**/*.docbook.tex"/>
>             <mapper type="glob" from="*.tex" to="*.dvi"/>
>             <env key="Path" value="${env.Path}"/>
>         </apply>
>     </target>
>
> and I get...
>
> D:\Project\ant\build.xml:458: Execute failed: java.io.IOException:
> CreatePr
> ocess: latex D:\Project\doc\design\SomeDoc.tex error=2
> --- Nested Exception ---
> java.io.IOException: CreateProcess: latex
> D:\Project\doc\design\SomeDoc.tex
>  error=2
>         at java.lang.Win32Process.create(Native Method)

<snip>

The reason you are getting the problem is that by making the executable
"latex", you are *not* using the cmd.exe (or command.exe) shell to launch
the application (which knows about the PATH environment variable), you are
launching the application itself.  So as far as the JVM is concerned, its
going to try an launch your application directly, assuming the system knows
where it is.  Since "latex" is not in one of the (effectively) hard coded
directories the OS knows to look in, it can't create an instance of the
"latex" application.  If you do something like

<apply executable="cmd.exe" depends="init">
  <arg value="-c latex" />
  ... same as before
</apply>

that should get you around the problem.  This way, you are running an
instance of the Windows shell, which does understand the PATH environment
variable, and so should be able to find the latex executable.

You know, we see this issue often enough this should be a FAQ entry...

Glenn McAllister
SOMA Networks, Inc.

Mime
View raw message