1

I would like to get started with scala. I have a Mac M1 computer and so I follow the instructions on this reddit post which seems to be the same as in the official website. So it do

$ brew install coursier/formulas/coursier
$ cs setup

for which the output is (output of cs setup)

Checking if a JVM is installed
Found a JVM installed under /Users/johnsmith/Library/Caches/Coursier/arc/https/github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_mac_hotspot_8u292b10.tar.gz/jdk8u292-b10/Contents/Home.
  Should we update ~/.profile, ~/.config/zsh/.zprofile, ~/.bash_profile? [Y/n] y

Checking if ~/Library/Application Support/Coursier/bin is in PATH
  Should we add ~/Library/Application Support/Coursier/bin to your PATH via ~/.profile, ~/.config/zsh/.zprofile, ~/.bash_profile? [Y/n] y

Checking if the standard Scala applications are installed
  Found ammonite
  Found cs
  Found coursier
  Found scala
  Found scalac
  Found scala-cli
  Found sbt
  Found sbtn
  Found scalafmt

Apparently this should install the following

s itself, to further manage your Scala environment

scala-cli, a convenient tool to compile / run / package Scala code

scala, the Scala REPL

scalac, the Scala compiler

sbt and sbtn, the sbt build toold

ammonite, an enhanced REPL for Scala

scalafmt, the Scala code formatter

but I cannot acces any of them. When I do for instance

scala -version

I get

zsh: command not found: scala
roi_saumon
  • 489
  • 4
  • 13
  • 1
    It's possible that the PATH environment variable was changed in one of those dot files but not in the current shell. Kill the shell and restart it and see if the commands can now be found. – President James K. Polk Sep 16 '22 at 22:58
  • @PresidentJamesK.Polk, I tried to close the shell and reopen but it still didn't work – roi_saumon Sep 16 '22 at 23:02
  • When it asked "Should we add ~/Library/Application Support/Coursier/bin to your PATH via ~/.profile, ~/.config/zsh/.zprofile, ~/.bash_profile? [Y/n] y", did you answer yes? And have you looked at the PATH settings in those files? – Seth Tisue Sep 17 '22 at 00:12
  • I gave [one way of installing it](https://stackoverflow.com/a/66464892/7662670) in an answer to a [previous question](https://stackoverflow.com/questions/66464412/install-scala-to-apple-silicon) and the answer seems to work for other people. But the question was closed so it might not be visible and probably can't be marked as a duplicate. – Tim Sep 17 '22 at 06:23
  • 3
    Okay so I think I found my issue [here](https://serverfault.com/questions/901403/zsh-not-sourcing-zprofile). Since it exported the path in `.config/zsh/.zprofile` and this is only sourced when openening a login shell, just opening a new shell didn't source the `.config/zsh/.zprofile` so didn't export to the path. However if I do `su johnsmith --login` it will source it (but `su johnsmit` wont, weird since both seem to be logins for me). In the end I just exported the path in `.zshenv`. I guess the distinction between login shells and non-login shells are not clear to me^^ – roi_saumon Sep 17 '22 at 11:41

2 Answers2

1

Simple do this

brew install scala
Aung Zan Baw
  • 392
  • 2
  • 8
1

Try

source ~/.zprofile

This worked for me.

Hung Om
  • 630
  • 7
  • 16