-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix for #11424 #11425
fix for #11424 #11425
Conversation
I think we need to have this in RC1, given that it is user-facing for anyone trying the repl. |
Note also :
Question : Did anybody test script file |
Good catch @michelou . We have a test for distribution https://github.com/lampepfl/packtest. I think it's time to have that test as part of CI. |
@michelou - I tested in these environments:
Although my
|
@philwalk I know the issue (I was waiting for someone else to also report it). In my case I made the following local change on line 119 of file
instead of
|
@michelou - I can do a PR for the |
@philwalk I guess my fix works for you as well. PS. To remind us : PR #5444 (closed, november 2018). |
@michelou the fix worked for MINGW but not for MSYS2, so I haven't done the PR yet. A possible fix that works for both MINGW and MSYS2: diff --git a/compiler/src/dotty/tools/repl/JLineTerminal.scala b/compiler/src/dotty/tools/repl/JLineTerminal.scala
index 916df851cb..7110af5605 100644
--- a/compiler/src/dotty/tools/repl/JLineTerminal.scala
+++ b/compiler/src/dotty/tools/repl/JLineTerminal.scala
@@ -20,10 +20,12 @@ final class JLineTerminal extends java.io.Closeable {
private val terminal =
TerminalBuilder.builder()
- .dumb(false) // fail early if not able to create a terminal
+ .dumb(dumbRequested) // fail early if not able to create a terminal
.build()
private val history = new DefaultHistory
+ def dumbRequested = Option(System.getenv("TERM")) == Some("dumb")
+
private def blue(str: String)(using Context) =
if (ctx.settings.color.value != "never") Console.BLUE + str + Console.RESET
else str
$ uname -a
MSYS_NT-10.0-19042 d5 3.1.7-340.x86_64 2020-11-08 12:32 UTC x86_64 Msys
philwalk@d5:~/workspace/dotty
$ scala
Starting scala3 REPL...
Exception in thread "main" java.lang.IllegalStateException: Unable to create a system terminal
at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:317)
at org.jline.terminal.TerminalBuilder.build(TerminalBuilder.java:263)
at dotty.tools.repl.JLineTerminal.<init>(JLineTerminal.scala:23)
at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:108)
at dotty.tools.repl.Main$.main(Main.scala:6)
at dotty.tools.repl.Main.main(Main.scala)
Suppressed: java.lang.NoClassDefFoundError: com/sun/jna/LastErrorException
at org.jline.terminal.impl.jna.JnaSupportImpl.isWindowsConsole(JnaSupportImpl.java:44)
at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:325)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.sun.jna.LastErrorException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 7 more
Suppressed: java.util.NoSuchElementException
at java.base/java.util.ServiceLoader$2.next(ServiceLoader.java:1308)
at java.base/java.util.ServiceLoader$2.next(ServiceLoader.java:1296)
at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
at org.jline.terminal.TerminalBuilder.load(TerminalBuilder.java:487)
at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:334)
... 5 more |
@philwalk Here is a first observation : the shell script In my case I get PS. Maybe I should also update my GitHub project |
@michelou Both $ uname
MINGW64_NT-10.0-19042
$ cygpath -m /
C:/opt/gitbash/
$ uname
MSYS_NT-10.0-19042
$ cygpath -m /
C:/msys64/
$ uname
CYGWIN_NT-10.0
$ cygpath -m /
C:/cygwin64 So a simplification to dist/bin/common would be: # winshell=true if any of $cygwin, $msys, or $mingw are true
# For Cygwin, Mingw and MSys, switch paths to Windows-mixed format before running java
if $winshell; then
[ -n "$PROG_HOME" ] &&
PROG_HOME=`cygpath -am "$PROG_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath -am "$JAVA_HOME"`
CLASSPATH_SUFFIX=";"
PSEP=";"
fi The advantage of using The same change would happen here as well: find_lib () {
local lib=$(find $PROG_HOME/lib/ -name "$1")
if $winshell; then
cygpath -am $lib
else
echo $lib
fi
}``` |
@philwalk It's also worth looking at the Unix template (
IMO introducing variable
In conclusion we need to investigate further. |
@michelou
The differences I have discovered between
The problem that dist/bin/common (line 73) addresses is better handled by Here's an approach that seems likely to provide a better result. $ has_cygpath=false
$ if `which cygpath.exe > /dev/null 2>&1`; then has_cygpath=true ; fi Then, instead of dist/bin/common (lines 73-105): # For Cygwin, switch paths to Windows-mixed format before running java
if $has_cygpath; then
[ -n "$PROG_HOME" ] &&
PROG_HOME=`cygpath -am "$PROG_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath -am "$JAVA_HOME"`
CLASSPATH_SUFFIX=";"
PSEP=";"
elif ($mingw || $msys); then
# For Mingw / Msys, ensure paths are in UNIX format before anything is touched
[ -n "$PROG_HOME" ] &&
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd -W | sed 's|/|\\\\|g')`"
CLASSPATH_SUFFIX=";"
PSEP=";"
fi
#/*--------------------------------------------------
# * The code below is for Dotty
# *-------------------------------------------------*/
find_lib () {
local lib=$(find $PROG_HOME/lib/ -name "$1")
if $has_cygpath; then
cygpath -am $lib
elif $mingw; then
echo $lib | sed 's|/|\\\\|g'
else
echo $lib
fi
} |
this fixes #11424
manually verified for currently defined dotc script-only options: