scala
https://scala-lang.org
curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup
./cs --help
Usage: ./cs <COMMAND>
Coursier is the Scala application and artifact manager.
It can install Scala applications and setup your Scala development environment.
It can also download and cache artifacts from the web.
Install application commands:
install Install an application from its descriptor.
list List all currently installed applications.
setup Setup a machine for Scala development.
uninstall Uninstall one or more applications.
update Update one or more applications.
Application channel commands:
channel Manage additional channels, used by coursier to resolve application descriptors.
search Search application names from known channels.
Java commands:
java Manage installed JVMs and run java.
java-home Print the home directory of a particular JVM.
Launcher commands:
bootstrap Create a binary launcher from a dependency or an application descriptor.
launch Launch an application from a dependency or an application descriptor.
Resolution commands:
fetch Transitively fetch the JARs of one or more dependencies or an application.
resolve Resolve and print the transitive dependencies of one or more dependencies or an application.
Other commands:
about Print details about the current machine and coursier launcher.
version Prints the coursier version
Checking if a JVM is installed
Found a JVM installed under /usr/lib/jvm/corretto21.
Checking if ~/.local/share/coursier/bin is in PATH
Should we add ~/.local/share/coursier/bin to your PATH via ~/.profile? [Y/n] Y
Checking if the standard Scala applications are installed
Installed ammonite
Found app cs in channel io.get-coursier:apps
Error downloading https://github.com/coursier/coursier/releases/download/v2.1.24/cs-x86_64-pc-linux.gz
解决办法:使用代理 ./cs -J-Dhttps.proxyHost=192.168.1.131 -J-Dhttps.proxyPort=8118 setup --verbose --progress
Checking if a JVM is installed
Found a JVM installed under /usr/lib/jvm/corretto21.
Checking if ~/.local/share/coursier/bin is in PATH
Should we add ~/.local/share/coursier/bin to your PATH via ~/.profile? [Y/n] Y
Checking if the standard Scala applications are installed
Found app ammonite in channel io.get-coursier:apps
Found ammonite
Found app cs in channel io.get-coursier:apps
Found prebuilt launcher at https://github.com/coursier/coursier/releases/download/v2.1.24/cs-x86_64-pc-linux.gz (22.3 MiB)
Wrote /home/ubuntu/.local/share/coursier/bin/.cs.part
Wrote /home/ubuntu/.local/share/coursier/bin/cs
Wrote /home/ubuntu/.local/share/coursier/bin/.cs.aux
Installed cs
Found app coursier in channel io.get-coursier:apps
Wrote /home/ubuntu/.local/share/coursier/bin/.coursier.part
Wrote /home/ubuntu/.local/share/coursier/bin/coursier
Installed coursier
Found app scala in channel io.get-coursier:apps
Found prebuilt launcher at https://github.com/scala/scala3/releases/download/3.6.3/scala3-3.6.3-x86_64-pc-linux.tar.gz (4.0 KiB)
Wrote /home/ubuntu/.local/share/coursier/bin/.scala.part
Wrote /home/ubuntu/.local/share/coursier/bin/scala
Installed scala
Found app scalac in channel io.get-coursier:apps
Wrote /home/ubuntu/.local/share/coursier/bin/.scalac.part
Wrote /home/ubuntu/.local/share/coursier/bin/scalac
Installed scalac
Found app scala-cli in channel io.get-coursier:apps
Found prebuilt launcher at https://github.com/VirtusLab/scala-cli/releases/download/v1.6.1/scala-cli-x86_64-pc-linux.gz (33.9 MiB)
Wrote /home/ubuntu/.local/share/coursier/bin/.scala-cli.part
Wrote /home/ubuntu/.local/share/coursier/bin/scala-cli
Wrote /home/ubuntu/.local/share/coursier/bin/.scala-cli.aux
Installed scala-cli
Found app sbt in channel io.get-coursier:apps
Found prebuilt launcher at https://github.com/sbt/sbt/releases/download/v1.10.7/sbt-1.10.7.zip (4.0 KiB)
Wrote /home/ubuntu/.local/share/coursier/bin/.sbt.part
Wrote /home/ubuntu/.local/share/coursier/bin/sbt
Installed sbt
Found app sbtn in channel io.get-coursier:apps
Found prebuilt launcher at https://github.com/sbt/sbt/releases/download/v1.10.7/sbt-1.10.7.zip (4.0 KiB)
Wrote /home/ubuntu/.local/share/coursier/bin/.sbtn.part
Wrote /home/ubuntu/.local/share/coursier/bin/sbtn
Installed sbtn
Found app scalafmt in channel io.get-coursier:apps
Wrote /home/ubuntu/.local/share/coursier/bin/.scalafmt.part
Wrote /home/ubuntu/.local/share/coursier/bin/scalafmt
Installed scalafmt
cs setup 主要用于安装 Scala 环境和工具,但本身不直接提供指定 Scala 版本的选项.
要安装特定版本的 Scala,可以
- 卸载已安装的 Scala 和 scalac(如果存在):
cs uninstall scala scalac
. - 使用 cs install 命令指定版本安装:
cs install scala:版本号 && cs install scalac:版本号
- 例如:
cs install scala:2.13.16; cs install scalac:2.13.16
.
~$ ./cs -J-Dhttps.proxyHost=192.168.1.181 -J-Dhttps.proxyPort=8118 install scala:2.13.16
https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.16/scala-compiler-2.13.16.pom
100.0% [##########] 2.3 KiB (11.7 KiB / s)
https://repo1.maven.org/maven2/org/jline/jline/3.27.1/jline-3.27.1.pom
100.0% [##########] 23.2 KiB (106.5 KiB / s)
https://repo1.maven.org/maven2/io/github/java-diff-utils/java-diff-utils/4.15/java-diff-utils-4.15.pom
100.0% [##########] 2.6 KiB (4.8 KiB / s)
https://repo1.maven.org/maven2/io/github/java-diff-utils/java-diff-utils/4.15/java-diff-utils-4.15.jar
100.0% [##########] 73.9 KiB (71.1 KiB / s)
https://repo1.maven.org/maven2/org/jline/jline/3.27.1/jline-3.27.1-jdk8.jar
100.0% [##########] 1.3 MiB (276.3 KiB / s)
https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.16/scala-compiler-2.13.16.jar
100.0% [##########] 11.7 MiB (563.8 KiB / s)
Wrote scala
~$ ./cs -J-Dhttps.proxyHost=192.168.1.181 -J-Dhttps.proxyPort=8118 install scalac:2.13.16
https://repo1.maven.org/maven2/io/get-coursier/apps/maven-metadata.xml
No new update since 2025-01-20 22:06:52
Wrote scalac
~$ scala -version
Scala code runner version 2.13.16 -- Copyright 2002-2025, LAMP/EPFL and Lightbend, Inc. dba Akka
~$ scalac -version
Scala compiler version 2.13.16 -- Copyright 2002-2025, LAMP/EPFL and Lightbend, Inc. dba Akka
~$ ls -l ~/.local/share/coursier/bin/
total 852
-rwxr-xr-x 1 ubuntu ubuntu 172493 Feb 6 11:20 amm
-rwxr-xr-x 1 ubuntu ubuntu 169494 Feb 6 12:10 coursier
-rwxr-xr-x 1 ubuntu ubuntu 1303 Feb 6 12:09 cs
-rwxr-xr-x 1 ubuntu ubuntu 1236 Feb 6 12:14 sbt
-rwxr-xr-x 1 ubuntu ubuntu 1297 Feb 6 12:16 sbtn
-rwxr-xr-x 1 ubuntu ubuntu 166660 Feb 6 12:21 scala
-rwxr-xr-x 1 ubuntu ubuntu 166368 Feb 6 12:22 scalac
-rwxr-xr-x 1 ubuntu ubuntu 1277 Feb 6 12:13 scala-cli
-rwxr-xr-x 1 ubuntu ubuntu 167955 Feb 6 12:16 scalafmt