Shim Creation
Launchpad provides a powerful shim creation system that makes package executables available across your system without modifying the global environment.
What are Shims?
Shims are lightweight executable scripts that point to the actual binaries. When you run a shim, it transparently forwards the command to the actual binary, along with any arguments you provide.
Benefits of using shims:
- Run commands from anywhere without modifying your PATH for each package
- Use specific versions of tools without conflicts
- Easy clean-up and management
Creating Shims
To create shims for a package:
# Create shims for all executables in a package
launchpad shim node
# Create shims for multiple packages
launchpad shim python go typescript
Shim Location
By default, shims are created in ~/.local/bin
. You can specify a different location:
launchpad shim --path ~/bin node
Or set a default location in your configuration:
{
"shimPath": "~/bin"
}
How Shims Work
When you create a shim for a package, Launchpad:
- Queries pkgx for information about the package
- Locates all executable files in the package's
bin
directory - Creates a lightweight script for each executable in your shim directory
- Makes these scripts executable
- Optionally adds the shim directory to your PATH
The generated shim looks like this:
#!/usr/bin/env -S pkgx -q! node@22.12.0
This tells your system to use pkgx to run the specific version of the package.
PATH Integration
For shims to work, the shim directory must be in your PATH. Launchpad can automatically add the shim directory to your PATH by modifying your shell configuration file:
# Launchpad will add the shim directory to your PATH automatically
launchpad shim node
If you don't want automatic PATH modifications:
launchpad shim --no-auto-path node
Or disable it in your configuration:
{
"autoAddToPath": false
}
Force Recreation
To recreate existing shims:
launchpad shim --force node
Shell Configuration Files
When adding to PATH, Launchpad looks for these files (in order):
~/.zshrc
(if using Zsh)~/.bashrc
(if using Bash)~/.bash_profile
(if using Bash and .bashrc doesn't exist)
Windows Support
On Windows, Launchpad cannot directly modify the PATH. Instead, it provides instructions for adding the shim directory to your PATH:
[System.Environment]::SetEnvironmentVariable('PATH', $env:PATH + ';C:\path\to\shims', [System.EnvironmentVariableTarget]::Machine)
Verification
After creating shims, you can verify they're working:
# Check if a shim is available
which node
# Should output something like:
# /home/user/.local/bin/node