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

When using process substitution or -e, Scala CLI shouldn't create .scala-build in the current directory #1459

Closed
alexarchambault opened this issue Oct 14, 2022 · 3 comments · Fixed by #1771
Labels
bug Something isn't working SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command.

Comments

@alexarchambault
Copy link
Contributor

Version(s)
0.1.16

Describe the bug
Running commands such as

$ scala-cli <(echo 'println("Hello")')
$ scala-cli -e 'println("Hello")'

creates a .scala-build directory, and uses it to compile the provided input. Scala CLI should rather use a directory under the home directory for that purpose.

@alexarchambault alexarchambault added the bug Something isn't working label Oct 14, 2022
@Gedochao
Copy link
Contributor

Btw. this is only the case if no inputs are passed alongside -e 'println("Hello") or _.
What I mean is, the following two cases should still create .scala-build as normal:

$ scala-cli -e 'println(Messages.hello)' Messages.scala
$ echo 'println(Messages.hello)' | scala-cli _.sc Messages.scala

I believe if a subset of the following consists of all the passed sources, then .scala-build indeed shouldn't be created:

  • snippets (-e, --scala-snippet, --java-snippet)
  • piped sources (_.scala, _.java, _.sc)
  • process substitution
  • remote sources (i.e. GitHub gists)

We need the .scala-build directory locally only if those are combined with actual on-disk inputs.

@lwronski lwronski added the SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command. label Nov 2, 2022
@Gedochao
Copy link
Contributor

Gedochao commented Jan 4, 2023

Scala CLI should rather use a directory under the home directory for that purpose.

Maybe a temporary directory would be better than home?

@lwronski
Copy link
Contributor

lwronski commented Jan 4, 2023

Scala CLI should rather use a directory under the home directory for that purpose.

Maybe a temporary directory would be better than home?

Yes, using the tmp directory seems like a good idea, or we could use Directories.cacheDir. We should analyze which option is best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 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.

3 participants