Closed fredrikaverpil closed 7 months ago
Based on the information you've provided, it seems like the issue might be related to how the environment variables, including PATH, are managed and passed around within the pkgx
tool or how linuxbrew configures its environment. However, without more specific details on how pkgx
interacts with system utilities or how it's supposed to handle dependencies like unzip
, it's challenging to pinpoint the exact cause of the failure.
pkgx
does have specific configurations for the PATH. It mentions installing and uninstalling stubs to PATH in the modes section:
install <pkg…>
: installs stubs to PATHuninstall <pkg…>
: uninstall stubs
You can find more details in the src/modes/help.ts file.The pkgx
codebase handles the installation process on different platforms, including WSL (Ubuntu) using Linuxbrew, by employing a series of GitHub Actions workflows that compile the code, prepare the environment, and test the installation and functionality of pkgx
across different shell environments (bash, zsh, POSIX). The workflows are defined in the .github/workflows/ci.shellcode.yml file.
pkgx
handles system utilities like unzip
during the installation process by resolving the command or utility name to a package requirement and then executing the command with the resolved environment. This process involves several steps, as outlined in the provided code from src/modes/x.ts
:
Resolving the Command or Utility Name: The function find_arg0
is used to resolve the initial argument (arg0
) to a package if possible. This involves checking if the argument matches a known package or utility and then preparing it for execution. If the argument ends with @latest
, it indicates that the latest version of the package should be used, and this is handled accordingly.
Handling System Utilities Directly: The code includes a specific check for the open
command on Darwin (macOS) platforms, directly resolving it to /usr/bin/open
followed by the remaining arguments. This indicates that for certain well-known system utilities, pkgx
can bypass the package resolution process and directly execute the utility.
Execution Environment Construction: Once the package requirements are resolved, pkgx
constructs the execution environment using construct_env
. This involves setting up the environment variables and paths required for the execution of the package or utility.
Executing the Command: Finally, the resolved command or utility is executed using the exec
function from _internals
, which is an alias for execve
. This function takes the command to execute and the constructed environment, performing the actual execution of the utility or package command.
You can find more details in the src/modes/x.ts file.
Without access to this additional information or specific error handling related to unzip
within the pkgx
codebase, it's not possible to provide a definitive answer based on the provided context. Could you provide more details about your environment setup and the exact steps you took before encountering the error? This would help in identifying the root cause of the issue.
Hm. Within pkgx, this is handled by
runtime:
env:
DENO_NO_UPDATE_CHECK: 'true'
DENORT_BIN: '{{prefix}}/bin/denort'
It's a peculiar consequence of the deno compiled runtime changes made in 1.39.1. I definitely agree that it should have detected your existing unzip
install, which would make depending on unzip in homebrew one solution. I'll play around with it, and see if I can't inject the correct environment variable in the Homebrew formula.
@fredrikaverpil , I can confirm https://github.com/pkgxdev/homebrew-made/commit/1733eb9363f748d470752924ee0ed4e94c9d0bac lets me install in a clean debian:buster-slim docker image without unzip
installed explicitly.
$ apt-get update && apt-get install -y curl git psutils
...
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
...
$ (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /root/.bashrc
$ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
$ brew install pkgxdev/made/pkgx
...
==> Installing pkgxdev/made/pkgx
==> deno task compile
==> Caveats
try it out:
pkgx node@18 --eval 'console.log("pkgx: run anything")'
shell integration:
pkgx integrate --dry-run
# ^^ https://docs.pkgx.sh/shell-integration
==> Summary
🍺 /home/linuxbrew/.linuxbrew/Cellar/pkgx/1.1.6: 5 files, 89.1MB, built in 9 seconds
==> Running `brew cleanup pkgx`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> pkgx
try it out:
pkgx node@18 --eval 'console.log("pkgx: run anything")'
shell integration:
pkgx integrate --dry-run
# ^^ https://docs.pkgx.sh/shell-integration
are you able to confirm the install works (you might need to brew update
, or brew untap pkgxdev/made/pkgx
to get it to refresh), without unzip
from the OS package manager?
Very nice, I can confirm that you fixed this. 🎉
❯ brew uninstall pkgx
Uninstalling /home/linuxbrew/.linuxbrew/Cellar/pkgx/1.1.6... (5 files, 89.1MB)
❯ brew untap pkgxdev/made
Untapping pkgxdev/made...
Untapped 1 formula (48 files, 256KB).
❯ sudo apt-get remove unzip
[sudo] password for fredrik:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libntfs-3g89
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
unzip
0 upgraded, 0 newly installed, 1 to remove and 33 not upgraded.
After this operation, 385 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 78723 files and directories currently installed.)
Removing unzip (6.0-26ubuntu3.1) ...
Processing triggers for man-db (2.10.2-1) ...
❯ brew tap pkgxdev/made
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 5 taps (go-task/tap, homebrew/bundle, homebrew/linux-fonts, homebrew/core and homebrew/cask).
==> New Formulae
liblc3 msieve rage rustcat
==> New Casks
ente-auth outfox toneprint viable
You have 3 outdated formulae installed.
==> Tapping pkgxdev/made
Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/pkgxdev/homebrew-made'...
remote: Enumerating objects: 366, done.
remote: Counting objects: 100% (185/185), done.
remote: Compressing objects: 100% (81/81), done.
remote: Total 366 (delta 106), reused 169 (delta 93), pack-reused 181
Receiving objects: 100% (366/366), 61.82 KiB | 1.31 MiB/s, done.
Resolving deltas: 100% (207/207), done.
Tapped 1 formula (19 files, 179KB).
❯ brew install pkgx
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Fetching pkgxdev/made/pkgx
==> Downloading https://github.com/pkgxdev/pkgx/releases/download/v1.1.6/pkgx-1.1.6.tar.xz
Already downloaded: /home/fredrik/.cache/Homebrew/downloads/c8b2441dfddcbd6b0ef34fb1621836e46340e44576acd184a9e0bca2a45121cd--pkgx-1.1.6.tar.xz
==> Installing pkgx from pkgxdev/made
==> deno task compile
==> Caveats
try it out:
pkgx node@18 --eval 'console.log("pkgx: run anything")'
shell integration:
pkgx integrate --dry-run
# ^^ https://docs.pkgx.sh/shell-integration
==> Summary
🍺 /home/linuxbrew/.linuxbrew/Cellar/pkgx/1.1.6: 5 files, 89.1MB, built in 14 seconds
==> Running `brew cleanup pkgx`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Problem description
I just noticed, that while on WSL (Ubuntu) and using linuxbrew, running
brew install pkgx
yields the following error, so I figured I'd report it here:However, I have
unzip
installed:Solution / workaround
A
sudo apt install unzip
solved it, but I think maybe this should've worked sinceunzip
was already on$PATH
.Feel free to close this issue anytime, as I just wanted to bring attention to this - along with the workaround.