-
Notifications
You must be signed in to change notification settings - Fork 49
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
Fix failing to obtain $PATH #899
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -16,8 +18,8 @@ async function getPathEnv(appRoot: string) { | |||
|
|||
// Fish, bash, and zsh all support -i and -c flags. | |||
const shellPath = process.env.SHELL ?? "/bin/zsh"; | |||
const { stdout: path } = await execa(shellPath, ["-i", "-c", `cd "${appRoot}" && echo "$PATH"`]); | |||
return path.trim(); | |||
const { stdout: path } = await execa(shellPath, ["-i", "-c", `cd "${appRoot}" && echo "${PRE_PATH_TOKEN}$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'd suggest that to make it easier to debug such problems in the future we should add log statement to print the output of this command
const { stdout: path } = await execa(shellPath, ["-i", "-c", `cd "${appRoot}" && echo "$PATH"`]); | ||
return path.trim(); | ||
const { stdout: path } = await execa(shellPath, ["-i", "-c", `cd "${appRoot}" && echo "${PRE_PATH_TOKEN}$PATH"`]); | ||
return path.split(PRE_PATH_TOKEN)[1].trim(); |
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.
would it be possible for the shell to also add something after the command? For example, there are some extensions that print exit code after each command. Maybe we should have both prefix and suffix to extract the 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.
Left more comments inline
Fixes #896
This PR solves the problem of IDE not being able to obtain $PATH when something is printed at the launch of the shell, by adding unique tokens before and after
$PATH
value. This way we make sure only $PATH is extracted.How Has This Been Tested:
echo "SOMETHING"
to your./zshrc