You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "healey, alex" <al...@midas-kapiti.com> on 2001/07/03 11:41:28 UTC

Environment not being passed to Apply task command (I think) - Wi n2k

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)
        at java.lang.Win32Process.<init>(Win32Process.java:66)
        at java.lang.Runtime.execInternal(Native Method)
        at java.lang.Runtime.exec(Runtime.java:551)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:509)
        at
org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:329)
        at
org.apache.tools.ant.taskdefs.ExecuteOn.runExec(ExecuteOn.java:167)
        at
org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:162)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.Project.executeTargets(Project.java:510)
        at org.apache.tools.ant.Main.runBuild(Main.java:421)
        at org.apache.tools.ant.Main.main(Main.java:149)

Now if I instead replace latex with the full path to latex I am fine. If
I remove the env element I also get the same result.

Has anyone seen this problem??

Cheers

Alex

Re: Environment not being passed to Apply task command (I think) - Win2k

Posted by Bernd Gruendling <gr...@acm.org>.
Alex,

did you solve this problem? I get exactly the same error when trying 
to run a batch file with <exec>. The batch file is fine, of course.

Bern.d


>
>
>and I get...
>
>D:\Project\ant\build.xml:458: Execute failed: java.io.IOException:
>CreateProcess: 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)
>        at java.lang.Win32Process.<init>(Win32Process.java:66)
  ...

_______________________________________________________________________
Bernd Gruendling                            Custom Software Development
Systemberatung Softwaredesign                    for Mac OS and Windows

Wendenstrasse 16                                Phone: +49 5363 97676-0
38448 Wolfsburg, Germany                    Facsimile: +49 5363 97676-9

Re: Environment not being passed to Apply task command (I think) - Win2k

Posted by Glenn McAllister <gl...@somanetworks.com>.
"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.