Quarkus: Native compilation doesn't like space in project directory

Created on 25 Mar 2019  路  5Comments  路  Source: quarkusio/quarkus

When creating a project directory with a space in it, native compilation fails, see steps to reproduce below:

mkdir "dir with space"
cd dir with space/
mvn io.quarkus:quarkus-maven-plugin:0.12.0:create
-DprojectGroupId=quarkus.io
-DprojectArtifactId=space-quickstart
-DprojectVersion=1.0-SNAPSHOT
-DclassName="io.quarkus.SpaceResource"
mvn compile quarkus:dev
mvn package -Pnative

The following fixes the issue:

mv dir with space/ dir_with_space/

kinbug triagout-of-date

Most helpful comment

Again it's going to be wrong URI handling somewhere.

Here's the rules for class paths:

  • A MANIFEST.MF Class-Path is a list of relative URIs. A relative URI is not a relative directory, it's a URI without a scheme (see the RFC).

    • Additional rule for Windows: Absolute paths of the form C:\foo\bar.jar must have a leading slash when included in a Class-Path, like this: /C:/foo/bar. This happens by default when you use URI#getRawPath as described below. Note that when specifying paths in a CLASSPATH or -classpath, you must not use the leading / before the drive letter!

  • Since it's a space-separated list, the "raw" URI must be used (see the JavaDoc for URI.toAsciiString() as this will URI-encode and UTF-8 encode the whole URI).
  • The JDK forbids usage of URIs that are not in the file scheme. Some JDKs don't allow URIs with any scheme including file. Make sure the URI is relative before encoding it. I think that simply using the raw path will just about always suffice.
  • When emitting URIs, use Path.toUri(). If you're just pulling the raw path, no further conversion is necessary.
  • When decoding URIs back to Path, use Paths.get(URI). Nice and easy.
  • When you need a File, use Path.toFile().

If you are not adhering to these rules, please include copious documentation explaining your rationale!

I'll update all related issues to reference this comment.

All 5 comments

This seems related to #1402/#1607/#1438/#1030/etc.

The first error is Error: Class initialization failed: io.quarkus.undertow.runtime.graal.URLResourceSubstitution$ResourceInfo
Caused by: java.io.FileNotFoundException: /Users/rsvoboda/tmp/dir%20with%20space/target/lib/io.smallrye.smallrye-config-1.3.5.jar (No such file or directory) in my case.

I see same error when the root directory is named:

  • app dir ect ory
  • app#dir
  • 啪lu钮ou膷k媒-k暖艌
  • app!@#%dir ect ory

For the following cases I have successful run of compilation + dev mode + native build

With app?dir case I don't get through package phase

14:55:46 [INFO] 
14:55:46 [INFO] --- quarkus-maven-plugin:999-SNAPSHOT:build (default) @ space-quickstart ---
14:55:46 [INFO] ------------------------------------------------------------------------
14:55:46 [INFO] BUILD FAILURE
14:55:46 [INFO] ------------------------------------------------------------------------
14:55:46 [INFO] Total time: 7.579 s
14:55:46 [INFO] Finished at: 2019-03-27T14:55:46+01:00
14:55:46 [INFO] ------------------------------------------------------------------------
14:55:46 [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:
  build (default) on project space-quickstart: Failed to build a runnable JAR: 
  Failed to build a runner jar: URI has a query component -> [Help 1]

Again it's going to be wrong URI handling somewhere.

Here's the rules for class paths:

  • A MANIFEST.MF Class-Path is a list of relative URIs. A relative URI is not a relative directory, it's a URI without a scheme (see the RFC).

    • Additional rule for Windows: Absolute paths of the form C:\foo\bar.jar must have a leading slash when included in a Class-Path, like this: /C:/foo/bar. This happens by default when you use URI#getRawPath as described below. Note that when specifying paths in a CLASSPATH or -classpath, you must not use the leading / before the drive letter!

  • Since it's a space-separated list, the "raw" URI must be used (see the JavaDoc for URI.toAsciiString() as this will URI-encode and UTF-8 encode the whole URI).
  • The JDK forbids usage of URIs that are not in the file scheme. Some JDKs don't allow URIs with any scheme including file. Make sure the URI is relative before encoding it. I think that simply using the raw path will just about always suffice.
  • When emitting URIs, use Path.toUri(). If you're just pulling the raw path, no further conversion is necessary.
  • When decoding URIs back to Path, use Paths.get(URI). Nice and easy.
  • When you need a File, use Path.toFile().

If you are not adhering to these rules, please include copious documentation explaining your rationale!

I'll update all related issues to reference this comment.

This seems related to #1402/#1607/#1438/#1030/etc.

Can this issue be closed? Looks like all the related issues have been closed.

Yes, I think so. Thanks.

Was this page helpful?
0 / 5 - 0 ratings