Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document starting programs compiled by scalac in the current working directory #3132

Closed
tgodzik opened this issue Aug 27, 2024 · 1 comment · Fixed by #3155
Closed

Document starting programs compiled by scalac in the current working directory #3132

tgodzik opened this issue Aug 27, 2024 · 1 comment · Fixed by #3155
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command.

Comments

@tgodzik
Copy link
Member

tgodzik commented Aug 27, 2024

Version(s)
1.5.0 follow up from scala/scala3#21432

Describe the bug
If a user compiles using scalac, they can't now run that using scala.

To Reproduce

› scalac hello.scala
› ls -la hello.*
-rw-r--r--@ 1 kieran  staff  758 25 Aug 20:45 hello$package$.class
-rw-r--r--@ 1 kieran  staff  267 25 Aug 20:45 hello$package.class
-rw-r--r--@ 1 kieran  staff  593 25 Aug 20:45 hello$package.tasty
-rw-r--r--@ 1 kieran  staff  912 25 Aug 20:45 hello.class
-rw-r--r--@ 1 kieran  staff   45 25 Aug 20:45 hello.scala
-rw-r--r--@ 1 kieran  staff  502 25 Aug 20:45 hello.tasty
› scala hello
[error]  hello is not a scala sub-command and it is not a valid path to an input file or directory.
Try viewing the relevant help to see the list of available sub-commands and options.
  scala --help

Expected behaviour
Hello should be run. Should we see if hello.class exists in that case and just try to run it? I am not sure if we discussed this breaking (?) change

@tgodzik tgodzik added the bug Something isn't working label Aug 27, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Sep 2, 2024

It has been discussed and agreed we would not be supporting this during SIP-46 implementation (this has been a while ago, I'd have to look very deep to link to a discussion).
Scala CLI never tries to include any inputs from the current working directory, nor should it.

The equivalent for this to be working is:

scalac hello.scala
scala run -cp .

Passing the main class may be necessary, in which case:

scalac hello.scala
scala run -cp . -M hello

it is necessary to pass the run command explicitly, as otherwise it is assumed we are launching the REPL (there are no explicit inputs, just a classpath).
We treat passing the current working directory to the classpath as necessary here.

What we should do here is add an entry about it in the migration guide (https://scala-cli.virtuslab.org/docs/guides/introduction/old-runner-migration/), as it indeed seems largely undocumented.

Please note that passing the main class to the old scala script this way is also entirely undocumented, it's very easy to miss documenting these things when they weren't documented in the first place...

@Gedochao Gedochao added documentation Improvements or additions to documentation SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command. labels Sep 2, 2024
@Gedochao Gedochao moved this from To do to To Document in Issue Board Sep 2, 2024
@Gedochao Gedochao self-assigned this Sep 2, 2024
@Gedochao Gedochao linked a pull request Sep 6, 2024 that will close this issue
@Gedochao Gedochao changed the title Start programs compiled by scalac Document starting programs compiled by scalac in the current working directory Sep 9, 2024
@Gedochao Gedochao closed this as completed Sep 9, 2024
@github-project-automation github-project-automation bot moved this from To Document to Done in Issue Board Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants
@tgodzik @Gedochao and others