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

Option -save is not supported #1670

Closed
julienrf opened this issue Dec 8, 2022 · 4 comments · Fixed by #1679
Closed

Option -save is not supported #1670

julienrf opened this issue Dec 8, 2022 · 4 comments · Fixed by #1679
Assignees
Labels
enhancement New feature or request SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command.

Comments

@julienrf
Copy link
Contributor

julienrf commented Dec 8, 2022

Is your feature request related to a problem? Please describe.

The current scala runner (based on Scala 2.13) does support a -save option.

The experimental scala runner (based on Scala CLI) does not recognize that option:

$ scala -save test.scala 
Unrecognized argument: -save

To list all available options, run
  /home/julien/.local/share/coursier/bin/.scala.aux --help

Describe the solution you'd like

For the sake of compatibility with the current runner, it would be great to recognize the -save option. As far as I understand, Scala CLI now always behaves like the current scala -save, so the option is not necessary anymore. Therefore, it could simply print a warning like “Unnecessary option: -save. This option is always enabled.”

@julienrf julienrf added the enhancement New feature or request label Dec 8, 2022
@Gedochao Gedochao added the SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command. label Dec 8, 2022
@Gedochao Gedochao self-assigned this Dec 8, 2022
@Gedochao
Copy link
Contributor

As far as I understand, Scala CLI now always behaves like the current scala -save, so the option is not necessary anymore.

Actually, it seems that part isn't entirely true.
There doesn't seem to be any official docs on the -save (and tied -nosave) options for the old scala command beyond what's in the runner code itself.
For context, here are the relevant code bits:

Looking at the actual behaviour:

▶ tree -a
# .
# └── smth.scala
#
# 0 directories, 1 file
▶ scala -save smth.scala
# Hello
▶ tree -a
# .
# ├── smth.jar
# └── smth.scala
# 
# 0 directories, 2 files
▶ scala smth.jar
# Hello

It seems that the -save option forces a compiled jar to be saved in the cwd, while -nosave overrides it and prevents the jar being saved (for whatever reason).

Now, this looks like a way to combine the run and package --lib subcommands of Scala CLI.
We could theoretically support it by running the 2 subcommands one after another (that'd be a quick bandaid) or (preferably) combine both effects in a single build.

Therefore, it could simply print a warning like “Unnecessary option: -save. This option is always enabled.”

In this context, that wouldn't be true. We could always just not support it if it's not actually needed and print a warning like Deprecated option '-save' ignored., so that it doesn't fail the build.

@julienrf thoughts? Is this option necessary?

@Gedochao
Copy link
Contributor

Also, a side note - it seems that what I mentioned above would also require us to implement #1641, so I'm tagging it as SIP as well...

@julienrf
Copy link
Contributor Author

julienrf commented Dec 12, 2022

I think the fact that it saves the compiled code as a .jar is an “implementation detail”. But maybe not. Maybe some people are relying on the produced jar. In that case, I think a warning saying that this option is ignored but the compilation artifacts are saved (in .scala-build/) for reuse, and that a .jar can be produced with the command package would be enough.

@Gedochao
Copy link
Contributor

We could even suggest running a subsequent package --lib in the warning, too, in case someone actually needs that jar... That'd reuse whatever is in .scala-build/, so it wouldn't be much slower beyond the necessity of running another command.
I guess that if it's a niche use case, maybe that'd be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants