vscode-java: Project cannot be synced when gradle init script path contains white spaces
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:
- removing the
arguments
line temporarily, re-saving the build.gradle file, and watch as it builds successfully. - 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
- Be on a mac
- Turn on the
generatesMetadataFilesAtProjectRoot
setting. - Refresh the project, and watch as the
org.eclipse.buildship.core.prefs
file gets the describedarguments
line. - 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.
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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (9 by maintainers)
@tthornton3-chwy Try running the command
Java: Clean Java Language Server Workspace
should fix your problemWell, 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 togetGradleInitScriptTempFile()
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.
Thank you all again for looking into this, I appreciate the time and effort here. Sorry about the can of worms haha.
I can confirm what @jdneo said above about the latest release-- the paths used now in the
org.eclipse.buildship.core.prefs
file are now good/temp-looking ones with no spaces, so that’s awesome! But as per what was said, the build still fails becausethe specified initialization script '/var/folders/_2/6mk1mskj6698fmb0_81nzbgc0000gn/T/init...' does not exist.
If there’s anything you want me to do, just let me know.