Skip to content

Support multiple drives when using the CLI on Windows with cygwin #17872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

wanderrful
Copy link
Contributor

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 via cygpath 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 the java -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.

@pivotal-issuemaster
Copy link

@wanderrful Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@wanderrful Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 15, 2019
@philwebb philwebb added for: team-attention An issue we'd like other members of the team to review type: enhancement A general enhancement and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Aug 20, 2019
@philwebb philwebb added this to the 2.2.x milestone Aug 21, 2019
@wilkinsona wilkinsona changed the title Support multiple drives in run script Support multiple drives in CLI's spring script Sep 3, 2019
@wilkinsona wilkinsona self-assigned this Sep 3, 2019
@wilkinsona wilkinsona closed this in 57d68c6 Sep 3, 2019
@snicoll snicoll modified the milestones: 2.2.x, 2.2.0.M6 Sep 3, 2019
@wilkinsona
Copy link
Member

@wanderrful Thank you very much for making your first contribution to Spring Boot. The proposed changes are now in master along with a small polish commit. The polishing is to address an issue in a "normal" bash shell to avoid the following output:

./bin/spring: line 102: cygpath: command not found
./bin/spring: line 108: cygpath: command not found

If you have a chance to try a snapshot once this build has completed and confirm that the changes work in your environment that would be much appreciated.

@wilkinsona wilkinsona changed the title Support multiple drives in CLI's spring script Support multiple drives when using the CLI on Windows with cygwin Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants