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

Conversation

maciekstosio
Copy link
Contributor

@maciekstosio maciekstosio commented Jan 13, 2025

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:

  • add echo "SOMETHING" to your ./zshrc
  • IDE should be able to obtain $PATH anyway

Copy link

vercel bot commented Jan 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 11:49am

@@ -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"`]);
Copy link
Member

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();
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?

Copy link
Member

@kmagiera kmagiera left a 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

packages/vscode-extension/src/utilities/subprocess.ts Outdated Show resolved Hide resolved
packages/vscode-extension/src/utilities/subprocess.ts Outdated Show resolved Hide resolved
@maciekstosio maciekstosio merged commit 7281f0d into main Jan 14, 2025
4 checks passed
@maciekstosio maciekstosio deleted the @maciekstosio/Fix-failing-to-obtain-path branch January 14, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paid for 1 year but still lots of issues, no IOS devices found, NPM ENAMETOOLONG (output)
2 participants