Support multiple drives when using the CLI on Windows with cygwin #17872
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there,
This PR is to fix an edge case for MinGW and Cygwin users where projects and source files are stored on different drives, causing the Spring Boot CLI to fail on startup. I searched through the Issue log and unfortunately didn't find anything about this so I haven't attached an issue number.
I originally noticed that the Spring Boot CLI wouldn't run on my home PC due to a space in the
SPRING_HOME
folder path (i.e.C:\Program Files\...
) for the Windows Batch executable script (which unfortunately is not included in the current branch so I've omitted that fix from this PR).The error message was
Error: Could not find or load main class org.springframework.boot.loader.JarLauncher
and after researching a bit I narrowed it the issue down to two separate problems:I found the problem to be that the
$CLASSPATH
variable was being parsed incorrectly as my Spring project was stored on a different hard drive,F:\
, as opposed to my$SPRING_HOME
folder,C:\
. Because of this, the part of the Shell script where it assembles the $CLASSPATH variable viacygpath
would get confused about what the root drive actually is and so I'd end up with a bunch of/f/
prefixes to each $CLASSPATH folder, which in turn led to the above error message.To fix this, I added two ternary checks to modify what exactly we're feeding into the
$SPRING_HOME
and$CLASSPATH
variables before we actually attempt to run thejava -cp
command. Lastly, I also noticed a minor cosmetic consistency thing where${}
was used in one place and$
was used in another so I adjusted that to stay consistent. Lastly, the space in the folder path (i.e.Program Files
) didn't help the situation so I added some double quotes ("") to take care of that edge case as well.Of course, please test my changes for yourselves and if you think this change is worthy of a merge then I look forward to living the dream of one day seeing that purple icon on my notifications page.
Well, that's my Pull Request! Thanks for reading.