native-build-tools icon indicating copy to clipboard operation
native-build-tools copied to clipboard

NativeCompile task cannot pass - "InvalidPathException" is thrown when compiling.

Open partaloski-dev opened this issue 2 years ago • 2 comments

Describe the bug When using the native-build-tools, gradle task :nativeCompile is failing

To Reproduce I cannot link the repository of mine since it's under a contract that I cannot share these files.

Steps to reproduce the behavior: Just try starting a gradle nativeCompile task.

Expected behavior The build should not fail at this point here since it seems to fail because of a "bad path" to the .jar file.

Logs

```
> Task :nativeCompile FAILED
[native-image-plugin] GraalVM Toolchain detection is disabled
[native-image-plugin] GraalVM location read from environment variable: JAVA_HOME
[native-image-plugin] Native Image executable path: C:\Program Files\Java\graalvm-ee-java17-22.3.2\bin\native-image.cmd
9 actionable tasks: 7 executed, 2 up-to-date
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char < > at index 3: C:\ Users\ petar.partaloski\ Documents\ Projects\ ITL 360\ javaApp-AuthorizationFunction\ build\ libs\ authorization-0.0.1-SNAPSHOT-plain.jar
	at [email protected]/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at [email protected]/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at [email protected]/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at [email protected]/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at [email protected]/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
	at [email protected]/java.nio.file.Path.of(Path.java:147)
	at [email protected]/java.nio.file.Paths.get(Paths.java:69)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.ClasspathUtils.stringToClasspath(ClasspathUtils.java:52)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.addCustomImageClasspath(NativeImage.java:1582)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.processClasspathArgs(DefaultOptionHandler.java:417)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.consume(DefaultOptionHandler.java:69)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage$NativeImageArgsProcessor.apply(NativeImage.java:1512)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.consume(DefaultOptionHandler.java:204)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage$NativeImageArgsProcessor.apply(NativeImage.java:1512)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.processNativeImageArgs(NativeImage.java:1770)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.completeImageBuild(NativeImage.java:959)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:1417)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1387)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1374)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeCompile'.
> Process 'command 'C:\Program Files\Java\graalvm-ee-java17-22.3.2\bin\native-image.cmd'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
```

The compile fails when we reach the path of the .jar file with the exception Illegal char < > at index 3: C:\ Users\ where the " " is in fact a NULL object when I take a look at it in console it looks like this: image

System Info:

  • OS: Windows 11 - Version 10.0.22621 Build 22621
  • GraalVM Version Enterprise 22.3.2
  • Java Version 17.0.7
  • Plugin org.graalvm.buildtools.native, version 0.9.21

Additional context I have tried this with multiple GraalVM versions including (22.3.1, 22.3.0), I have also tried combining both of those with other versions of the "native" plugin including (0.9.20, 0.9.18), the issue still persists.

partaloski-dev avatar May 09 '23 08:05 partaloski-dev

@partaloski-dev I've ran across the same issue where "Illegal char at index" was occurring during build testing on Windows. This post here by @kristofdho resolved it: https://github.com/graalvm/native-build-tools/issues/318#issuecomment-1303118358

I'm seeing the same thing on my end, but with the native-build-tools directly (without micronaut layer in between). This is caused by having a space on your path (anywhere, it reports it at index 3 every time). Through the build tools there are no additional spaces in the reported path.

Adding <useArgFile>false</useArgFile> to the plugin config fixes it if your path isn't too long and you don't run into other issues. I don't know if you can configure that through the micronaut plugin, but either way this is something that should be fixed in the native-build-tools.

Lemon-King avatar Sep 11 '23 23:09 Lemon-King

I also have the same problem in version 0.9.26.

tri5m avatar Sep 14 '23 11:09 tri5m