Linux

Installing and Configuring Nim on Linux: A Complete Guide

This guide will walk you through installing Nim using choosenim, configuring your code editor, and creating your first application. After completion, you'll have a ready-to-use development environment for Nim.

Updated at February 14, 2026
15-20 min
Easy
FixPedia Team
Применимо к:Ubuntu 20.04+Fedora 35+Debian 11+Arch LinuxNim 2.0+

Introduction / Why This Is Needed

Nim is a statically typed, compiled programming language that combines Python's expressiveness with C's performance. It is ideal for systems programming, web servers, games, and embedded systems.

After completing this guide, you will be able to:

  • Compile and run Nim programs from the terminal.
  • Use the nimble package manager.
  • Develop in VS Code with syntax highlighting and autocompletion.
  • Create and manage Nim projects.

This guide is intended for Nim beginners but requires basic familiarity with the Linux terminal.

Prerequisites / Preparation

Before you begin, ensure:

  1. You have access to a Linux terminal (Ubuntu, Fedora, Debian, Arch, or another distribution).
  2. Basic build tools are installed:
    • Ubuntu/Debian: sudo apt update && sudo apt install build-essential curl
    • Fedora: sudo dnf groupinstall "Development Tools" && sudo dnf install curl
    • Arch: sudo pacman -S base-devel curl
  3. You have write permissions in your home directory (~).

If you plan to use VS Code, download it from the official website or install it via your distribution's package manager.

Step 1: Install the choosenim Script

Choosenim is the official Nim installation and version management script. It downloads the compiler, configures paths, and allows easy switching between versions.

  1. Open your terminal.
  2. Run the command to download and execute the script:
curl https://nim-lang.org/choosenim/init.sh -sSf | sh
  1. The script will propose installing choosenim to ~/.choosenim. Press Enter to confirm or type y.
  2. After completion, you will see a success message.

⚠️ Important: If curl is not installed, install it first: sudo apt install curl (Ubuntu/Debian) or sudo dnf install curl (Fedora).

Step 2: Install the Nim Compiler

Now that choosenim is installed, use it to install the latest stable version of Nim:

~/.choosenim/bin/choosenim stable

The command:

  • Downloads Nim binaries (compiler, standard library).
  • Installs them to ~/.nimble.
  • Automatically configures environment variables.

The process may take a few minutes depending on your internet speed.

After completion, check the version:

nim --version

The output should look similar to:

Nim Compiler Version 2.0.0 [Linux: amd64]
Compiled with '--cc:gcc' for Linux/amd64

Step 3: Configure the PATH Environment Variable

To make the nim and nimble commands available from anywhere, you need to add the ~/.nimble/bin path to your PATH variable.

  1. Identify which shell you are using:
    • Bash: file ~/.bashrc
    • Zsh: file ~/.zshrc
    • Fish: file ~/.config/fish/config.fish
  2. Open the corresponding file in a text editor (e.g., nano ~/.bashrc).
  3. Add this line to the end of the file:
export PATH="$HOME/.nimble/bin:$PATH"
  1. Save the file (Ctrl+O in nano, then Enter) and close the editor (Ctrl+X).
  2. Apply the changes:
    • For Bash/Zsh: source ~/.bashrc or source ~/.zshrc
    • For Fish: source ~/.config/fish/config.fish
  3. Verify that the commands are available:
which nim
which nimble

Both commands should return a path starting with /home/your_user/.nimble/bin/.

Step 4: Install Code Editor and Extension

While you can write Nim in any text editor, VS Code with the extension provides the best experience: syntax highlighting, autocompletion, debugging.

  1. Install VS Code (if not already installed):
    • Ubuntu/Debian: sudo apt install code (via Microsoft repository) or download the .deb from the website.
    • Fedora: sudo dnf install code
    • Arch: sudo pacman -S code
  2. Install the Nim extension:
    • Launch VS Code.
    • Go to the Extensions section (squares icon on the left).
    • Search for nim.
    • Select the official Nim extension (publisher: nim-lang).
    • Click Install.
  3. Verify the extension works:
    • Create a file with the .nim extension.
    • Start typing code—autocompletion should appear.

💡 Tip: For more advanced development, also consider the Nim Language Server extension (if available) or configure nimlsp manually.

Step 5: Create and Run a Test Project

Now let's create a simple application to confirm everything works.

  1. Create a project directory and navigate to it:
mkdir ~/nim_projects
cd ~/nim_projects
  1. Create a hello.nim file:
cat > hello.nim << 'EOF'
echo "Hello, world!"
EOF
  1. Compile and run it:
nim c -r hello.nim

The nim c command compiles the program into an executable, and -r runs it immediately.

The output should be:

Hello, world!
  1. You can also compile in optimized release mode:
nim c -d:release hello.nim
./hello

Step 6: Install the Nimble Package Manager

Nimble is the package manager for Nim, similar to npm for Node.js or pip for Python. It is usually installed automatically with Nim, but let's verify:

  1. Check the version:
nimble --version

If the command is not found, install it manually:

git clone https://github.com/nim-lang/nimble.git
cd nimble
git checkout v0.14.0  # or the latest version
nim c -d:release src/nimble.nim
sudo mv bin/nimble /usr/local/bin/
  1. Update the package list:
nimble refresh
  1. Try installing a package, for example json:
nimble install json

Verification

Run the following commands and ensure they output information without errors:

nim --version
nimble --version
nim c -r hello.nim  # from the test project directory
code --version      # if VS Code is installed

Also, open VS Code, create a test.nim file, and check if syntax highlighting and autocompletion work.

Potential Issues

1. Error nim: command not found after installation

Cause: The ~/.nimble/bin path is not added to PATH. Solution: Repeat Step 3, ensuring the line export PATH="$HOME/.nimble/bin:$PATH" is added to the correct shell configuration file and that you reload it (source ~/.bashrc).

2. Choosenim cannot download Nim (SSL or network errors)

Cause: Network issues or outdated certificates. Solution:

  • Ensure you have an internet connection.
  • Update ca-certificates: sudo apt update && sudo apt install ca-certificates (Ubuntu/Debian).
  • Temporarily disable SSL verification (not recommended): export CHOOSENIM_NO_VERIFY=1 and run choosenim again.

3. Compilation errors due to insufficient memory

Cause: Nim requires sufficient RAM to compile large projects. Solution: Increase the swap file size or close other applications. This rarely occurs for small projects.

4. VS Code does not highlight Nim syntax

Cause: The extension is not activated for the current file. Solution:

  • Ensure the file has a .nim extension.
  • In the bottom-right corner of VS Code, select the Nim language (if prompted).
  • Restart VS Code.

5. Nimble cannot find a package

Cause: The package list is not updated or there are network restrictions. Solution: Run nimble refresh and try again. If the package is not in the official repository, it may need to be installed from GitHub.

6. Error cannot open file: std/... during compilation

Cause: The Nim installation was incorrect or corrupted. Solution: Reinstall Nim via choosenim:

choosenim uninstall
choosenim stable

Ensure there are no old files in ~/.nimble that might conflict.


Environment ready! You can now study the Nim language, create projects, and use the rich package ecosystem via Nimble. For further learning, refer to the official Nim tutorial.

F.A.Q.

Can I install Nim without choosenim?
How do I update Nim to the latest version?
Why is the `nim` command not found after installation?
Does Nim work on WSL?

Hints

Installing the choosenim script
Installing the Nim compiler
Configuring the PATH environment variable
Installing the code editor and extension
Creating and running a test project
Installing the Nimble package manager
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