Skip to content
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

Merged
merged 6 commits into from
Jan 14, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/vscode-extension/src/utilities/subprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Platform } from "./platform";

export type ChildProcess = ExecaChildProcess<string>;

const PRE_PATH_TOKEN = "{RNIDE_PRE_PATH}";
maciekstosio marked this conversation as resolved.
Show resolved Hide resolved

async function getPathEnv(appRoot: string) {
// We run an interactive shell session to make sure that tool managers (nvm,
// asdf, mise, etc.) are loaded and PATH is set correctly. Mise in
Expand All @@ -16,8 +18,12 @@ 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, [
maciekstosio marked this conversation as resolved.
Show resolved Hide resolved
"-i",
"-c",
`cd "${appRoot}" && echo "${PRE_PATH_TOKEN}$PATH${PRE_PATH_TOKEN}"`,
]);
return path.split(PRE_PATH_TOKEN)[1].trim();
Copy link
Member

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?

}

let pathEnv: string | undefined;
Expand Down
Loading