Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution of Windows executables broken in 1.5.0 #42

Closed
fjakop opened this issue May 18, 2016 · 15 comments
Milestone

Comments

@fjakop
Copy link
Contributor

@fjakop fjakop commented May 18, 2016

I'm using exec-maven-plugin on Windows to run npm install in a JS project.

<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
    <execution>
        <id>npm install</id>
        <phase>generate-resources</phase>
        <goals>
            <goal>exec</goal>
        </goals>
        <configuration>
            <executable>npm</executable>
            <commandlineArgs>install --registry ${npm.registry}</commandlineArgs>
        </configuration>
    </execution>
</executions>

which works fine with 1.4.0 but switching to 1.5.0 results in

[INFO] --- exec-maven-plugin:1.5.0:exec (npm install) @ util ---
[ERROR] Command execution failed.
java.io.IOException: Cannot run program "C:\Program Files\nodejs\npm" (in directory "D:\Workspaces\git-repositories\myproject"): CreateProcess error=193, %1 ist keine zulässige Win32-Anwendung
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at java.lang.Runtime.exec(Runtime.java:620)
        at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:61)
        at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:279)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:336)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
        at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
        at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
        at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.io.IOException: CreateProcess error=193, %1 ist keine zulässige Win32-Anwendung
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
        at java.lang.ProcessImpl.start(ProcessImpl.java:137)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 30 more
@khmarbaise

This comment has been minimized.

Copy link
Member

@khmarbaise khmarbaise commented May 22, 2016

Are you running on win32 based system (Windows XP or 32 Bit version of Windows 7 ?)

@fjakop

This comment has been minimized.

Copy link
Contributor Author

@fjakop fjakop commented May 23, 2016

My environment is

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
Maven home: D:\Programme\Java\apache-maven-3.3.3
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: D:\Programme\Java\java-8.0.40-win64-jdk\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

I'm running maven from cmd prompt and of course npm install from the same cmd works fine.

@khmarbaise

This comment has been minimized.

Copy link
Member

@khmarbaise khmarbaise commented May 27, 2016

Have you seen the error message:

CreateProcess error=193, %1 ist keine zulässige Win32-Anwendung
@fjakop

This comment has been minimized.

Copy link
Contributor Author

@fjakop fjakop commented May 27, 2016

Yes I did, but calling the same from cmd promt works well and with version 1.5.0 also.

@khmarbaise

This comment has been minimized.

Copy link
Member

@khmarbaise khmarbaise commented May 27, 2016

So with version 1.5.0 it works without any issue? have you tried to add the extension like (.exe ?)

@fjakop

This comment has been minimized.

Copy link
Contributor Author

@fjakop fjakop commented May 30, 2016

Sorry typo, with 1.4.0 all is good, just switching version to 1.5.0 makes things break.

@gabor-farkas

This comment has been minimized.

Copy link

@gabor-farkas gabor-farkas commented Jun 6, 2016

Changing "npm" to "npm.cmd" solved the issue for me

@fjakop

This comment has been minimized.

Copy link
Contributor Author

@fjakop fjakop commented Jun 6, 2016

We use the same POM in Windows and Linux, if I changed this, it would not run under Linux anymore.

@1inuxoid

This comment has been minimized.

Copy link

@1inuxoid 1inuxoid commented Jun 6, 2016

I guess the easiest way is to remove npm file (shell script) on Windows, so that it will find npm.cmd.
Makes no sense to have a Windows-specific command line in pom.xml.

@fjakop

This comment has been minimized.

Copy link
Contributor Author

@fjakop fjakop commented Jun 6, 2016

That may be, but it does not clarify, why it worked in 1.4.0...

@gabor-farkas

This comment has been minimized.

Copy link

@gabor-farkas gabor-farkas commented Jun 6, 2016

@fjakop true, I forgot about that, I'll also need this to run on jenkins and peer developers machines.

@mkarg

This comment has been minimized.

Copy link
Contributor

@mkarg mkarg commented Jun 7, 2016

The proposed fix works only on Windows, but will break Linux as it enforces the existence of file extensions, and the existence of the variable PATHEXT. Please correct it: Don't remove the top fast-success case, but make it conditional for non-Windows instead.

fjakop pushed a commit to arxes-tolina/exec-maven-plugin that referenced this issue Jun 8, 2016
khmarbaise added a commit that referenced this issue Jun 12, 2016
fixed #42, Execution of Windows executables broken in 1.5.0
@hohwille

This comment has been minimized.

Copy link
Member

@hohwille hohwille commented Mar 6, 2017

Could you set a milestone (1.6.0?) or label so people can understand why this is closed?

@Prophet32j

This comment has been minimized.

Copy link

@Prophet32j Prophet32j commented Mar 6, 2017

when is 1.6.0 getting added to Maven central?

@khmarbaise khmarbaise added this to the 1.6.0 milestone Mar 6, 2017
@amwebexpert

This comment has been minimized.

Copy link

@amwebexpert amwebexpert commented May 9, 2017

See this which solve the problem through profiles: http://stackoverflow.com/a/39407412/704681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.