Recently, I started learning Clojure. I have been using Emacs, and cider (REPL). Also, I have NixOS as OS.
I have been able to successfully program in Clojure using this environment. Usually, I create the files, then I go to the directory where the .clj
are, I execute cider-jack-in
, a REPL is created, and interactive programming magic happens. Thus, I am able to load the file, load new versions of old functions, etc.
It also works if I just start Emacs and execute `cider-jack-in. The mini-buffer asks:
Are you sure you want to run `cider-jack-in' without a Clojure project? (y or n)
After answering y
, everything works fine.
While reading the book Clojure for the Brave and True, I have also successfully used:
$ lein run
For learning purposes, I decided to explore some open source projects. Thus, I did a git clone
of this open-source project.
Being on the folder, I decided to reproduce the steps that have worked so far. However, it does not work. After executing cider-jack-in
, the mini-buffer echoes the following:
The clojure executable isn’t on your ‘exec-path
Also, if I try with lein
I get:
[pedro@system:~/projects/http-cron]$ lein run
No :main namespace specified in project.clj.
Obs.: If I type clojure
on the shell, this is what I get:
[pedro@system:~]$ clojure
The program 'clojure' is not in your PATH. You can make it available in an
ephemeral shell by typing:
nix-shell -p clojure
Why is this happening?
How can I solve this (considering that I am using NixOS)?
Going the imperative route, depending on whether you use NixOS with channels (default) or flakes, you can permanently install clojure
into your environment with:
nix-env -f '<nixpkgs>' -iA clojure
nix profile install nixpkgs#clojure
The preferred (declarative) way would however be adding clojure
to environment.systemPackages
in /etc/nixos/configuration.nix
and running sudo nixos-rebuild switch
.