quarkusio / quarkus

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

`gradle quarkusUpdate` fails while running in Windows Powershell #37721

Open gastaldi opened 11 months ago

gastaldi commented 11 months ago

If I switch to 'powershell' + the batch files...

psh ❯ .\gradlew quarkusUpdate
...
> Task :quarkusUpdate
quarkusUpdate is experimental, its options and output might change in future versions
Detected project Java version: 21
Detected project Java version: 21
Instructions to update this project from '3.6.2' to '3.6.3':
Recommended Quarkus platform BOM updates:
Update: io.quarkus.platform:quarkus-bom:pom:3.6.2 -> 3.6.3
...

Resolved io.quarkus:quarkus-updates-recipes:1.0.11 with 0 recipe(s) to update from 3.6.2 to 3.6.3 (initially made for OpenRewrite GRADLE plugin version: 6.5.10)
OpenRewrite recipe generated: C:\TEMP\quarkus-project-recipe-18062489789386963700.yaml
...
Executing:
D:\storage\workdir\quarkus-update-repro\gradlew.bat --console plain --stacktrace --init-script C:\TEMP\openrewrite-init15405549798719511192gradle rewriteRun

Which then hangs forever... If you try to run the precise commandline again in powershell:

psh ❯ ./gradlew.bat --console plain --stacktrace --init-script C:\TEMP\openrewrite-init15405549798719511192gradle rewriteRun
...
FAILURE: Build failed with an exception.

* Where:
Initialization script 'C:\TEMP\openrewrite-init15405549798719511192gradle' line: 27

* What went wrong:
Could not compile initialization script 'C:\TEMP\openrewrite-init15405549798719511192gradle'.
> startup failed:
  initialization script 'C:\TEMP\openrewrite-init15405549798719511192gradle': 27: Unexpected character: '"' @ line 27, column 50.
     project.getRootProject().file("C:\TEMP\q
                                   ^

  1 error
psh ❯ ./gradlew.bat --console plain --stacktrace --init-script C:\TEMP\openrewrite-init15405549798719511192gradle rewriteRun
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.5/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build
> Task :processResources
> Task :quarkusGenerateCode
> Task :quarkusGenerateCodeDev
> Task :compileJava NO-SOURCE
> Task :classes
> Task :compileQuarkusTestGeneratedSourcesJava NO-SOURCE
> Task :quarkusGenerateCodeTests
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :compileIntegrationTestJava NO-SOURCE
> Task :processIntegrationTestResources NO-SOURCE
> Task :integrationTestClasses UP-TO-DATE
> Task :compileNativeTestJava NO-SOURCE
> Task :compileQuarkusGeneratedSourcesJava NO-SOURCE
> Task :rewriteResolveDependencies

> Task :rewriteRun
Validating active recipes
Scanning sources in project :
Using active styles []
All sources parsed, running active recipes: io.quarkus.openrewrite.Quarkus
Generated new file gradle.properties by:
    io.quarkus.openrewrite.Quarkus
        org.openrewrite.gradle.AddProperty: {key=quarkusPlatformVersion, value=3.6.3, overwrite=true}
Generated new file gradle.properties by:
    io.quarkus.openrewrite.Quarkus
        org.openrewrite.gradle.AddProperty: {key=quarkusPluginVersion, value=3.6.3, overwrite=true}
Please review and commit the results.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 21s
6 actionable tasks: 6 executed

Which implies to me that the problem is 'potentially on windows' and not just isolated to my WSL.

Originally posted by @quotidian-ennui in https://github.com/quarkusio/quarkus/issues/37715#issuecomment-1853989074

quarkus-bot[bot] commented 11 months ago

/cc @glefloch, @quarkusio/devtools

quotidian-ennui commented 11 months ago

Additional Info:

JAVA_HOME=D:\Storage\.sdkman\candidates\java\current
JAVA_JDK_OPTIONS=-Djava.io.tmpdir=C:/TEMP -Dpolyglot.js.nashorn-compat=true -Dpolyglot.engine.WarnInterpreterOnly=false -Dlog4j2.Script.enableLanguages=javascript

But ultimately the fix is to str.replaceAll("\\\\","/") or similar; and perhaps do some %20 encoding as well, because while I have c:\temp... the default temp dir is gonna be something like "C:\Users\John Smith\AppData\Roaming\Temp"

gastaldi commented 11 months ago

But ultimately the fix is to str.replaceAll("\\\\","/") or similar; and perhaps do some %20 encoding as well, because while I have c:\temp... the default temp dir is gonna be something like "C:\Users\John Smith\AppData\Roaming\Temp"

Where?

quotidian-ennui commented 11 months ago

In what ever process generates the C:\TEMP\openrewrite-init15405549798719511192gradle file; which from a cursory search of the quarkus repo suggests this location (I searched for openrewrite-init)

https://github.com/quarkusio/quarkus/blob/07c0c0698d063add0d536051730bef4f7054e945/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdateCommand.java#L83C1-L83C83

and changing that to "rewriteFile", recipe.toAbsolutePath().toString().replaceAll("\\\\", "/"),

or potentially changing the whole thing into a URI or something, via Paths.get().toURI() if the file() method in gradle supports such a thing. (Apache Commons IO has FilenameUtils.separatorsToUnix())

n8s16 commented 4 months ago

I am also experiencing this issue. Is there any update on it?

gastaldi commented 4 months ago

@n8s16 can you attach a simple reproducer?

quotidian-ennui commented 4 months ago

Well, I didn't think you'd need a reproducer once I'd shown you the line in the code that presents the problem (as per my comments above).

@gastaldi : https://github.com/quotidian-ennui/quarkus-update-pwsh

This reproduces the problem directly in my current windows environment. i.e. quarkusUpdate hangs forever once it tries to run rewriteRun when all it really needs to do is to change 2 entries in gradle.properties

Powershell Info

$PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      22621  3880
------------------------------------------------------------
Gradle 8.5
------------------------------------------------------------

Build time:   2023-11-29 14:08:57 UTC
Revision:     28aca86a7180baa17117e0e5ba01d8ea9feca598

Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.3 (Amazon.com Inc. 21.0.3+9-LTS)
OS:           Windows 11 10.0 amd64
n8s16 commented 4 months ago

@n8s16 can you attach a simple reproducer?

@gastaldi

I just created a new Quarkus project with version 3.8.5 and ran ./gradlew quarkusUpdate --stream=3.12. It seems to run indefinitely.

maxandersen commented 4 months ago

not sure trying to escape that path will help or trying to flip / vs . It needs to be treated as a path and quoted for the case if it has spaces.

n8s16 commented 4 months ago

In addition, as a workaround to update the Quarkus version, I manually changed the \ to / in the generated init script and run the rewriteRun.