mnenv
Purpose
mnenv is a version manager for Metanorma that allows you to:
-
Install and manage multiple Metanorma versions
-
Switch between versions globally, per-project, or per-shell session
-
Install from multiple sources: RubyGems (gemfile) or pre-built binaries
Version data is sourced from the metanorma/versions repository.
Features
-
Multiple Installation Sources - Install from RubyGems (gemfile) or pre-built binaries
-
Version Switching - Switch versions globally, per-project, or per-shell session
-
Shell Integration - Automatic PATH management via shims
-
Cross-Platform - Works on Linux, macOS, and Windows
-
Offline Capable - Version data cached locally for fast operation
Installation
As a Ruby gem
gem install mnenvFrom source
git clone https://github.com/metanorma/mnenv.git
cd mnenv
bundle install
bundle exec rake installShell setup
After installation, add mnenv shims to your PATH:
Bash
Add to ~/.bashrc:
export PATH="$HOME/.mnenv/shims:$PATH"Zsh
Add to ~/.zshrc:
export PATH="$HOME/.mnenv/shims:$PATH"Fish
Add to ~/.config/fish/config.fish:
set -gx PATH $HOME/.mnenv/shims $PATHPowerShell (Windows)
Add to your PowerShell profile:
$env:PATH = "$env:USERPROFILE\.mnenv\shims;$env:PATH"Usage
List available versions
mnenv install --list
# or
mnenv install -lShows all available Metanorma versions with platform availability:
Available Metanorma versions: (gemfile = source build, binary = prebuilt for specific platforms) 1.14.4 (gemfile, binary [linux, macos*, windows]) 1.14.3 (gemfile, binary [linux, macos*, windows]) 1.14.1 (binary [linux, macos*]) ... Legend: * Current version / platform [installed: ...] = Already installed locally Detected platform: macos
Install a version
# Install from gemfile (source build, requires dev tools)
mnenv install 1.14.4 --source gemfile
# Install from binary (pre-built, no dev tools needed)
mnenv install 1.14.4 --source binary
# Interactive installation
mnenv install -i
# List versions before installing
mnenv install --listList installed versions
mnenv versionsSet version
# Set global version (affects all projects)
mnenv global 1.14.4
# Set global version with source
mnenv global 1.14.4 --source binary
# Set local version (affects current directory)
mnenv local 1.14.4
# Set shell version (affects current shell session only)
mnenv use 1.14.4Uninstall a version
mnenv uninstall 1.14.4
# Force uninstall without confirmation
mnenv uninstall 1.14.4 --forceShow mnenv version
mnenv versionUpdate version data
# Update version data from metanorma/versions repository
mnenv updateVersion Sources
mnenv supports two installation sources:
| Source | Description |
|---|---|
|
RubyGems installation using Gemfile. Requires development tools (Ruby, bundler). Faster startup with lazy loading. |
|
Pre-compiled binaries from packed-mn releases. No development tools required. Full memory load at startup. |
Version Resolution
mnenv resolves the active version in the following order:
-
METANORMA_VERSIONenvironment variable -
.metanorma-versionfile in current directory (and parent directories) -
~/.mnenv/versionfile (global version)
The source is resolved similarly:
-
METANORMA_SOURCEenvironment variable -
.metanorma-sourcefile in current directory (and parent directories) -
~/.mnenv/sourcefile (global source) -
Default:
gemfile
Directory Structure
~/.mnenv/
├── versions/ # Version data (cloned from metanorma/versions)
│ └── data/
│ ├── gemfile/versions.yaml
│ ├── binary/versions.yaml
│ └── ...
├── installed/ # Installed Metanorma versions
│ └── 1.14.4/
│ ├── bin/metanorma # (gemfile source)
│ ├── metanorma # (binary source)
│ └── source # Records installation source
├── shims/ # Shim executables
│ └── metanorma
├── version # Global version file
└── source # Global source fileArchitecture
mnenv follows a model-driven architecture:
mnenv
├── Cli # Thor CLI entry point
├── Commands/
│ ├── InstallCommand # Install versions
│ ├── VersionCommand # Version switching (global, local, use, versions)
│ └── UninstallCommand # Uninstall versions
├── Installers/
│ ├── Base # Abstract installer
│ ├── BinaryInstaller # Binary installation (downloads, extracts)
│ └── GemfileInstaller # Gemfile-based installation
├── Shells/
│ ├── Base # Abstract shell
│ ├── Bash # Unix shells (bash, zsh, sh)
│ ├── PowerShell # Windows PowerShell
│ └── Cmd # Windows CMD
├── Repositories/
│ ├── GemfileRepository # RubyGems version data
│ ├── BinaryRepository # Binary version data
│ └── ...
├── ShimManager # Shim generation
├── VersionsManager # Version data management
└── Models/
├── ArtifactVersion # Base version model
├── GemfileVersion # RubyGems version
└── BinaryVersion # Binary versionDevelopment
Running tests
bundle exec rake specOr with RSpec directly:
bundle exec rspecCode quality
# Run Rubocop
bundle exec rubocop
# Auto-correct issues
bundle exec rubocop -AContributing
-
Fork the repository
-
Create your feature branch (
git checkout -b my-amazing-feature) -
Commit your changes (
git commit -am 'Add some amazing feature') -
Push to the branch (
git push origin my-amazing-feature) -
Open a Pull Request
License
This project is available as open source under the terms of the MIT License.
Copyright
Copyright (c) 2025 Ribose Inc.