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: ensure PATH is always set #93

Merged
merged 1 commit into from
Aug 10, 2022
Merged

fix: ensure PATH is always set #93

merged 1 commit into from
Aug 10, 2022

Conversation

danez
Copy link
Contributor

@danez danez commented Aug 9, 2022

PR #82 broke the detection of global installed binaries. The detection of the binary uses all environment variables and finds the global binary. When we then run the edge function with deno ... deno is not found because PATH is not there anymore.

I don't like this solution, but I like the alternative even less. The only alternative i could come up is using node-which package to find the absolute path to the global binary. But not sure if we really want to add that overhead?
What do you think? This means that edge functions in dev will have PATH available.

@danez danez added the type: bug code to address defects in shipped code label Aug 9, 2022
@danez danez requested a review from a team August 9, 2022 16:18
eduardoboucas
eduardoboucas previously approved these changes Aug 9, 2022
@danez danez changed the title fix: supply PATH to deno fix: detect global Path correctly instead of relying on PATH env variable Aug 9, 2022
@danez danez changed the title fix: detect global Path correctly instead of relying on PATH env variable fix: detect global deno correctly instead of relying on PATH env variable Aug 9, 2022
@danez danez force-pushed the path branch 4 times, most recently from 7da11ee to 57b6bfd Compare August 10, 2022 10:02
@danez danez changed the title fix: detect global deno correctly instead of relying on PATH env variable fix: ensure PATH is always set Aug 10, 2022
@@ -199,6 +200,9 @@ class DenoBridge {
env.DENO_DIR = this.denoDir
}

// Ensure PATH is always set as otherwise we are not able to find the global deno binary
env[pathKey()] = inputEnv[pathKey({ env: inputEnv })] || process.env[pathKey()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't pathKey always need the environment variables passed in?

If I look at this correctly, and if the variable happens to be PATH on Windows, you're then setting it as Path in the final env object?

Or am I misunderstanding? 🤔

Copy link
Contributor Author

@danez danez Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sets path to whatever the PATH casing is in process.env.
So if someone passes in PATH, it will be converted to Path on windows, or whatever the current casing is.

So from the outside of the bridge you do not need to care about windows or not.

package.json Show resolved Hide resolved
@danez danez merged commit 2f71c57 into main Aug 10, 2022
@danez danez deleted the path branch August 10, 2022 10:38
Skn0tt pushed a commit to netlify/build that referenced this pull request Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants