command 'scala' not found after set up by coursier

2k Views Asked by At

I use coursier to set up the environment of Scala using command ./cs setup in Ubuntu 20.04 LTS. It was said that all the requirements were installed. However, when I use command scala -version to check whether the installation succeeded, it shown that Command 'scala' not found. The result of command. Reboot didn't work. So please help me to slove this problem! Thanks!

Information: An ECS with Ubuntu 20.04 LTS, user is not the root.

3

There are 3 best solutions below

0
On

For those on OSX I found that I had to change the directory that coursier had automatically added to the PATH in my .bash_profile:

export PATH="$PATH:/Users/username/Library/Application Support/Coursier/bin"

to

export PATH="$PATH:/Users/username/Library/Application\ Support/Coursier/bin"

Basically add the backslash in. Then run source .bash_profile to reload the profile.

1
On

I had the same issue, coursier did modify my .bash_profile to include:

# >>> coursier install directory >>>
export PATH="$PATH:/home/james/.local/share/coursier/bin"
# <<< coursier install directory <<<

But that didn't work for me.

I had to edit the .bashrc and on the last line add:

export PATH="$PATH:$HOME/.local/share/coursier/bin"

You will have to run bash or logout and back in for it to take effect.

0
On

I had the same issue, it looks like coursier is adding scala bin path to the ~/.profile file using double quotations:

# >>> coursier install directory >>>
export PATH="$PATH:/home/username/.local/share/coursier/bin"
# <<< coursier install directory <<<

So I removed the double quotations and it worked fine for me

# >>> coursier install directory >>>
export PATH=$PATH:/home/username/.local/share/coursier/bin
# <<< coursier install directory <<<

You can run this command in your terminal after updating the profile file, so the new changes takes effect immediately in your terminal with no need to log out or open a new terminal tab.

source ~/.profile