
pkgx is a 4 MiB, standalone binary that can run anything.
Quickstart
|| |
Run Anything
> ^D
# ^^ nothing was installed; your wider system is untouched
Run Any Version of Anything
Run Anywhere
- macOS >= 11
- 64 bit Intel & Apple Silicon
- glibc >=2.28 repology
x86_64&arm64
WSL2; x86-64. Native windows is planned.
We provide an image with pkgx in it:
()
>
You can use this image to try out (pretty much) any version of any program:
Or in a Dockerfile:
FROM pkgxdev/pkgx
RUN pkgx deno@1.35 task start
Or in any image:
FROM ubuntu
RUN curl https://pkgx.sh | sh
RUN pkgx python@3.10 -m http.server 8000
- uses: pkgxdev/setup@v3
- run: pkgx shellcheck
Or in other CI/CD providers:
|
#!/usr/bin/env -S pkgx +git python@3.12
# python 3.12 runs the script and `git` is available during its execution
Use dev; a separate tool that uses the pkgx primitives to
automatically determine and utilize your dependencies based on your
project’s keyfiles.
The pkgx Ecosystem
pkgx is not just a package runner, it’s a composable primitive that can be
used to build a whole ecosystem of tools.
dev
dev uses pkgx and shellcode to create “virtual environments” consisting
of the specific versions of tools and their dependencies you need for your
projects.
&&
#…
pkgm
pkgm installs pkgx packages to /usr/local. It installs alongside pkgx.
Scripting
A powerful use of pkgx is scripting, eg. here’s a script to release new
versions to GitHub:
#!/usr/bin/env -S pkgx +gum +gh +npx +git bash>=4 -eo pipefail
versions=""
v_latest=""
v_new=
Above you can see how we “loaded” the shebang with +pkg syntax to bring in
all the tools we needed.
We have pretty advanced versions of the above script, eg teaBASE
There’s tools for just about every language ecosystem so you can import
dependencies. For example, here we use uv to run a python script with
pypi dependencies, and pkgx to load both uv and a specific python version:
#!/usr/bin/env -S pkgx +python@3.11 uv run
# /// script
# dependencies = [
# "requests<3",
# "rich",
# ]
# ///
)
)
) for))
[!TIP]
Mash
We love scripting with
pkgxso much that we made a whole package manager for scripts to show the world what is possible when the whole open source ecosystem is available to your scripts Check it outmash.
[!NOTE]
Notably, packages used during your script aren’t installed and don’t pollute your system and anyone else’s systems either. Don’t be confused— they are downloaded to
~/.pkgxbut the wider system is not touched.
Recursive Run
Easily run tools from other language ecosystems:
Magic
It can be fun to add magic to your shell:
# add to ~/.zshrc
Thus if you type gh and it’s not installed pkgx will magically run it as
though it was installed all along.
[!NOTE] Bash is the same function but drop the
rfrom the end of the name.
Further Reading
docs.pkgx.sh is a comprehensive manual and user guide for the pkgx
suite.
Migrating from pkgx^1
Shellcode
The pkgx suite has had its scopes tightened. There is no shellcode in pkgx
anymore. Instead dev is its own separate tool that has its own shellcode.
Migrate your shell configuration with:
env +foo
If you used this, let us know, we can make a mash script to provide this
functionality again. You can achieve the same result as eg. env +git with:
Surround the eval with set -a and set +a if you need the environment
exported.
pkgx install
We now provide pkgm but if you miss the leanness of “stubs” we
provide a mash script to create stubs in /usr/local/bin:
#!/bin/sh
Contributing
We recommend using dev to make rust available.
- To add packages see the pantry README
- To hack on
pkgxitself; clone it andcargo buildhydrate.rsis where optimization efforts will bear most fruit
Pre-PR Linting
Chat / Support / Questions
We love a good chinwag.