Thanks to visit codestin.com
Credit goes to github.com

Skip to content

metanorma/mnenv

Repository files navigation

mnenv

RubyGems Version License Build

Version manager for Metanorma, similar to rbenv/pyenv.

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 mnenv

From source

git clone https://github.com/metanorma/mnenv.git
cd mnenv
bundle install
bundle exec rake install

Shell 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 $PATH

PowerShell (Windows)

Add to your PowerShell profile:

$env:PATH = "$env:USERPROFILE\.mnenv\shims;$env:PATH"

Usage

List available versions

mnenv install --list
# or
mnenv install -l

Shows 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 --list

List installed versions

mnenv versions

Set 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.4

Uninstall a version

mnenv uninstall 1.14.4

# Force uninstall without confirmation
mnenv uninstall 1.14.4 --force

Show mnenv version

mnenv version

Update version data

# Update version data from metanorma/versions repository
mnenv update

Version Sources

mnenv supports two installation sources:

Source Description

gemfile

RubyGems installation using Gemfile. Requires development tools (Ruby, bundler). Faster startup with lazy loading.

binary

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:

  1. METANORMA_VERSION environment variable

  2. .metanorma-version file in current directory (and parent directories)

  3. ~/.mnenv/version file (global version)

The source is resolved similarly:

  1. METANORMA_SOURCE environment variable

  2. .metanorma-source file in current directory (and parent directories)

  3. ~/.mnenv/source file (global source)

  4. 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 file

Architecture

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 version

Development

Running tests

bundle exec rake spec

Or with RSpec directly:

bundle exec rspec

Code quality

# Run Rubocop
bundle exec rubocop

# Auto-correct issues
bundle exec rubocop -A

Contributing

  1. Fork the repository

  2. Create your feature branch (git checkout -b my-amazing-feature)

  3. Commit your changes (git commit -am 'Add some amazing feature')

  4. Push to the branch (git push origin my-amazing-feature)

  5. Open a Pull Request

License

This project is available as open source under the terms of the MIT License.

Copyright (c) 2025 Ribose Inc.

About

Command-line tool to switch between Metanorma versions

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •