Bun virtual environment builder
Project description
bunenv - Bun Virtual Environment
Create isolated Bun environments, similar to Python's virtualenv. Inspired by and adapted from nodeenv.
Why bunenv?
- Isolated Bun installations - Keep different Bun versions per project
- No global pollution - Install packages without affecting system Bun
- Easy version management - Switch between Bun versions effortlessly
- Python integration - Works alongside Python virtual environments
- Cross-platform - Supports macOS, Linux, and Windows
Installation
Using uv (Recommended)
uv tool install bunenv
Using pip
pip install bunenv
From source
git clone https://github.com/JacobCoffee/bunenv.git
cd bunenv
uv pip install -e .
Quick Start
Create a Bun environment
# Create environment with latest Bun
bunenv myenv
# Create with specific version
bunenv myenv --bun=1.3.3
# List available Bun versions
bunenv --list
Activate the environment
# On macOS/Linux
source myenv/bin/activate
# On Windows
myenv\Scripts\activate.bat
Use Bun
bun --version # Check version
bun init # Initialize a project
bun add express # Install packages
bun run index.ts # Run scripts
Deactivate
deactivate_bun
Usage Examples
Development Workflow
# Create project environment
bunenv .venv --bun=latest
# Activate
source .venv/bin/activate
# Your project is now using isolated Bun
bun install
bun run dev
Multiple Projects, Different Versions
# Legacy project with Bun 1.0
bunenv ~/projects/legacy/.bunenv --bun=1.0.0
cd ~/projects/legacy
source .bunenv/bin/activate
# New project with latest Bun
bunenv ~/projects/new/.bunenv --bun=latest
cd ~/projects/new
source .bunenv/bin/activate
CI/CD Integration
# GitHub Actions example
- name: Setup Bun environment
run: |
pip install bunenv
bunenv .bunenv --bun=1.3.3
source .bunenv/bin/activate
bun install
bun test
Python + Bun Projects
# Create Python virtualenv
python -m venv .venv
source .venv/bin/activate
# Install bunenv in the virtualenv
pip install bunenv
# Create Bun environment inside Python virtualenv
bunenv --python-virtualenv --bun=latest
# Now you have both Python and Bun isolated!
python --version
bun --version
Command-Line Options
Basic Options
bunenv [OPTIONS] DEST_DIR
| Option | Description |
|---|---|
DEST_DIR |
Destination directory for the environment |
--version |
Show bunenv version |
-h, --help |
Show help message |
Bun Version Options
| Option | Description |
|---|---|
--bun=VERSION |
Specify Bun version (e.g., 1.3.3, latest, system) |
--list, -l |
List all available Bun versions |
--variant=VARIANT |
Choose variant: baseline, musl, profile |
Installation Options
| Option | Description |
|---|---|
--mirror=URL |
Use alternative GitHub mirror for downloads |
--github-token=TOKEN |
GitHub API token (avoid rate limits) |
--prebuilt |
Install from prebuilt binaries (default, only option) |
--ignore_ssl_certs |
Ignore SSL certificate verification (unsafe) |
Integration Options
| Option | Description |
|---|---|
--python-virtualenv, -p |
Install into active Python virtualenv |
--requirements=FILE, -r |
Install packages from requirements file |
--clean-src, -c |
Remove downloaded files after installation |
--force |
Overwrite existing environment directory |
Customization Options
| Option | Description |
|---|---|
--prompt=PROMPT |
Custom shell prompt prefix |
--verbose, -v |
Verbose output |
--quiet, -q |
Minimal output |
--config-file=FILE, -C |
Use custom config file (default: ~/.bunenvrc) |
Configuration File
Create ~/.bunenvrc to set defaults:
[bunenv]
bun = latest
variant =
github_token = ghp_xxxxxxxxxxxxx
ignore_ssl_certs = False
You can also use .bun-version file in your project:
echo "1.3.3" > .bun-version
bunenv .venv # Will use version from .bun-version
Requirements File
Create a requirements.txt with packages to install:
# requirements.txt
express
typescript
@types/node
Install with:
bunenv myenv --requirements=requirements.txt
Platform Support
Supported Platforms
- macOS: Intel (x64) and Apple Silicon (aarch64)
- Linux: x64, aarch64, with glibc or musl (Alpine, Void)
- Windows: x64
Variants
| Variant | Description |
|---|---|
| default | Optimized for modern CPUs (Haswell/Excavator+) |
baseline |
Compatible with older CPUs (Nehalem/Bulldozer+) |
musl |
For Alpine Linux, Void Linux (auto-detected) |
profile |
Debug/profiling build |
# Auto-detect best variant
bunenv myenv
# Force baseline for old CPU
bunenv myenv --variant=baseline
# Use musl on Alpine Linux (auto-detected)
bunenv myenv # Will use musl variant automatically
Environment Variables
When activated, bunenv sets:
BUN_VIRTUAL_ENV- Path to the environmentBUN_INSTALL- Bun install directoryBUN_INSTALL_BIN- Binary installation directoryPATH- Prepended with environment's bin directory
Comparison with Other Tools
| Feature | bunenv | asdf | mise | Homebrew |
|---|---|---|---|---|
| Isolated environments | L | L | L | |
| Multiple versions simultaneously | L | |||
| Python integration | L | L | L | |
| Cross-platform | L | |||
| No shell modification needed | L | L | N/A |
Real-World Example: Byte Bot
The Byte Bot project uses Bun for frontend tooling (TailwindCSS, Biome linter) alongside Python (uv). With bunenv:
# Setup isolated environment
bunenv .bunenv --bun=latest
source .bunenv/bin/activate
# Frontend development
bun install
bun run format # Biome formatting
bun run lint # Biome linting
Troubleshooting
GitHub API Rate Limits
If you see rate limit errors:
# Create a GitHub token (read-only, public repos)
# https://github.com/settings/tokens
# Use with bunenv
bunenv myenv --github-token=ghp_xxxxx
# Or set in ~/.bunenvrc
echo "github_token = ghp_xxxxx" >> ~/.bunenvrc
Architecture Detection
On ARM systems:
# Bunenv auto-detects and uses aarch64 binaries
bunenv myenv # Uses bun-darwin-aarch64 or bun-linux-aarch64
# Fallback to x64 if needed (Rosetta on macOS)
bunenv myenv --variant=baseline
Alpine Linux / musl
# Auto-detected on Alpine/Void Linux
bunenv myenv # Automatically uses bun-linux-x64-musl
# Force musl variant
bunenv myenv --variant=musl
Development
Running Tests
# Clone repository
git clone https://github.com/JacobCoffee/bunenv.git
cd bunenv
# Install development dependencies
uv sync
# Run tests
uv run pytest
# Run linter
uv run ruff check
Building Documentation
# Install docs dependencies
uv sync --group docs
# Build docs
cd docs
uv run make html
Differences from nodeenv
Bunenv is adapted from the excellent nodeenv project. Key differences:
| Feature | nodeenv | bunenv |
|---|---|---|
| Runtime | Node.js | Bun |
| Package Manager | npm (separate) | Built-in |
| Distribution | nodejs.org | GitHub Releases |
| Source builds | Supported | Not available |
| LTS versions | Yes | Not yet |
| Version API | index.json | GitHub Releases API |
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
See CONTRIBUTING.md for details.
License
BSD-3-Clause License. See LICENSE for details.
Based on nodeenv by Eugene Kalinin.
Acknowledgments
- Eugene Kalinin - Original nodeenv author
- Oven.sh - Bun runtime creators
- All contributors to nodeenv and bunenv
Links
- GitHub: https://github.com/JacobCoffee/bunenv
- PyPI: https://pypi.org/project/bunenv/
- Documentation: https://bunenv.readthedocs.io/
- Bun: https://bun.sh
- nodeenv: https://github.com/ekalinin/nodeenv
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bunenv-0.1.0.tar.gz.
File metadata
- Download URL: bunenv-0.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c2b6280dce68abcf6081c24119870152cf50d5dfcf57f17ce1666302d9c7919
|
|
| MD5 |
c95b7df7e5519734c435fae6619db02e
|
|
| BLAKE2b-256 |
286d9ac15a847c5f878dcc5c5cc19d47154bff5ea02083864faf1dbdb388d296
|
Provenance
The following attestation bundles were made for bunenv-0.1.0.tar.gz:
Publisher:
publish.yml on JacobCoffee/bunenv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bunenv-0.1.0.tar.gz -
Subject digest:
8c2b6280dce68abcf6081c24119870152cf50d5dfcf57f17ce1666302d9c7919 - Sigstore transparency entry: 718886620
- Sigstore integration time:
-
Permalink:
JacobCoffee/bunenv@1cdc97bd1df2d097ada2cf4c3cf3d6effccee416 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/JacobCoffee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1cdc97bd1df2d097ada2cf4c3cf3d6effccee416 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bunenv-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bunenv-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee1b5b1bb2116b142aa7ccfb9a6ee1c1c9a12124c2e79ad80efdb0819c58b3b2
|
|
| MD5 |
0c24c9d82df870395f39d38e2e3a1c1a
|
|
| BLAKE2b-256 |
7d7168b53bb174d1eee7278d3bff609b1f9a8ba7b74191cbbdabe4ec08dbeeb8
|
Provenance
The following attestation bundles were made for bunenv-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on JacobCoffee/bunenv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bunenv-0.1.0-py3-none-any.whl -
Subject digest:
ee1b5b1bb2116b142aa7ccfb9a6ee1c1c9a12124c2e79ad80efdb0819c58b3b2 - Sigstore transparency entry: 718886624
- Sigstore integration time:
-
Permalink:
JacobCoffee/bunenv@1cdc97bd1df2d097ada2cf4c3cf3d6effccee416 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/JacobCoffee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1cdc97bd1df2d097ada2cf4c3cf3d6effccee416 -
Trigger Event:
release
-
Statement type: