A version manager for Bun JavaScript runtime, inspired by tools like rbenv and nvm.
- 🚀 Install and manage multiple Bun versions
 - 🔄 Switch between versions globally or per project
 - 🔍 Automatic version detection using 
.bun-versionfiles - 🛠️ Shell integration for seamless version switching
 - 🐚 Support for bash, zsh, and fish shells
 - 🍺 Homebrew installation support
 
The project is now ready for initial release with all core functionality in place:
- ✅ Core modules: Version resolver, Path utilities, and Configuration
 - ✅ Version manager: Installation, listing, and management of Bun versions
 - ✅ Shim generator: Creation and management of shims for version switching
 - ✅ CLI Commands: All commands are implemented and working
 - ✅ Testing: Unit tests passing, direct function tests implemented, integration tests in progress
 - ✅ Documentation: Comprehensive documentation with guides and examples
 - ✅ Distribution: npm packaging and CI/CD workflows configured
 
- Ongoing testing improvements
 - Community feedback and bug fixes
 - Additional features based on user needs
 
- Shell Integration Guide - Detailed guide on setting up and troubleshooting shell integration
 
- Project-Specific Version Management - How to manage Bun versions per project
 - Global Version Management - Setting up and working with global Bun versions
 - Temporary Version Switching - Temporarily using different Bun versions
 
- Node.js 16+ or Bun
 - UNIX-like operating system (macOS, Linux) or Windows with WSL
 
The easiest way to install bunenv on macOS or Linux is via Homebrew:
# Install bunenv via Homebrew
brew install jonathanphilippou/tap/bunenv
# Verify the installation
bunenv --versionAlternatively, you can install bunenv using our installer script:
# Using curl
curl -o- https://raw.githubusercontent.com/jonathanphilippou/bunenv/main/install.sh | bash
# Or using wget
wget -qO- https://raw.githubusercontent.com/jonathanphilippou/bunenv/main/install.sh | bashThis script will install bunenv and set up shell integration automatically.
npm install -g bunenv
# Then set up shell integration
bunenv init >> ~/.bashrc  # or your appropriate shell config file
source ~/.bashrcbun install -g bunenv
# Then set up shell integration
bunenv init >> ~/.bashrc  # or your appropriate shell config file
source ~/.bashrc- Clone the repository:
 
git clone https://github.com/jonathanphilippou/bunenv.git
cd bunenv- Install dependencies:
 
npm install
# or if you have Bun installed
bun install- Build the project:
 
npm run build
# or
bun run build- Link the binary:
 
npm link
# or
bun link- Set up shell integration:
 
bunenv init >> ~/.bashrc
# Or for zsh
bunenv init --shell zsh >> ~/.zshrc
# Or for fish
bunenv init --shell fish >> ~/.config/fish/conf.d/bunenv.fish- Restart your shell or source the configuration file:
 
source ~/.bashrc
# Or for zsh
source ~/.zshrc# Install a specific version
bunenv install 1.0.0
# List installed versions
bunenv list# Set the global Bun version
bunenv global 1.0.0
# View current global version
bunenv global# Set the local Bun version for the current directory
bunenv local 1.0.0
# View current local version
bunenv local# Spawn a new shell with a specific Bun version
bunenv shell 1.0.0Install a specific version of Bun.
Options:
-f, --force: Force reinstall if the version is already installed
List all installed Bun versions.
Aliases: ls
Options:
-a, --all: Show all versions, including system installations
Set or show the global Bun version.
Set or show the local Bun version for the current directory.
Spawn a new shell using the specified Bun version.
Show the current active Bun version.
Options:
-v, --verbose: Show detailed version information
Rebuild Bun shim executables.
Configure shell integration for bunenv.
Options:
-s, --shell <type>: Specify shell type (bash, zsh, fish)
bunenv works by creating a directory of shims, which map to the commands for the selected Bun version. When you run a shim, bunenv determines which Bun version to use by checking:
- The 
BUNENV_VERSIONenvironment variable - A 
.bun-versionfile in the current or parent directories - The global Bun version set with 
bunenv global 
The version resolution follows this priority order:
- The 
BUNENV_VERSIONenvironment variable - The 
.bun-versionfile in the current directory - The 
.bun-versionfile in parent directories (searching up to root) - The global version set with 
bunenv global 
$HOME/.bunenv/
├── versions/         # Bun versions
│   ├── 1.0.0/
│   │   └── bin/
│   │       └── bun
│   └── 1.0.1/
│       └── bin/
│           └── bun
├── shims/            # Command shims
├── version           # Global version file
└── .bun-version      # Local version file (in project directories)
git clone https://github.com/yourusername/bunenv.git
cd bunenv
bun installbun test          # Run all tests
bun test:unit     # Run unit tests
bun test:component # Run component tests
bun test:integration # Run integration testsbun run buildThe project is structured into several key modules:
src/core/- Core utilities (paths, config, environment)src/resolvers/- Version resolution logicsrc/versions/- Version management and installationsrc/shims/- Shim generation and managementsrc/cli/- CLI commands and utilitiessrc/utils/- Shared utility functions
We follow a test pyramid approach:
- Unit Tests: Test individual functions in isolation
 - Component Tests: Test interactions between modules
 - Integration Tests: Test end-to-end functionality
 
We welcome contributions of all kinds! Whether you're fixing bugs, adding features, or improving documentation, your help is appreciated.
- Fork the repository
 - Clone your fork: 
git clone https://github.com/yourusername/bunenv.git - Install dependencies: 
bun install - Create a branch for your contribution: 
git checkout -b my-feature-branch 
- Make your changes
 - Run tests: 
bun test - Format your code: 
bun run format - Commit your changes following conventional commits
 - Push to your fork and submit a pull request
 
If you're working on improving the Homebrew integration:
- Read the Homebrew documentation to understand the current implementation
 - Test any changes locally with 
brew install --build-from-source ./homebrew/bunenv.rb - Update the formula using the automated script: 
bun homebrew:update 
- Follow TypeScript best practices
 - Write tests for new functionality
 - Document your code with JSDoc comments
 - Keep commits focused and descriptive
 
When adding or changing features, please update the relevant documentation:
- README.md for general usage information
 - Specific documentation files in the 
docs/directory 
For detailed information on specific topics, check out these resources:
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by rbenv and nvm
 - Built with TypeScript and Bun
 - Thanks to all contributors
 
npm install -g bunenv
bun install -g bunenv
Diagram:
+---------------------------------------------+
|                   User                      |
+----------------------+----------------------+
                       |
                       | (runs command: e.g., bun --version)
                       v
+---------------------------------------------+
|                 PATH lookup                 |
|   (~/.bunenv/shims takes precedence)        |
+----------------------+----------------------+
                       |
                       | (finds shim first)
                       v
+---------------------------------------------+
|               ~/.bunenv/shims/bun           |  <---- Shim Script (Bash)
|                                             |       Intercepts all 'bun' calls
+----------------------+----------------------+
                       |
                       | (looks for version)
                       v
+---------------------/ \---------------------+
|  Version Resolution Process                 |
|                                             |
|  1. Check BUNENV_VERSION env var            |
|  2. Look for .bun-version file (local)      |
|  3. Check package.json engines.bun          |
|  4. Check ~/.bunenv/version (global)        |
|                                             |
+----------------------+----------------------+
                       |
                       | (selects version)
                       v
+---------------------------------------------+
|      ~/.bunenv/versions/{version}/bin/bun   |  <---- Actual bun binary
+---------------------------------------------+
          |                        |
          v                        v
+-------------------+   +----------------------+
| bunenv CLI Tool   |   | User's Bun Commands  |
| (bunenv install)  |   | (managed by version) |
+-------------------+   +----------------------+
+---------------------------------------------+
|            Core Components                  |
+---------------------------------------------+
|                                             |
|  ~/.bunenv/                                 |
|  ├── shims/                                 |
|  │   └── bun           (shim executable)    |
|  ├── versions/                              |
|  │   ├── 1.0.0/        (installed version)  |
|  │   │   └── bin/                           |
|  │   │       └── bun   (actual executable)  |
|  │   └── 1.0.22/       (another version)    |
|  │       └── bin/                           |
|  │           └── bun                        |
|  └── version           (global version file)|
|                                             |
+---------------------------------------------+
+--------------+       +--------------------+
| bunenv CLI   | <---> | Version Management |
|              |       | (install/list/etc) |
+--------------+       +--------------------+
       |
       v
+-------------------------------+
| Commands:                     |
| - bunenv install <version>    |
| - bunenv global <version>     |
| - bunenv local <version>      |
| - bunenv rehash               |
| - bunenv list                 |
| - bunenv version              |
| - bunenv shell <version>      |
| - bunenv init                 |
+-------------------------------+