question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Project cannot be synced when gradle init script path contains white spaces

See original GitHub issue

Good evening vscode-java team! Hope all is well. When I set generatesMetadataFilesAtProjectRoot to true and refresh the project, org.eclipse.buildship.core.prefs gets updated to include arguments=--init-script /Users/[...me]/Library/Application Support/Code - Insiders/User/globalStorage/redhat.java[...], etc. These scripts seem to be injecting some plugins and doing some setup stuff, which is totally cool, and things seem okay until the next time I rebuild (like by editing+saving the gradle file).

Due to the spaces in the path, the first one being in Application Support, I get an error: [Error - 7:15:04 PM] Sep 24, 2022, 7:15:04 PM Error occured while building workspace. Details: message: Could not run phased build action using connection to Gradle distribution '[...]/gradle-7.5.1-bin.zip'. The specified initialization script '/Users/[...me]/Library/Application' does not exist.; code: 0; resource: /Users/[...me]/Documents/[...project-path]/build.gradle;

I am able to work around this issue by either:

  1. removing the arguments line temporarily, re-saving the build.gradle file, and watch as it builds successfully.
  2. a bit more severe, but by using the --user-data-dir /Users/[...me]/.vscode-insiders/user-data flag applied to VS Code itself, the path that gets set for arguments is now a valid one!

Notes:

  • I tried every combination of quotes, escape characters, etc to get [...]/Application Support[...] to work and nothing would fix it. It just would not allow a path with a space in it.
  • I didn’t try it, but maybe another work around could be a settings/option to turn on that has it instead use a local (to the .settings folder) init gradle script that calls those other init scripts within it.
  • (user directory name redacted in all references to […me])
Environment
  • Operating System: MacOS 12.6
  • JDK version: 17.0.3
  • Visual Studio Code version: 1.72.0-insider
  • Java extension version: v1.11.2022092404
Steps To Reproduce
  1. Be on a mac
  2. Turn on thegeneratesMetadataFilesAtProjectRoot setting.
  3. Refresh the project, and watch as the org.eclipse.buildship.core.prefs file gets the described arguments line.
  4. Try to save the build.gradle file (automatic updating is turned on), and see it fail.

You may use https://spring.io/guides/gs/gradle/ w/ the “complete” project as a base hello world project. It just needs a gradle update to 7.3.X, which you all nicely tell us to do/help us through on open.

log.txt

Current Result

Project won’t build on build.gradle save due to inappropriate init scripts locations (no quotes around a spaced location)

Expected Result

Project builds under those circumstances.

Additional Informations

Provided upon request.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
CsCherrYYcommented, Sep 27, 2022

Well, I just sort out the story.

1.10.0

#2222 shows some errors caused by spaces in URIs. These errors will not affect the import & synchorize process since we have a fallback mechanism, see: https://github.com/eclipse/eclipse.jdt.ls/blob/1058840b2e442486ddd7e7d117db9e2db7533a32/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporter.java#L599-L617

when fileURL.toURI() fails due to spaces in the URI string, we fallback to getGradleInitScriptTempFile() and create the init script file in system temporary folder and continue the import & synchorize process. So you can find errors in server log, but it works.

1.11.2022092604

#2234 fixes #2222 and sends correct arguments to buildship BuildConfiguration, however, https://github.com/eclipse/buildship/issues/1207 makes it fail to synchorize the project. So you can find error shows the init script path is splited by spaces.

Solution

I suggested to follow the previous fallback mechanism and do not send arguments within spaces to buildship until https://github.com/eclipse/buildship/issues/1207 got solved. I will create a PR later.

1reaction
jdneocommented, Sep 30, 2022

@tthornton3-chwy Try running the command Java: Clean Java Language Server Workspace should fix your problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Initialization Scripts - Gradle User Manual
Specify a file on the command line. The command line option is -I or --init-script followed by the path to the script. ·...
Read more >
Error:Cause: unable to find valid certification path to requested ...
In Android Studio open File -> Project Structure -> SDK Location -> JDK ... and gradle ,in the log file tips me some...
Read more >
Gradle Wrapper - IntelliJ IDEA Guide - JetBrains
Useful information for working with projects that use the Gradle Wrapper.
Read more >
CLI for JFrog Artifactory
JFrog project key to be used by commands which expect build name and ... Specific path in Artifactory, under which to sync artifacts...
Read more >
How to Install Android Studio IDE & SDK and Get Started with ...
Take note that you should have enough space on C drive. ... and sync project" to install API-26 (another GB download!); or Under...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found