macOS NIM-MACOS-INSTALLMedium

Installing Nim Language on macOS (via choosenim and Homebrew)

Install Nim on macOS using choosenim or Homebrew, check compilation, set up the environment, and install packages via Nimble.

Updated at February 13, 2026
15-45 min
Medium
FixPedia Team
Применимо к:macOS 12 MontereymacOS 13 VenturamacOS 14 SonomamacOS 15 Sequoia

Installing Nim Language on macOS

This guide describes two main ways to install Nim on macOS:

  • Through choosenim (recommended): convenient version management for Nim, installation in the user's home directory.
  • Through Homebrew: installation as a brew package (suitable for those who standardize their environment through brew).

We will also cover setting up PATH, checking compilation, and basic usage of nimble.


Prerequisites

1) Install Xcode Command Line Tools

Nim uses the system C/C++ compiler (usually clang) to build the final binaries.

xcode-select --install

Check:

clang --version
make --version

If the installation window does not appear, the tools may already be installed. Check the path:

xcode-select -p

choosenim is the official installer/version manager for Nim.

1) Install choosenim

curl https://nim-lang.org/choosenim/init.sh -sSf | sh

The script will:

  • download choosenim,
  • install Nim (usually stable),
  • may suggest adding a line to your shell config (e.g., ~/.zshrc) for PATH.

2) Restart the terminal or apply the settings

If the installer added changes to ~/.zshrc, apply them:

source ~/.zshrc

3) Check Nim and Nimble versions

nim --version
nimble --version

4) Useful choosenim commands

Show the current version:

choosenim show

Update to the latest stable version:

choosenim update stable

Install a specific version (example):

choosenim 2.2.0

Method 2: Installing Nim via Homebrew

This option is convenient if you prefer to manage development tools through brew.

1) Install Homebrew (if not already installed)

If Homebrew is missing, use our guide:

  • /guides/macos/install-homebrew-on-macos

Quick check:

brew --version

2) Install Nim

brew update
brew install nim

3) Check the installation

nim --version
nimble --version

Note: when installing via Homebrew, updating Nim is done through brew upgrade nim.


Setting up PATH (if nim is not found)

1) Diagnosis

Check if the system sees nim:

which nim
echo $SHELL

If which nim returns nothing, the path to Nim is likely not added to PATH.

2) zsh (default on macOS)

Open ~/.zshrc:

nano ~/.zshrc

For installation via choosenim, Nim is often located in ~/.nimble/bin. Add the line:

export PATH="$HOME/.nimble/bin:$PATH"

Apply:

source ~/.zshrc

Check:

which nim
nim --version

3) bash (if you are using bash)

Open ~/.bash_profile or ~/.bashrc and add:

export PATH="$HOME/.nimble/bin:$PATH"

Then:

source ~/.bash_profile 2>/dev/null || source ~/.bashrc

Check: Compile and Run a Program

Create a file hello.nim:

echo "Hello from Nim on macOS"

Compile and run:

nim c -r hello.nim

The expected result is the output of the string in the terminal.


Installing Packages via Nimble

nimble is the package manager for Nim.

1) Search for a package

nimble search json

2) Install a package

Example (the package is conditional — use a real one from the search results):

nimble install somepackage

3) Update installed packages

nimble refresh
nimble update

Common Issues and Solutions

Error: clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=...'

Usually related to environment variables or incompatible SDK settings.

What to do:

  1. Check the variable value:
    echo $MACOSX_DEPLOYMENT_TARGET
    
  2. Temporarily unset and rebuild:
    unset MACOSX_DEPLOYMENT_TARGET
    nim c hello.nim
    

Error: xcrun: error: invalid active developer path

Command Line Tools are incorrectly installed or removed after upgrading macOS.

Solution:

sudo xcode-select --reset
xcode-select --install

Error: Permission denied when installing packages

If you installed Nim in system directories or changed permissions.

Recommended approach:

  • use choosenim (installation in the home directory),
  • do not run nimble install with sudo unless absolutely necessary.

What Next

  • Set up your editor (e.g., VS Code) and install the Nim extension.
  • Familiarize yourself with the Nim documentation and standard library.
  • For projects, use nimble init (to create a package/project structure).

F.A.Q.

What to choose: choosenim or Homebrew?
Is Xcode needed in full?
Why is the command `nim` not found after installation?
Can Nim be used with Apple Silicon (M1/M2/M3)?

Hints

Install Xcode Command Line Tools
Install Nim via choosenim (recommended)
Check Nim Installation
Compile a Test Program
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community