Installing clojure locally on a Mac

I’m setting up a newly repurposed Mac for Exercism, and I had some extra steps to do to install clojure. Starting from Installing Clojure locally | Exercism's Docs

  1. brew install went smoothly

    $ brew install clojure/tools/clojure
    ...
    ==> Installing clojure from clojure/tools
    ==> ./install.sh /usr/local/Cellar/clojure/1.11.1.1347
    🍺  /usr/local/Cellar/clojure/1.11.1.1347: 11 files, 19.5MB, built in 4 seconds
    ...
    
  2. however

    $ clj
    The operation couldn’t be completed. Unable to locate a Java Runtime.
    Please visit http://www.java.com for information on installing Java.
    
  3. OK, install a Java

    $ brew install openjdk
    ...
    ==> Installing openjdk
    ==> Pouring openjdk--20.0.1.ventura.bottle.tar.gz
    ...
    
  4. however

    $ clj
    The operation couldn’t be completed. Unable to locate a Java Runtime.
    Please visit http://www.java.com for information on installing Java.
    
  5. scroll back up and read the Caveats from the above openjdk installation

    ...
    ==> Installing openjdk
    ==> Pouring openjdk--20.0.1.ventura.bottle.tar.gz
    ==> Caveats
    For the system Java wrappers to find this JDK, symlink it with
      sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
    ...
    
  6. OK, let’s do that

    $ sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
    
    $ clj
    Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.pom from central
    Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.pom from central
    Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.pom from central
    Downloading: org/clojure/pom.contrib/1.1.0/pom.contrib-1.1.0.pom from central
    Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar from central
    Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar from central
    Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.jar from central
    Clojure 1.11.1
    user=> 
    

Shall I create a PR to augment the MacOS installation instructions accordingly?

1 Like

Yes please!

FWIW, after reading this I clicked through the links on the referenced page and got to the official install instructions. The section on Java (linked as a prerequisite near the top of the page) suggests using Homebrew to install the Temurin flavour of OpenJDK.

I, being of no particular opinion on the matter, did as suggested and found the process very smooth on a fairly virgin Ventura install. No symlinking required!

1 Like
2 Likes