Skip to content

REPL runner command line options weakly parsed #8095

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

Closed
som-snytt opened this issue Jan 27, 2020 · 2 comments · Fixed by #11366
Closed

REPL runner command line options weakly parsed #8095

som-snytt opened this issue Jan 27, 2020 · 2 comments · Fixed by #11366

Comments

@som-snytt
Copy link
Contributor

minimized code

I was tripped up by -cp not meaning -classpath. Also by -help not offering any.

  dotr -classpath /tmp/stuff f
OK
  dotr -cp /tmp/stuff f       
Error: Unable to initialize main class f
Caused by: java.lang.NoClassDefFoundError: scala/util/CommandLineParser$ParseError
  dotr -help
Starting dotty REPL...
scala>                                                                                                                     
  dotr -version
Starting dotty REPL...
Dotty compiler version 0.21.0-RC1 -- Copyright 2002-2019, LAMP/EPFL
scala>                 

Or maybe it does mean some kind of classpath, because that looks like it found the entry point but nothing else. This is finding nothing, or not finding anything:

➜  dotr -classpath junk nada
Error: Could not find or load main class nada
Caused by: java.lang.ClassNotFoundException: nada
Compilation output
As per transcript.

expectation

Common options explained by dotr -help. Most people won't use it at the shell or sbt prompt anyway.

OK, it just completed in sbt, where it looks like options are passed on to java. So -cp must be fielded by java, explaining the result above.

@retronym
Copy link
Member

retronym commented Feb 10, 2021

I just ran into this. The runner passes options other than {-repl, -run, -classpath, -with-compiler, -d, -J*}, directly to the JVM as residual_args. The JVM accepts -cp as alias for -cp and this ovewrwrites the setting of "-classpath \"$cp_arg\"" which includes the standard library.

@retronym
Copy link
Member

Taking the step of accepting the -cp alias in #11366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants