-
Notifications
You must be signed in to change notification settings - Fork 78
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
feature: Run local coursier if available to avoid using bootstraped one #1385
Conversation
9d28ed7
to
94ce9d6
Compare
(process.platform === "win32" && p.endsWith(path.sep + "cs.bat")) | ||
); | ||
if (possibleCoursier) { | ||
const coursierVersion = spawnSync(possibleCoursier, ["version"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to work around this, I can't find a way to chain ChildProcess since then is only available on Promise. Alternatively, we could make a spawn with a wait to make sure this doesn't take too long. Ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already dependency on promisify-child-process
which provides a promisfied equivalents of child_process, did you check it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did? Doing .then
on ChildProcessPromise was only returning Promise<Output>
and not sure of there is a way around it really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe https://github.com/sindresorhus/execa help?
As long as we use raw child_process stuffs (without writing a wrapper) there's no way to do that (get stdout wrapped by Promise if success, and Promise failed if return code isn't 0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like it :/ We want to pipe the output from coursier to VS Code output, but it seems I can do it only via ChildProcessPromise. I tried returning a Promise, but that seems to have a wrong type in the actual javascript underneath:
906323d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Och actually if I have an intermediate object it works, not 100% pretty, but feels ok.
509aba3
to
022a78c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments, but overall it looks good 👍
} | ||
|
||
export function validateCoursier(pathEnv: string): string | undefined { | ||
const isWindows = process.platform === "win32"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note]
I thought this might fail to detect windows when it's 64bit system, but it looks like there's only win32
😄
https://nodejs.org/api/process.html#process_process_platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep :P I checked the docs
"-p", | ||
]; | ||
|
||
const path = process.env["PATH"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this work for Windows (while CI tests pass), maybe it's Path
instead of PATH
on windows?
avajs/ava#3014
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PATH
works, the CI actually checks this correctly. https://superuser.com/questions/441611/what-is-the-linux-equivalent-of-windows-path
"sourceMaps": true, | ||
"outFiles": ["${workspaceRoot}/out/**/*.js"], | ||
"outFiles": ["${workspaceRoot}/packages/metals-vscode/out/**/*.js"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise it's not possible to start the extension inside VS Code, I can move it separate, but this is just a follow up from the PR that merged the language client
|
||
export function validateCoursier(pathEnv: string): string | undefined { | ||
const isWindows = process.platform === "win32"; | ||
const possibleCoursier = pathEnv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to use https://github.com/otiai10/lookpath to find commands from PATH, this library deals well with the platform differences (and it takes care of PATHEXT
to checking cs.bat
and cs.exe
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I would add the library if we see any issue, but this seems to work correctly both in linux and windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it seems that the alst release was in 2021 so I would rather tweak our logic if needed.
(process.platform === "win32" && p.endsWith(path.sep + "cs.bat")) | ||
); | ||
if (possibleCoursier) { | ||
const coursierVersion = spawnSync(possibleCoursier, ["version"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe https://github.com/sindresorhus/execa help?
As long as we use raw child_process stuffs (without writing a wrapper) there's no way to do that (get stdout wrapped by Promise if success, and Promise failed if return code isn't 0).
a2fc784
to
b665fdc
Compare
This might help out in corporate environements since it will require installing coursier only once and Metals will be able to use it. In later steps I will try to automatically download coursier or native image via metals if not available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM:+1:
This might help out in corporate environements since it will require installing coursier only once and Metals will be able to use it.
In later steps I will try to automatically download coursier or native image via metals if not available.
Continuation of scalameta/metals-languageclient#524