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

shebang stopped working after 0.1.18 #1638

Closed
julienrf opened this issue Dec 4, 2022 · 0 comments · Fixed by #1639
Closed

shebang stopped working after 0.1.18 #1638

julienrf opened this issue Dec 4, 2022 · 0 comments · Fixed by #1639
Assignees
Labels
bug Something isn't working

Comments

@julienrf
Copy link
Contributor

julienrf commented Dec 4, 2022

Version(s)

$ scala-cli --version
Scala CLI version: 0.1.18
Scala version (default): 3.2.1

Describe the bug

Scala-CLI ignores the “using directives” of my executable script that uses the shebang command.

To Reproduce

Consider a file Test.scala:

$ ls -l          
total 4
-rwxrwxr-x 1 julien julien 288 Dec  4 15:56 Test.scala

It contains a regular Scala-CLI script and uses the shebang command:

$ cat Test.scala 
#!/usr/bin/env -S scala-cli shebang
//> using scala "2.13.8"
//> using repository "https://artifacts.unidata.ucar.edu/repository/unidata-all"
//> using lib "edu.ucar:grib:5.3.1"

import ucar.nc2.dt.grid.{GeoGrid, GridDataset}

object Main {
  def main(args: Array[String]): Unit = ()
}

Note that the script uses Scala 2.13.8, and one library dependency.

Trying to run it (on Ubuntu):

$ ./Test.scala 
Compiling project (Scala 3.2.1, JVM)
[error] ./Test.scala:6:8: Not found: ucar
[error] import ucar.nc2.dt.grid.{GeoGrid, GridDataset}
[error]        ^^^^
Error compiling project (Scala 3.2.1, JVM)
Compilation failed

The import is not resolved, and the Scala version is wrong.

Note that the regression seems to be pretty recent as it was working not a long time ago.

Expected behaviour

Scala-CLI does take into account the using directives of the file.

Workaround

  • Remove the shebang on the first line
  • Run the script with scala-cli run Test.scala -- ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants