microsoft/vscode-gradle

Init fails if the user directory has a single quote

Opened this issue · 0 comments

Extension Name: vscode-gradle
Extension Version: v3.16.4
OS Version: Windows 10 OS Build 19045.4894
VSCode version: 1.93.1

Describe the bug
Project fails to properly initialize (immediate "Gradle: Build Error"). As a result, most of Gradle's functions on VSCode don't work out-of-the-box.

To Reproduce

  1. Have a User folder name with a single quote in it (ex.: Teh's PC)
    then
  2. Create a new Java Project that uses Gradle (happens with both Kotlin and Groovy DSL)
    or
  3. Open existing Folder that uses Gradle

Expected behavior
No errors on a new or existing project (that didn't have any to begin with)

Screenshots
If applicable, add screenshots to help explain your problem.

Output from "Gradle for Java"

[info] [gradle-server] Gradle Server started, listening on 52088
[info] Gradle client connected to server
[info] Java Home: C:\Users\Teh's PC\.vscode\extensions\redhat.java-1.35.0-win32-x64\jre\17.0.12-win32-x86_64
[info] JVM Args: --add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=384m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant
[info] Gradle User Home: C:\Users\Teh's PC\.gradle
[info] Gradle Version: 8.8
[error] FAILURE: Build failed with an exception.

* Where:
Initialization script 'C:\Users\TEH'SP~1\AppData\Local\Temp\6cd13dd2fa51480d337b832a789dc587a42a1bcc56faca1ac557de2d9d4abf5d.gradle' line: 3

* What went wrong:
Could not compile initialization script 'C:\Users\TEH'SP~1\AppData\Local\Temp\6cd13dd2fa51480d337b832a789dc587a42a1bcc56faca1ac557de2d9d4abf5d.gradle'.
> startup failed:
  initialization script 'C:\Users\TEH'SP~1\AppData\Local\Temp\6cd13dd2fa51480d337b832a789dc587a42a1bcc56faca1ac557de2d9d4abf5d.gradle': 3: Unexpected character: '\'' @ line 3, column 125.
     14b6d4df3032861318303278f9.jar')
                                   ^
  
  1 error


* 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.

CONFIGURE FAILED in 20s
[error] [gradle-server] The supplied build action failed with an exception.

Does the bug still exist if you disable all other extensions?
Yes

Additional context
I have little-to-no knowledge of Gradle, and had been following a guide to set it up for development, but if any new project encounters this then I assume it's a bug.
Managed to manually fix it by copying the offending .gradle file, replacing the quotes around the file path with double-quotes instead of single-quotes, then running ./gradlew -I fixed_init_script.gradle. It works now on my specific project, but the bug/error noted above still persists. I also don't know if this is a proper fix (see first sentence), but I'm noting it down anyways because while troubleshooting (hello search engine visitor) I haven't seen anyone else with this same problem note a solution, and it might help as additional context.