Skip to content

Commit 7975036

Browse files
committed
Update the Scala CLI as an implementation of the scala command doc
1 parent e99f770 commit 7975036

File tree

1 file changed

+62
-17
lines changed
  • website/docs/reference/scala-command

1 file changed

+62
-17
lines changed

website/docs/reference/scala-command/index.md

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,93 @@
22
title: Scala CLI as scala
33
---
44

5-
# Scala CLI as implementation for `scala` command
5+
# Scala CLI as an implementation of the `scala` command
66

7-
Scala CLI is designed to be a replacement for script that is currently installed as `scala`. Since Scala CLI is
8-
feature-packed we do not want to expose all the features and options to the whole Scala public at the very start. Why is
9-
that?
7+
As of Scala 3.5.0, Scala CLI has become the official runner for the language,
8+
replacing the old runner implementation under the `scala` script.
109

11-
- We want to make sure that the options / commands are stable
12-
- We do not want to overwhelm users with multiple options and commands
13-
- We want to make sure that the commands we add to `scala` are stable so once we commited to supporting given option it
14-
may be hard to remove it later
10+
Since Scala CLI is quite feature-packed, we do not want to expose all the features and options to all the Scala users
11+
from the very beginning. Why is that?
12+
13+
- We want to make sure that the options / commands are stable.
14+
- We do not want to overwhelm users with multiple options and commands.
1515

1616
That is why we built in a mechanism to limit the commands, options, directives in Scala CLI by default. However, it's
1717
still possible to enable all features by explicitly passing the `--power` flag on the command line, or by setting it
1818
globally running:
1919

2020
```bash ignore
21-
scala-cli config power true
21+
scala config power true
22+
```
23+
24+
Alternatively, it is also possible to rely on the `SCALA_CLI_POWER` environment variable to achieve the same:
25+
26+
```bash ignore
27+
export SCALA_CLI_POWER=true
2228
```
2329

2430
To check which options, commands and directives are supported when running Scala CLI with limited functionalities, refer
2531
to [options](./cli-options.md), [commands](./commands.md) and [using directives](./directives.md), respectively.
2632

27-
## Testing Scala CLI as `scala`
33+
## Installing Scala CLI as `scala`
34+
35+
Refer to the [official instructions for installing Scala](https://www.scala-lang.org/download/).
36+
37+
:::note
38+
A given Scala version has a paired Scala CLI version which is used by the `scala` command installed alongside it, as per
39+
the [official instructions](https://www.scala-lang.org/download/).
40+
This means that even when installing the latest Scala version, its `scala` command may refer to an older Scala CLI
41+
version.
2842

29-
There are two recommended ways to test and use Scala CLI:
43+
To get the latest stable Scala CLI launcher, refer to the [separate
44+
`scala-cli` installation instructions](../../../install).
3045

31-
- with brew:
46+
Alternatively, you can use the `--cli-version` launcher option to specify the Scala CLI version to use.
47+
This will run the JVM launcher of the specified Scala CLI version under the hood, so do keep in mind that it may be a
48+
bit slower than a native launcher.
49+
Also, the specified version (and potentially any of its dependencies, if they are not already installed) would be
50+
downloaded if it's not available in the local cache, so it may require additional setup for isolated environments.
3251

3352
```bash ignore
34-
brew install virtuslab/scala-experimental/scala
53+
scala --cli-version 1.5.0 version
54+
# Scala CLI version: 1.5.0
55+
# Scala version (default): 3.5.0
3556
```
3657

37-
- with coursier:
58+
If the bleeding edge is what you are after, you can use the nightly version this way.
59+
Just keep in mind that there are no guarantees about the stability of nightly versions.
3860

3961
```bash ignore
40-
cs setup
41-
cs install scala-experimental ← this command will replace the default scala runner
62+
scala --cli-version nightly version
63+
# Scala CLI version: 1.5.0-17-g00e4c88c1-SNAPSHOT
64+
# Scala version (default): 3.5.0
4265
```
4366

44-
Alternatively, you can rename your `scala-cli` executable or alias it as `scala`.
67+
:::
4568

4669
## Migrating from the old `scala` runner to Scala CLI
4770

4871
If you have been using the old `scala` runner and want to migrate to Scala CLI, refer
4972
to [the migration guide](../../guides/introduction/old-runner-migration.md).
73+
74+
## Using the old (deprecated) `scala` runner with Scala 3.5+
75+
76+
You can still use the (deprecated as of Scala 3.5.0) legacy runner with Scala 3.5+ installed. It is available under
77+
the `scala_legacy` command.
78+
79+
:::caution
80+
Even though this enables usage of the old runner under a new alias, it is recommended to
81+
migrate any existing scripts and automations to Scala CLI under either `scala` or `scala-cli`, as the `scala_legacy`
82+
command may be dropped at some point in the future.
83+
:::
84+
85+
```bash ignore
86+
scala_legacy
87+
# [warning] MainGenericRunner class is deprecated since Scala 3.5.0, and Scala CLI features will not work.
88+
# [warning] Please be sure to update to the Scala CLI launcher to use the new features.
89+
# [warning] Check the Scala 3.5.0 release notes to troubleshoot your installation.
90+
# Welcome to Scala 3.5.0 (17, Java OpenJDK 64-Bit Server VM).
91+
# Type in expressions for evaluation. Or try :help.
92+
#
93+
# scala>
94+
```

0 commit comments

Comments
 (0)