Skip to content

Add support for the :require command in the REPL #21658

Closed
@Gedochao

Description

@Gedochao

The :require command was (and is) supported by the Scala 2 REPL, while it is visibly absent in Scala 3.

scala -S 2.13
Welcome to Scala 2.13.15 (OpenJDK 64-Bit Server VM, Java 17).
Type in expressions for evaluation. Or try :help.
scala> :help
All commands can be abbreviated, e.g., :he instead of :help.
(...)
:require <path>          add a jar to the classpath
(...)
scala> :require cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_2.13/0.10.7/os-lib_2.13-0.10.7.jar
Added '/user/test/cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_2.13/0.10.7/os-lib_2.13-0.10.7.jar' to classpath.

scala> :require cache/https/repo1.maven.org/maven2/com/lihaoyi/geny_2.13/1.1.1/geny_2.13-1.1.1.jar
Added '/user/test/cache/https/repo1.maven.org/maven2/com/lihaoyi/geny_2.13/1.1.1/geny_2.13-1.1.1.jar' to classpath.

scala> os.pwd
val res0: os.Path = /user/test

scala> 

This is not exactly as good as direct support for //> using dep from inside of the REPL, and would be the equivalent of the //> using jar directive of the runner (that indeed, could be called from inside of the REPL).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions