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 when pkgx is installed by Homebrew on Linux #23

Merged
merged 4 commits into from
Feb 24, 2025

Conversation

felipecrs
Copy link
Contributor

No description provided.

@felipecrs felipecrs marked this pull request as draft February 15, 2025 16:00
@felipecrs felipecrs marked this pull request as ready for review February 15, 2025 16:05
Comment on lines +8 to +25
let path = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";

// for pkgx installed via homebrew
let homebrewPrefix = "";
switch (Deno.build.os) {
case "darwin":
homebrewPrefix = "/opt/homebrew"; // /usr/local is already in the path
break;
case "linux":
homebrewPrefix = `/home/linuxbrew/.linuxbrew:${Deno.env.get("HOME")}/.linuxbrew`;
break;
}
if (homebrewPrefix) {
homebrewPrefix = Deno.env.get("HOMEBREW_PREFIX") ?? homebrewPrefix;
path = `${homebrewPrefix}/bin:${path}`;
}

return path;
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be slower to use fs.exists(), but we could just loop an array of paths and add them if they're there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but I think it still makes sense to only search on some directories conditionally. For example, it doesn't make sense to search for /home/linuxbrew/.linuxbrew on a macOS.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's reasonably correct. if it's present, who knows what it's doing?

@mxcl mxcl merged commit 7da3fa7 into pkgxdev:main Feb 24, 2025
1 of 2 checks passed
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.

3 participants