setup command aims at making it easier to setup a machine for
Scala development, be it your own development machine, or CI
It currently ensures that:
- a JVM is installed on your system,
- standard Scala CLI tools are installed.
Launched without options,
setup checks that a JVM and the standard Scala CLI tools are
installed on your system, and updates your profile files (Linux / macOS) or user environment variables
$ cs setup
It asks you to confirm prior to performing any of these actions.
To answer yes to all these questions beforehand, pass
$ cs setup --yes
On Windows, simply launching
cs invokes the
setup command. That allows simply
cs.exe from the Windows explorer to open a terminal running the
If you prefer the
setup command not to update your profile files (
~/.profile and the like),
--env to it, and call
eval (from bash or zsh) on its output:
$ eval "$(cs setup --env)"
PATH for the duration of the current session.
Pass it a JVM id and a list of applications to
- use that JVM in the current session, and
- ensure some applications are installed, like
$ eval "$(cs setup --env --jvm 11 --apps sbt-launcher,ammonite)" $ sbt … $ amm … $ java -version openjdk version "11.0.6" 2020-01-14 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)
setup command currently doesn't offer a way to revert the changes
it made to the environment variables of the current session. It's mostly
made to easily setup CI environments, rather than switch JVMs. If you're
interested in trying / switching JVM, see the
--disable options of the
The JVM installed if none is found on your system
is the same as the
java command, the latest AdoptOpenJDK 8 as of
--jvm to ignore the already installed jvm and install a custom one:
$ cs setup --jvm 11
JVMs are extracted in the JVM cache directory by default.
Pass a custom directory to extract JVM under with
$ eval "$(cs setup --jvm 11 --jvm-dir test-jvm)" … $ echo "$JAVA_HOME" …/firstname.lastname@example.org
setup command installs a number of standard Scala CLI applications by default.
Pass a custom list of applications to install instead with
$ cs setup --apps sbt-launcher,ammonite
--apps can be specified multiple times, and expects a
,-separared list of applications.
See the documentation of the
install command for more details about
where these applications are defined, how to add your own, etc.
Applications are installed in the installation directory of coursier by default.
Pass a custom directory to install applications in with
$ eval "$(cs setup --apps sbt-launcher,ammonite --install-dir tmp-install)" … $ tmp-install/sbt … $ tmp-install/amm …
Profile files directory
Pass a custom directory that contains
.zprofile files with:
$ cs setup --user-home test-home … $ cat test-home/.profile # >>> coursier install directory >>> export PATH="$PATH:/Users/alex/Library/Application Support/Coursier/bin" # <<< coursier install directory <<<
How it sets environment variables globally
Linux / macOS
setup command updates the following files:
~/.profile(created if needed),
~/.zprofileif zsh is the current shell (created if needed, respects
~/.bash_profile(only if it exists).
For example, if
~/.bash_profile doesn't exist and you're using zsh, both
~/.zprofile will be updated (and created if needed).
The sections the
setup command adds to your profile files are clearly delimited, like
# >>> coursier install directory >>> export PATH="$PATH:/Users/alex/Library/Application Support/Coursier/bin" # <<< coursier install directory <<<
On Windows, the
setup command updates the
User environment variables.