nix-env command not found

In this troubleshooting guide we learn how to fix nix-env command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

nix-env: command not found

or when using sudo you get the following error message

sudo: nix-env: command not found

Solutions to nix-env: command not found

How To Fix nix-env: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu nix-env is provided by nix-bin package.

nix-bin is:

A powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. Nix provides atomic upgrades and rollbacks, side-by-side installation of multiple versions of a package, multi-user package management and easy setup of build environments.

NOTE: This package only provides the nix binaries. One still needs to setup directories, environments variables and configuration files to use nix as described in the nix manual. The package nix-setup-systemd provides such a setup using systemd mechanisms, also see /usr/share/doc/nix-bin/README.Debian.

To fix this problem, we can install more using the command below.

sudo apt-get -y install nix-bin

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install nix-bin.

sudo apt -y install nix-bin

Or if you have aptitude installed you can use the following command.

sudo aptitude install nix-bin

Summary

In this tutorial we learn how to fix nix-env command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.