From db9b8028510820177c32e945e1b8e5208733bbf9 Mon Sep 17 00:00:00 2001 From: Maciej Stosio Date: Mon, 13 Jan 2025 23:53:12 +0100 Subject: [PATCH 1/6] Update subprocess.ts --- packages/vscode-extension/src/utilities/subprocess.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vscode-extension/src/utilities/subprocess.ts b/packages/vscode-extension/src/utilities/subprocess.ts index b69063561..7cf168861 100644 --- a/packages/vscode-extension/src/utilities/subprocess.ts +++ b/packages/vscode-extension/src/utilities/subprocess.ts @@ -5,6 +5,8 @@ import { Platform } from "./platform"; export type ChildProcess = ExecaChildProcess; +const PRE_PATH_TOKEN = "{RNIDE_PRE_PATH}"; + 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 @@ -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"`]); + return path.split(PRE_PATH_TOKEN)[1].trim(); } let pathEnv: string | undefined; From 28e2b80f64ce8c20e888a816f67083f1eac5f929 Mon Sep 17 00:00:00 2001 From: Maciej Stosio Date: Tue, 14 Jan 2025 11:19:22 +0100 Subject: [PATCH 2/6] Omit also the part after if there is one --- packages/vscode-extension/src/utilities/subprocess.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vscode-extension/src/utilities/subprocess.ts b/packages/vscode-extension/src/utilities/subprocess.ts index 7cf168861..5dde3f869 100644 --- a/packages/vscode-extension/src/utilities/subprocess.ts +++ b/packages/vscode-extension/src/utilities/subprocess.ts @@ -18,7 +18,7 @@ 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 "${PRE_PATH_TOKEN}$PATH"`]); + const { stdout: path } = await execa(shellPath, ["-i", "-c", `cd "${appRoot}" && echo "${PRE_PATH_TOKEN}$PATH${PRE_PATH_TOKEN}"`]); return path.split(PRE_PATH_TOKEN)[1].trim(); } From 7de7a78c318da82da5965b63449c8379ed6119fd Mon Sep 17 00:00:00 2001 From: Maciej Stosio Date: Tue, 14 Jan 2025 11:19:46 +0100 Subject: [PATCH 3/6] Fix lint --- packages/vscode-extension/src/utilities/subprocess.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/vscode-extension/src/utilities/subprocess.ts b/packages/vscode-extension/src/utilities/subprocess.ts index 5dde3f869..d7bdcb0eb 100644 --- a/packages/vscode-extension/src/utilities/subprocess.ts +++ b/packages/vscode-extension/src/utilities/subprocess.ts @@ -18,7 +18,11 @@ 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 "${PRE_PATH_TOKEN}$PATH${PRE_PATH_TOKEN}"`]); + const { stdout: path } = await execa(shellPath, [ + "-i", + "-c", + `cd "${appRoot}" && echo "${PRE_PATH_TOKEN}$PATH${PRE_PATH_TOKEN}"`, + ]); return path.split(PRE_PATH_TOKEN)[1].trim(); } From 26048e7255d9c55722f16333d6c9dc6944605089 Mon Sep 17 00:00:00 2001 From: Maciej Stosio Date: Tue, 14 Jan 2025 12:38:19 +0100 Subject: [PATCH 4/6] Add changes from comments --- packages/vscode-extension/src/utilities/subprocess.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/vscode-extension/src/utilities/subprocess.ts b/packages/vscode-extension/src/utilities/subprocess.ts index d7bdcb0eb..54e8a36d2 100644 --- a/packages/vscode-extension/src/utilities/subprocess.ts +++ b/packages/vscode-extension/src/utilities/subprocess.ts @@ -5,7 +5,6 @@ import { Platform } from "./platform"; export type ChildProcess = ExecaChildProcess; -const PRE_PATH_TOKEN = "{RNIDE_PRE_PATH}"; async function getPathEnv(appRoot: string) { // We run an interactive shell session to make sure that tool managers (nvm, @@ -17,13 +16,15 @@ async function getPathEnv(appRoot: string) { // versions based on directory in most managers). // Fish, bash, and zsh all support -i and -c flags. + const RNIDE_PATH_DELIMITER = "{RNIDE_PATH_DELIMITER}"; + const shellPath = process.env.SHELL ?? "/bin/zsh"; - const { stdout: path } = await execa(shellPath, [ + const { stdout } = await execa(shellPath, [ "-i", "-c", - `cd "${appRoot}" && echo "${PRE_PATH_TOKEN}$PATH${PRE_PATH_TOKEN}"`, + `cd "${appRoot}" && echo "${RNIDE_PATH_DELIMITER}$PATH${RNIDE_PATH_DELIMITER}"`, ]); - return path.split(PRE_PATH_TOKEN)[1].trim(); + return stdout.split(RNIDE_PATH_DELIMITER)[1].trim(); } let pathEnv: string | undefined; From 213f84c4b18ea36d0076e07085ba8cbc844538b2 Mon Sep 17 00:00:00 2001 From: Maciej Stosio Date: Tue, 14 Jan 2025 12:38:35 +0100 Subject: [PATCH 5/6] Fix lint --- packages/vscode-extension/src/utilities/subprocess.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vscode-extension/src/utilities/subprocess.ts b/packages/vscode-extension/src/utilities/subprocess.ts index 54e8a36d2..62ca531ff 100644 --- a/packages/vscode-extension/src/utilities/subprocess.ts +++ b/packages/vscode-extension/src/utilities/subprocess.ts @@ -5,7 +5,6 @@ import { Platform } from "./platform"; export type ChildProcess = ExecaChildProcess; - 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 From d5ce3215665b274814dc648acb3ecb8fef804046 Mon Sep 17 00:00:00 2001 From: Maciej Stosio Date: Tue, 14 Jan 2025 12:48:42 +0100 Subject: [PATCH 6/6] Add log with obtained path --- packages/vscode-extension/src/utilities/subprocess.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vscode-extension/src/utilities/subprocess.ts b/packages/vscode-extension/src/utilities/subprocess.ts index 62ca531ff..d5217f948 100644 --- a/packages/vscode-extension/src/utilities/subprocess.ts +++ b/packages/vscode-extension/src/utilities/subprocess.ts @@ -23,7 +23,9 @@ async function getPathEnv(appRoot: string) { "-c", `cd "${appRoot}" && echo "${RNIDE_PATH_DELIMITER}$PATH${RNIDE_PATH_DELIMITER}"`, ]); - return stdout.split(RNIDE_PATH_DELIMITER)[1].trim(); + const path = stdout.split(RNIDE_PATH_DELIMITER)[1].trim(); + Logger.debug("Obtained PATH environment variable:", path); + return path; } let pathEnv: string | undefined;