Skip to content

Conversation

dos65
Copy link
Contributor

@dos65 dos65 commented Dec 6, 2022

Originally reported in scalameta/metals#4702 (comment)

@lightbend-cla-validator
Copy link

@eed3si9n
Copy link
Member

eed3si9n commented Dec 6, 2022

@dos65 Thanks for the contribution!

@@ -63,7 +63,7 @@ object BuildServerConnection {
// For those who use an old sbt script, the -Dsbt.script is not set
// As a fallback we try to find the sbt script in $PATH
val fileName = if (Properties.isWin) "sbt.bat" else "sbt"
val envPath = sys.env.getOrElse("PATH", "")
val envPath = sys.env.get("PATH").orElse(sys.env.get("Path")).getOrElse("")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of singling out PATH and Path, would it make sense at this point to filter to all keys that becomes PATH if you turned it to upper case, and pick the first entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it makes sense. Changed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eed3si9n Doesn't it potentially break semantics on *NIX where you could have a variable PATH and also other case variants?
The suggested code gives no guarantee which would be the first.

I would suggest that the “filter to all keys that becomes PATH if you turned it to upper case, and pick the first entry” was only used on Windows (to match Windows semantics) but on *NIX you still only looked for PATH (upper case) We already have special handling for Windows for the name of the sbt launcher.

Copy link
Contributor Author

@dos65 dos65 Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martingd

We already have special handling for Windows for the name of the sbt launcher

Could you point where is this handling defined?
I think the best option would be to reuse/copy-paste the existing logic

@dos65 dos65 force-pushed the bspconfig_windows_path_fix branch from 14f424b to a2de064 Compare December 6, 2022 17:41
@eed3si9n eed3si9n merged commit 973cd63 into sbt:1.8.x Dec 7, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants