quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.56k stars 2.63k forks source link

Quarkus CLI comands failed with: [ERROR] ❗ Unable to create project: Failed to initialize the Maven artifact resolver #42890

Closed sunnyguohua closed 2 weeks ago

sunnyguohua commented 2 weeks ago

Describe the bug

Quarkus CLI comand "quarkus create" failed with: [ERROR] ❗ Unable to create project: Failed to initialize the Maven artifact resolver

andy@appledeMacBook-Pro ~ % quarkus create && cd code-with-quarkus Creating an app (default project type, see --help). [ERROR] ❗ Unable to create project: Failed to initialize the Maven artifact resolver

Expected behavior

quarkus project correctly created.

Actual behavior

error

How to Reproduce?

  1. Install openjdk: andy@appledeMacBook-Pro ~ % java -version openjdk version "17.0.12" 2024-07-16 OpenJDK Runtime Environment Homebrew (build 17.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.12+0, mixed mode, sharing)

  2. Installed maven: andy@appledeMacBook-Pro ~ % mvn -v Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: /usr/local/apache-maven-3.9.9 Java version: 17.0.12, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.12/libexec/openjdk.jdk/Contents/Home Default locale: zhCN#Hans, platform encoding: UTF-8 OS name: "mac os x", version: "13.4.1", arch: "x86_64", family: "mac"

(I tried /usr/local/apache-maven-3.6.3 , /usr/local/apache-maven-3.8.8, and /usr/local/apache-maven-3.9.6)

  1. Install quarkus: curl -Ls https://sh.jbang.dev | bash -s - trust add https://repo1.maven.org/maven2/io/quarkus/quarkus-cli/ curl -Ls https://sh.jbang.dev | bash -s - app install --fresh --force quarkus@quarkusio

andy@appledeMacBook-Pro ~ % quarkus -v 3.14.1

  1. try to create quarkus project: andy@appledeMacBook-Pro ~ % quarkus create && cd code-with-quarkus

Here I got error: Creating an app (default project type, see --help). [ERROR] ❗ Unable to create project: Failed to initialize the Maven artifact resolver

Output of uname -a or ver

Darwin appledeMacBook-Pro.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "17.0.12" 2024-07-16 OpenJDK Runtime Environment Homebrew (build 17.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.12+0, mixed mode, sharing)

Quarkus version or git rev

3.14.1

Build tool (ie. output of mvnw --version or gradlew --version)

mvn -v:

Additional information

No response

quarkus-bot[bot] commented 2 weeks ago

/cc @ebullient (cli), @maxandersen (cli,jbang), @quarkusio/devtools (jbang,maven)

sunnyguohua commented 2 weeks ago

andy@appledeMacBook-Pro ~ % mvn -v Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: /usr/local/apache-maven-3.9.9 Java version: 17.0.12, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.12/libexec/openjdk.jdk/Contents/Home Default locale: zhCN#Hans, platform encoding: UTF-8 OS name: "mac os x", version: "13.4.1", arch: "x86_64", family: "mac"

sunnyguohua commented 2 weeks ago

the Maven CLI command works: mvn io.quarkus.platform:quarkus-maven-plugin:3.13.2:create \ -DprojectGroupId=my-groupId \ -DprojectArtifactId=my-artifactId

gsmet commented 2 weeks ago

Could you try quarkus create -e? We should have more details about the errors.

Do you have some particular Maven settings in your .m2/?

sunnyguohua commented 2 weeks ago
andy@192 ~ % quarkus create -e 

Creating an app (default project type, see --help).
java.lang.IllegalStateException: Failed to initialize the Maven artifact resolver
    at io.quarkus.devtools.project.QuarkusProjectHelper.artifactResolver(QuarkusProjectHelper.java:211)
    at io.quarkus.devtools.project.QuarkusProjectHelper.getCatalogResolver(QuarkusProjectHelper.java:152)
    at io.quarkus.cli.registry.RegistryClientMixin.getExtensionCatalogResolver(RegistryClientMixin.java:118)
    at io.quarkus.cli.registry.RegistryClientMixin.getExtensionCatalog(RegistryClientMixin.java:91)
    at io.quarkus.cli.registry.RegistryClientMixin.createQuarkusProject(RegistryClientMixin.java:60)
    at io.quarkus.cli.create.BaseCreateCommand.build(BaseCreateCommand.java:223)
    at io.quarkus.cli.CreateApp.call(CreateApp.java:81)
    at io.quarkus.cli.CreateApp.call(CreateApp.java:22)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
    at picocli.CommandLine.execute(CommandLine.java:2174)
    at io.quarkus.cli.Create.call(Create.java:35)
    at io.quarkus.cli.Create.call(Create.java:12)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
    at picocli.CommandLine.execute(CommandLine.java:2174)
    at io.quarkus.cli.QuarkusCli.run(QuarkusCli.java:116)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:140)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
    at io.quarkus.cli.Main.main(Main.java:9)
Caused by: io.quarkus.bootstrap.resolver.maven.BootstrapMavenException: Failed to initialize Maven repository settings
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getEffectiveSettings(BootstrapMavenContext.java:357)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.newRepositorySystemSession(BootstrapMavenContext.java:454)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getRepositorySystemSession(BootstrapMavenContext.java:305)
    at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.<init>(MavenArtifactResolver.java:93)
    at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver$Builder.build(MavenArtifactResolver.java:74)
    at io.quarkus.devtools.project.QuarkusProjectHelper.artifactResolver(QuarkusProjectHelper.java:209)
    ... 30 more
Caused by: org.apache.maven.settings.building.SettingsBuildingException: 1 problem was encountered while building the effective settings
[FATAL] Non-parseable settings /Users/andy/.m2/settings.xml: XMLDecl is only allowed as first characters in input (position: START_DOCUMENT seen \n<?xml ... @2:7)  @ /Users/andy/.m2/settings.xml, line 2, column 7

    at org.apache.maven.settings.building.DefaultSettingsBuilder.build(DefaultSettingsBuilder.java:115)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getEffectiveSettings(BootstrapMavenContext.java:341)
    ... 35 more

[ERROR] ❗  Unable to create project: Failed to initialize the Maven artifact resolver
sunnyguohua commented 2 weeks ago
andy@192 ~ % cat .m2/settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <mirrors>
    </mirrors>
    <servers>
        <server>
            <id>lgmg-maven-releases</id>
        </server>
        <server>
            <id>lgmg-maven-snapshots</id>
        </server>
    </servers>
    <profiles>
        <!-- Configure the Red Hat build of Quarkus Maven repository -->
        <profile>
            <id>red-hat-enterprise-maven-repository</id>
            <repositories>
                <repository>
                    <id>red-hat-enterprise-maven-repository</id>
                    <url>https://maven.repository.redhat.com/ga/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>red-hat-enterprise-maven-repository</id>
                    <url>https://maven.repository.redhat.com/ga/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>red-hat-enterprise-maven-repository</activeProfile>
    </activeProfiles>
</settings>
gsmet commented 2 weeks ago

So the problem is the new line at the beginning of your settings.xml.

sunnyguohua commented 2 weeks ago

Thanks, the mal-formed settings.xml works for maven but not quarkus.

Thanks!

gsmet commented 2 weeks ago

Yeah, it's a bit odd as we are sending the File instance to a Maven API without adjusting it at all.