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

Ammonite-REPL doesn't work on Windows #119

Closed
lihaoyi opened this Issue Jul 25, 2015 · 41 comments

Comments

Projects
None yet
@lihaoyi
Owner

lihaoyi commented Jul 25, 2015

  • In my Windows 8.1 VM, compiling causes scalac to StackOverflow without any useful error message.
  • Trying to run the pre-compiled executable results in a "missing class java.lang.Object in mirror..." crash, indicating a classpath problem.

Would be nice if someone with a real windows machine/experience could dig into these and fix them

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Aug 5, 2015

Owner

Apparently it's giving problems in cygwin too

$ curl -L -o amm https://git.io/vO6Lo; chmod +x amm; ./amm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   406    0   406    0     0    401      0 --:--:--  0:00:01 --:--:--   401
100 29.3M  100 29.3M    0     0   444k      0  0:01:07  0:01:07 --:--:--  570k
Loading Ammonite Repl...
Exception in thread "main" scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
        at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
        at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
        at scala.reflect.internal.Mirrors$RootsBase.getClassByName(Mirrors.scala:102)
        at scala.reflect.internal.Mirrors$RootsBase.getRequiredClass(Mirrors.scala:105)
        at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
        at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
        at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1394)
        at scala.tools.nsc.Global$Run.<init>(Global.scala:1215)
        at ammonite.repl.interp.Compiler$$anon$4.<init>(Compiler.scala:142)
        at ammonite.repl.interp.Compiler$.apply(Compiler.scala:120)
        at ammonite.repl.interp.Interpreter.init(Interpreter.scala:225)
        at ammonite.repl.interp.Interpreter.<init>(Interpreter.scala:265)
        at ammonite.repl.Repl.<init>(Repl.scala:28)
        at ammonite.repl.Repl$.repl$1(Repl.scala:138)
        at ammonite.repl.Repl$.run(Repl.scala:146)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:130)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:130)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Repl$.main(Repl.scala:130)
        at ammonite.repl.Repl.main(Repl.scala)
Owner

lihaoyi commented Aug 5, 2015

Apparently it's giving problems in cygwin too

$ curl -L -o amm https://git.io/vO6Lo; chmod +x amm; ./amm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   406    0   406    0     0    401      0 --:--:--  0:00:01 --:--:--   401
100 29.3M  100 29.3M    0     0   444k      0  0:01:07  0:01:07 --:--:--  570k
Loading Ammonite Repl...
Exception in thread "main" scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
        at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
        at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
        at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
        at scala.reflect.internal.Mirrors$RootsBase.getClassByName(Mirrors.scala:102)
        at scala.reflect.internal.Mirrors$RootsBase.getRequiredClass(Mirrors.scala:105)
        at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
        at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
        at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1394)
        at scala.tools.nsc.Global$Run.<init>(Global.scala:1215)
        at ammonite.repl.interp.Compiler$$anon$4.<init>(Compiler.scala:142)
        at ammonite.repl.interp.Compiler$.apply(Compiler.scala:120)
        at ammonite.repl.interp.Interpreter.init(Interpreter.scala:225)
        at ammonite.repl.interp.Interpreter.<init>(Interpreter.scala:265)
        at ammonite.repl.Repl.<init>(Repl.scala:28)
        at ammonite.repl.Repl$.repl$1(Repl.scala:138)
        at ammonite.repl.Repl$.run(Repl.scala:146)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:130)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:130)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Repl$.main(Repl.scala:130)
        at ammonite.repl.Repl.main(Repl.scala)
@mslinn

This comment has been minimized.

Show comment
Hide comment
@mslinn

mslinn Aug 5, 2015

I get the identical problem above on two different machines that have Cygwin

mslinn commented Aug 5, 2015

I get the identical problem above on two different machines that have Cygwin

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Aug 5, 2015

Owner

Strange thing is it worked on cygwin last I tried; I really need to set up CI for this =/ otherwise I'll keep breaking it

Owner

lihaoyi commented Aug 5, 2015

Strange thing is it worked on cygwin last I tried; I really need to set up CI for this =/ otherwise I'll keep breaking it

@alexarchambault

This comment has been minimized.

Show comment
Hide comment
@alexarchambault

alexarchambault Aug 5, 2015

Collaborator

Setting up appveyor is quite straightforward, see https://github.com/sbt/sbt-native-packager/blob/master/appveyor.yml or https://github.com/alexarchambault/coursier/blob/master/appveyor.yml.

(I would have liked to help on this issue, but I don't have anymore access to the Windows machines I was using :-|)

Collaborator

alexarchambault commented Aug 5, 2015

Setting up appveyor is quite straightforward, see https://github.com/sbt/sbt-native-packager/blob/master/appveyor.yml or https://github.com/alexarchambault/coursier/blob/master/appveyor.yml.

(I would have liked to help on this issue, but I don't have anymore access to the Windows machines I was using :-|)

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Aug 5, 2015

Owner

@alexarchambault thanks for the pointers to the examples! I spent about an hour fiddling with it before giving up last time, will give it a shot

Owner

lihaoyi commented Aug 5, 2015

@alexarchambault thanks for the pointers to the examples! I spent about an hour fiddling with it before giving up last time, will give it a shot

@alexarchambault

This comment has been minimized.

Show comment
Hide comment
@alexarchambault

alexarchambault Aug 5, 2015

Collaborator

@lihaoyi Just struck me: I solved that at some point (so long a time ago that I forgot about it), I had to use File.pathSeparator here, instead of a hardcoded ":" :-)

Collaborator

alexarchambault commented Aug 5, 2015

@lihaoyi Just struck me: I solved that at some point (so long a time ago that I forgot about it), I had to use File.pathSeparator here, instead of a hardcoded ":" :-)

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Aug 5, 2015

Owner

Ahhh cool! I'll do that and try it in my ModernIE VM to see if it goes away.

I remember you told me the exact same thing before, and I thought I fixed it, but I guess I didn't

Owner

lihaoyi commented Aug 5, 2015

Ahhh cool! I'll do that and try it in my ModernIE VM to see if it goes away.

I remember you told me the exact same thing before, and I thought I fixed it, but I guess I didn't

@alexarchambault

This comment has been minimized.

Show comment
Hide comment
@alexarchambault

alexarchambault Aug 5, 2015

Collaborator

Did I? I must have forgotten that too then :-)

Collaborator

alexarchambault commented Aug 5, 2015

Did I? I must have forgotten that too then :-)

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Aug 6, 2015

Owner

I pushed a fix so trunk at least runs, and works great with colors turned off:

repl.colors() = ammonite.repl.Colors.BlackWhite

repl.frontEnd() = ammonite.repl.frontend.FrontEnd.JLineWindows

implicit val pprintConfig = pprint.Config.Defaults.PPrintConfig

Still some funniness around the terminals unfortunately =/ Probably will need a real windows user to put in the effort to make this works for reals

Owner

lihaoyi commented Aug 6, 2015

I pushed a fix so trunk at least runs, and works great with colors turned off:

repl.colors() = ammonite.repl.Colors.BlackWhite

repl.frontEnd() = ammonite.repl.frontend.FrontEnd.JLineWindows

implicit val pprintConfig = pprint.Config.Defaults.PPrintConfig

Still some funniness around the terminals unfortunately =/ Probably will need a real windows user to put in the effort to make this works for reals

@avakhrenev

This comment has been minimized.

Show comment
Hide comment
@avakhrenev

avakhrenev Sep 8, 2015

As of ammonite 0.4.7, it crashes on my machine with

Loading...
Welcome to the Ammonite Repl 0.4.7
(Scala 2.11.7 Java 1.8.0_51)
bash: /dev/tty: No such device or address
bash: /dev/tty: No such device or address
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 1
        at scala.sys.package$.error(package.scala:27)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        at ammonite.terminal.TTY$.stty(Utils.scala:78)
        at ammonite.terminal.TTY$.init(Utils.scala:57)
        at ammonite.terminal.TermCore$.x$6$lzycompute$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.x$6$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.initialConfig$lzycompute$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.initialConfig$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.readLine(TermCore.scala:240)
        at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:114)
        at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
        at ammonite.repl.Repl.action(Repl.scala:45)
        at ammonite.repl.Repl.loop$1(Repl.scala:78)
        at ammonite.repl.Repl.run(Repl.scala:96)
        at ammonite.repl.Repl$.run(Repl.scala:195)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:159)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:158)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Repl$.main(Repl.scala:158)
        at ammonite.repl.Repl.main(Repl.scala)

After replacing default front end to FrontEnd.JLineWindows in Repl.scala it works properly within sbt repl/run
Arrow keys work in stand-alone ammonite repl if you use jline.AnsiWindowsTerminal in JLineWindows frontend. However escape characters are displayed instead of some colors.

I'm using windows 7 64 bit, java8u51. I've tested this inside native windows console (cmd.exe). I also have cygwin installed.

avakhrenev commented Sep 8, 2015

As of ammonite 0.4.7, it crashes on my machine with

Loading...
Welcome to the Ammonite Repl 0.4.7
(Scala 2.11.7 Java 1.8.0_51)
bash: /dev/tty: No such device or address
bash: /dev/tty: No such device or address
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 1
        at scala.sys.package$.error(package.scala:27)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        at ammonite.terminal.TTY$.stty(Utils.scala:78)
        at ammonite.terminal.TTY$.init(Utils.scala:57)
        at ammonite.terminal.TermCore$.x$6$lzycompute$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.x$6$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.initialConfig$lzycompute$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.initialConfig$1(TermCore.scala:230)
        at ammonite.terminal.TermCore$.readLine(TermCore.scala:240)
        at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:114)
        at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
        at ammonite.repl.Repl.action(Repl.scala:45)
        at ammonite.repl.Repl.loop$1(Repl.scala:78)
        at ammonite.repl.Repl.run(Repl.scala:96)
        at ammonite.repl.Repl$.run(Repl.scala:195)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:159)
        at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:158)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Repl$.main(Repl.scala:158)
        at ammonite.repl.Repl.main(Repl.scala)

After replacing default front end to FrontEnd.JLineWindows in Repl.scala it works properly within sbt repl/run
Arrow keys work in stand-alone ammonite repl if you use jline.AnsiWindowsTerminal in JLineWindows frontend. However escape characters are displayed instead of some colors.

I'm using windows 7 64 bit, java8u51. I've tested this inside native windows console (cmd.exe). I also have cygwin installed.

yawo added a commit to yawo/Ammonite that referenced this issue Nov 2, 2015

Update Repl.scala
fix Issue lihaoyi#119.
After that change version and run sbt publishLocal to have the dependency in your ivy2 repo.

@lihaoyi lihaoyi added the enhancement label Dec 1, 2015

@nilskp

This comment has been minimized.

Show comment
Hide comment
@nilskp

nilskp Dec 13, 2015

Just tried 0.5.1 in Cygwin (64-bit)

Loading...
Welcome to the Ammonite Repl 0.5.1
(Scala 2.11.7 Java 1.8.0_66)
bash: /dev/tty: No such device or address
bash: /dev/tty: No such device or address
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 1
        at scala.sys.package$.error(package.scala:27)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        at ammonite.terminal.TTY$.stty(Utils.scala:85)
        at ammonite.terminal.TTY$.init(Utils.scala:64)
        at ammonite.terminal.TermCore$.x$6$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.x$6$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.readLine(TermCore.scala:254)
        at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:110)
        at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
        at ammonite.repl.Repl.action(Repl.scala:46)
        at ammonite.repl.Repl.loop$1(Repl.scala:79)
        at ammonite.repl.Repl.run(Repl.scala:97)
        at ammonite.repl.Main$.run(Main.scala:135)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:82)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:81)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Main$.main(Main.scala:81)
        at ammonite.repl.Main.main(Main.scala)

nilskp commented Dec 13, 2015

Just tried 0.5.1 in Cygwin (64-bit)

Loading...
Welcome to the Ammonite Repl 0.5.1
(Scala 2.11.7 Java 1.8.0_66)
bash: /dev/tty: No such device or address
bash: /dev/tty: No such device or address
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 1
        at scala.sys.package$.error(package.scala:27)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        at ammonite.terminal.TTY$.stty(Utils.scala:85)
        at ammonite.terminal.TTY$.init(Utils.scala:64)
        at ammonite.terminal.TermCore$.x$6$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.x$6$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.readLine(TermCore.scala:254)
        at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:110)
        at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
        at ammonite.repl.Repl.action(Repl.scala:46)
        at ammonite.repl.Repl.loop$1(Repl.scala:79)
        at ammonite.repl.Repl.run(Repl.scala:97)
        at ammonite.repl.Main$.run(Main.scala:135)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:82)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:81)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Main$.main(Main.scala:81)
        at ammonite.repl.Main.main(Main.scala)
@mnn

This comment has been minimized.

Show comment
Hide comment
@mnn

mnn Jan 21, 2016

This is unfortunate, I really wanted to try this 😞.

My error output looks a bit different (mingw):

Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_60)
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 127
        at scala.sys.package$.error(package.scala:27)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        at ammonite.terminal.TTY$.consoleDim(Utils.scala:61)
        at ammonite.terminal.TTY$.init(Utils.scala:66)
        at ammonite.terminal.TermCore$.x$6$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.x$6$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.readLine(TermCore.scala:254)
        at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:110)
        at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
        at ammonite.repl.Repl.action(Repl.scala:46)
        at ammonite.repl.Repl.loop$1(Repl.scala:79)
        at ammonite.repl.Repl.run(Repl.scala:97)
        at ammonite.repl.Main$.run(Main.scala:135)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:82)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:81)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Main$.main(Main.scala:81)
        at ammonite.repl.Main.main(Main.scala)

consoleDim?

mnn commented Jan 21, 2016

This is unfortunate, I really wanted to try this 😞.

My error output looks a bit different (mingw):

Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_60)
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 127
        at scala.sys.package$.error(package.scala:27)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        at ammonite.terminal.TTY$.consoleDim(Utils.scala:61)
        at ammonite.terminal.TTY$.init(Utils.scala:66)
        at ammonite.terminal.TermCore$.x$6$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.x$6$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$lzycompute$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.initialConfig$1(TermCore.scala:244)
        at ammonite.terminal.TermCore$.readLine(TermCore.scala:254)
        at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:110)
        at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
        at ammonite.repl.Repl.action(Repl.scala:46)
        at ammonite.repl.Repl.loop$1(Repl.scala:79)
        at ammonite.repl.Repl.run(Repl.scala:97)
        at ammonite.repl.Main$.run(Main.scala:135)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:82)
        at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:81)
        at scala.Option.foreach(Option.scala:257)
        at ammonite.repl.Main$.main(Main.scala:81)
        at ammonite.repl.Main.main(Main.scala)

consoleDim?

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Feb 14, 2016

Owner

@avakhrenev @mnn you need to tweak your predef as I described on Aug 16, 2015 (see above) to make this stand a chance of working at all. Note that it's still buggy, and is not in CI so is probably broken by now, but at least last I tried ~6 months ago it made something work without immediately crashing due to the error messages you two are seeing

Owner

lihaoyi commented Feb 14, 2016

@avakhrenev @mnn you need to tweak your predef as I described on Aug 16, 2015 (see above) to make this stand a chance of working at all. Note that it's still buggy, and is not in CI so is probably broken by now, but at least last I tried ~6 months ago it made something work without immediately crashing due to the error messages you two are seeing

@mnn

This comment has been minimized.

Show comment
Hide comment
@mnn

mnn Feb 14, 2016

@lihaoyi After changing the predef REPL started alright ^_^. But you are right, it's a bit buggy. For example ls! seems to be crashing on same issue REPL did before the change.

c:\Users\xxx\amm>java -jar amm
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_60)
xxx-amm@ ls!
res0: LsSeq =
java.lang.RuntimeException: Nonzero exit value: 127
        scala.sys.package$.error(package.scala:27)
        scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        ammonite.terminal.TTY$.consoleDim(Utils.scala:61)
        ammonite.repl.frontend.FrontEndUtils$.width(FrontEndUtils.scala:13)
        ammonite.shell.PPrints$$anonfun$lsSeqRepr$1$$anonfun$apply$1.apply(ShellSession.scala:43)
        ammonite.shell.PPrints$$anonfun$lsSeqRepr$1$$anonfun$apply$1.apply(ShellSession.scala:43)
        scala.collection.Iterator$JoinIterator.rhs$lzycompute(Iterator.scala:192)
        scala.collection.Iterator$JoinIterator.rhs(Iterator.scala:192)
        scala.collection.Iterator$JoinIterator.hasNext(Iterator.scala:193)
        scala.collection.Iterator$JoinIterator.hasNext(Iterator.scala:193)
        scala.collection.Iterator$JoinIterator.hasNext(Iterator.scala:193)
        scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:396)
        scala.collection.Iterator$class.foreach(Iterator.scala:742)
        scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
        ammonite.repl.Repl$$anonfun$action$4$$anonfun$apply$2$$anonfun$apply$3.apply(Repl.scala:60)
        ammonite.repl.Repl$$anonfun$action$4$$anonfun$apply$2$$anonfun$apply$3.apply(Repl.scala:60)
        ammonite.repl.interp.Evaluator$$anon$1$$anonfun$processLine$1$$anonfun$apply$10$$anonfun$apply$13$$anonfun$apply$15$$anonfun$apply$16$$anonfun$apply$1.apply$mcV$sp(Evaluator.scala:235)

xxx-amm@

It seems there's only a problem with output, after converting it to a List it gives right results.

xxx-amm@ (ls!).toList
res17: List[Path] = List(root/'Users/'xxx/'amm/'amm, root/'Users/'xxx/'amm/'hello, root/'Users/'xxx/'amm/'test)

I have tested everything in Shell Basics section and only LsSeq seems to be broken.

mnn commented Feb 14, 2016

@lihaoyi After changing the predef REPL started alright ^_^. But you are right, it's a bit buggy. For example ls! seems to be crashing on same issue REPL did before the change.

c:\Users\xxx\amm>java -jar amm
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_60)
xxx-amm@ ls!
res0: LsSeq =
java.lang.RuntimeException: Nonzero exit value: 127
        scala.sys.package$.error(package.scala:27)
        scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
        scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
        ammonite.terminal.TTY$.consoleDim(Utils.scala:61)
        ammonite.repl.frontend.FrontEndUtils$.width(FrontEndUtils.scala:13)
        ammonite.shell.PPrints$$anonfun$lsSeqRepr$1$$anonfun$apply$1.apply(ShellSession.scala:43)
        ammonite.shell.PPrints$$anonfun$lsSeqRepr$1$$anonfun$apply$1.apply(ShellSession.scala:43)
        scala.collection.Iterator$JoinIterator.rhs$lzycompute(Iterator.scala:192)
        scala.collection.Iterator$JoinIterator.rhs(Iterator.scala:192)
        scala.collection.Iterator$JoinIterator.hasNext(Iterator.scala:193)
        scala.collection.Iterator$JoinIterator.hasNext(Iterator.scala:193)
        scala.collection.Iterator$JoinIterator.hasNext(Iterator.scala:193)
        scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:396)
        scala.collection.Iterator$class.foreach(Iterator.scala:742)
        scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
        ammonite.repl.Repl$$anonfun$action$4$$anonfun$apply$2$$anonfun$apply$3.apply(Repl.scala:60)
        ammonite.repl.Repl$$anonfun$action$4$$anonfun$apply$2$$anonfun$apply$3.apply(Repl.scala:60)
        ammonite.repl.interp.Evaluator$$anon$1$$anonfun$processLine$1$$anonfun$apply$10$$anonfun$apply$13$$anonfun$apply$15$$anonfun$apply$16$$anonfun$apply$1.apply$mcV$sp(Evaluator.scala:235)

xxx-amm@

It seems there's only a problem with output, after converting it to a List it gives right results.

xxx-amm@ (ls!).toList
res17: List[Path] = List(root/'Users/'xxx/'amm/'amm, root/'Users/'xxx/'amm/'hello, root/'Users/'xxx/'amm/'test)

I have tested everything in Shell Basics section and only LsSeq seems to be broken.

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Feb 14, 2016

Owner

I'd guess the tabulate function that LsSeq uses is making use of shell-primitives to get the width and adjust the tabulation accordingly. That will need to be stubbed out. I'm surprised the other stuff actually worked!

There's a lot of hidden dependencies on the POSIX/Bash/Unix shell scattered throughout the program. Solving this would involve extracting them into a single place and letting us swap in Windows versions of all the functionality.

More important, I think, would be for someone to set up Windows CI so we can make sure any fixes don't regress as @mnn was (rightly) worried about

Owner

lihaoyi commented Feb 14, 2016

I'd guess the tabulate function that LsSeq uses is making use of shell-primitives to get the width and adjust the tabulation accordingly. That will need to be stubbed out. I'm surprised the other stuff actually worked!

There's a lot of hidden dependencies on the POSIX/Bash/Unix shell scattered throughout the program. Solving this would involve extracting them into a single place and letting us swap in Windows versions of all the functionality.

More important, I think, would be for someone to set up Windows CI so we can make sure any fixes don't regress as @mnn was (rightly) worried about

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Feb 22, 2016

Owner

Ammonite-Ops now works on Windows, so that's one step forward. I also set up Windows CI in https://ci.appveyor.com/project/lihaoyi/ammonite

If anyone wants to take a crack at this, I'd be glad to walk you through

Owner

lihaoyi commented Feb 22, 2016

Ammonite-Ops now works on Windows, so that's one step forward. I also set up Windows CI in https://ci.appveyor.com/project/lihaoyi/ammonite

If anyone wants to take a crack at this, I'd be glad to walk you through

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Apr 11, 2016

Owner

If the new Windows 10 Ubuntu stuff turns out well we may not have to do this at all!

Owner

lihaoyi commented Apr 11, 2016

If the new Windows 10 Ubuntu stuff turns out well we may not have to do this at all!

@vega113

This comment has been minimized.

Show comment
Hide comment
@vega113

vega113 May 4, 2016

Have the same issue on WIn7 and Cygwin

      C:\Users\yuri.zelikov\devroot>java -jar amm
 Loading...
 Welcome to the Ammonite Repl 0.5.7
 (Scala 2.11.8 Java 1.8.0_77)
 /usr/bin/bash: /dev/tty: No such device or address
 /usr/bin/bash: /dev/tty: No such device or address
 Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 1
 at scala.sys.package$.error(package.scala:27)
 at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
 at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
 at ammonite.terminal.TTY$.stty(Utils.scala:118)
 at ammonite.terminal.TTY$.init(Utils.scala:97)
 at ammonite.terminal.Terminal$.x$7$lzycompute$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.x$7$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.initialConfig$lzycompute$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.initialConfig$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.readLine(Terminal.scala:309)
 at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:117)
 at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:27)
 at ammonite.repl.Repl.action(Repl.scala:55)
 at ammonite.repl.Repl.loop$1(Repl.scala:88)
 at ammonite.repl.Repl.run(Repl.scala:106)
 at ammonite.repl.Main$.run(Main.scala:136)
 at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:87)
 at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:85)
 at scala.Option.foreach(Option.scala:257)
 at ammonite.repl.Main$.main(Main.scala:85)
 at ammonite.repl.Main.main(Main.scala)

 C:\Users\yuri.zelikov\devroot>

vega113 commented May 4, 2016

Have the same issue on WIn7 and Cygwin

      C:\Users\yuri.zelikov\devroot>java -jar amm
 Loading...
 Welcome to the Ammonite Repl 0.5.7
 (Scala 2.11.8 Java 1.8.0_77)
 /usr/bin/bash: /dev/tty: No such device or address
 /usr/bin/bash: /dev/tty: No such device or address
 Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 1
 at scala.sys.package$.error(package.scala:27)
 at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
 at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
 at ammonite.terminal.TTY$.stty(Utils.scala:118)
 at ammonite.terminal.TTY$.init(Utils.scala:97)
 at ammonite.terminal.Terminal$.x$7$lzycompute$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.x$7$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.initialConfig$lzycompute$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.initialConfig$1(Terminal.scala:299)
 at ammonite.terminal.Terminal$.readLine(Terminal.scala:309)
 at ammonite.repl.frontend.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:117)
 at ammonite.repl.frontend.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:27)
 at ammonite.repl.Repl.action(Repl.scala:55)
 at ammonite.repl.Repl.loop$1(Repl.scala:88)
 at ammonite.repl.Repl.run(Repl.scala:106)
 at ammonite.repl.Main$.run(Main.scala:136)
 at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:87)
 at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:85)
 at scala.Option.foreach(Option.scala:257)
 at ammonite.repl.Main$.main(Main.scala:85)
 at ammonite.repl.Main.main(Main.scala)

 C:\Users\yuri.zelikov\devroot>
@djx314

This comment has been minimized.

Show comment
Hide comment
@djx314

djx314 Jun 6, 2016

There is a workaround.
Add this to your build.sbt

{
  if (scala.util.Properties.isWin)
    initialCommands in (Test, console) += s"""ammonite.repl.Repl.run("repl.frontEnd() = ammonite.repl.frontend.FrontEnd.JLineWindows");"""
  else
    initialCommands in (Test, console) += s"""ammonite.repl.Repl.run("");"""
}

2016-06-07
Some fixes suggested by @lihaoyi

djx314 commented Jun 6, 2016

There is a workaround.
Add this to your build.sbt

{
  if (scala.util.Properties.isWin)
    initialCommands in (Test, console) += s"""ammonite.repl.Repl.run("repl.frontEnd() = ammonite.repl.frontend.FrontEnd.JLineWindows");"""
  else
    initialCommands in (Test, console) += s"""ammonite.repl.Repl.run("");"""
}

2016-06-07
Some fixes suggested by @lihaoyi

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Jun 6, 2016

Owner

FWIW, if you want to check mac windows there's scala.util.Properties.isMac scala.util.Properties.isWin

There doesn't appear to be one for Linux, I guess that's just the "everything else" case :P

Owner

lihaoyi commented Jun 6, 2016

FWIW, if you want to check mac windows there's scala.util.Properties.isMac scala.util.Properties.isWin

There doesn't appear to be one for Linux, I guess that's just the "everything else" case :P

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Jul 22, 2016

Owner

Thanks to @coderabhishek's efforts, the vast bulk of Ammonite's tests are now passing in our Windows CI in the latest published snapshot artifact. http://www.lihaoyi.com/Ammonite/master/#Ammonite-REPL. If you want to run scripts using Ammonite's script-running functionality on windows, it should just work.

The last stretch is getting some semblance of the REPL working automatically on windows. This can be done in two steps:

  • Make windows default to the JLineFrontEnd and Colors.BlackWhite; if we can't make the fancy stuff work, at least the non-fancy stuff should still be there. There are probably some bugs that will need to be fixed to make it work flawlessly, but I doubt it'll be a lot of work
  • Make the fancy AmmoniteFrontEnd work on windows, possibly using Jansi or similar to translate the color codes over

I don't have the time to work on either of these myself, but if someone wants to take up this cup I'll gladly help.

Owner

lihaoyi commented Jul 22, 2016

Thanks to @coderabhishek's efforts, the vast bulk of Ammonite's tests are now passing in our Windows CI in the latest published snapshot artifact. http://www.lihaoyi.com/Ammonite/master/#Ammonite-REPL. If you want to run scripts using Ammonite's script-running functionality on windows, it should just work.

The last stretch is getting some semblance of the REPL working automatically on windows. This can be done in two steps:

  • Make windows default to the JLineFrontEnd and Colors.BlackWhite; if we can't make the fancy stuff work, at least the non-fancy stuff should still be there. There are probably some bugs that will need to be fixed to make it work flawlessly, but I doubt it'll be a lot of work
  • Make the fancy AmmoniteFrontEnd work on windows, possibly using Jansi or similar to translate the color codes over

I don't have the time to work on either of these myself, but if someone wants to take up this cup I'll gladly help.

@iharh

This comment has been minimized.

Show comment
Hide comment
@iharh

iharh Dec 15, 2016

I've tried ammonite repl on windows at MSYS2+ConEmu. Colors works fine (no need for setting Collors.BlackWhite). We still has problems with stty+/dev/tty, but that need to be fixed either via migrating to the jline3 or using something like jansi/lanterna/...

iharh commented Dec 15, 2016

I've tried ammonite repl on windows at MSYS2+ConEmu. Colors works fine (no need for setting Collors.BlackWhite). We still has problems with stty+/dev/tty, but that need to be fixed either via migrating to the jline3 or using something like jansi/lanterna/...

@mmagyar

This comment has been minimized.

Show comment
Hide comment
@mmagyar

mmagyar Dec 23, 2016

The shell works correctly on the latest Windows Subsystem for Linux (WSL) , tested with oracle-java8 and Scala 2.11.8. It's not too bad, although the limitations of WSL make it a bit less then optimal ( you can't run windows binaries directly from there, but there are workarounds)

mmagyar commented Dec 23, 2016

The shell works correctly on the latest Windows Subsystem for Linux (WSL) , tested with oracle-java8 and Scala 2.11.8. It's not too bad, although the limitations of WSL make it a bit less then optimal ( you can't run windows binaries directly from there, but there are workarounds)

@mslinn

This comment has been minimized.

Show comment
Hide comment
@mslinn

mslinn Dec 23, 2016

Any idea when the general public will see this version of WSL?

mslinn commented Dec 23, 2016

Any idea when the general public will see this version of WSL?

@mmagyar

This comment has been minimized.

Show comment
Hide comment
@mmagyar

mmagyar Dec 23, 2016

@mslinn I'm not sure what are thinking of, This is what's publicly available, all you have to do is to switch windows to developer mode (settings -> update & security -> for developers -> developer mode) and then in the "turn Windows features on or off" select "Windows subsystem for Linux (beta)" and then you can use it, it will install a native "bash.exe", that will start this subsystem.

mmagyar commented Dec 23, 2016

@mslinn I'm not sure what are thinking of, This is what's publicly available, all you have to do is to switch windows to developer mode (settings -> update & security -> for developers -> developer mode) and then in the "turn Windows features on or off" select "Windows subsystem for Linux (beta)" and then you can use it, it will install a native "bash.exe", that will start this subsystem.

@mmagyar

This comment has been minimized.

Show comment
Hide comment
@mmagyar

mmagyar Dec 23, 2016

I'm using the default settings for Windows 10 Pro, not the insider or preview builds, and i don't defer updates. I guess that's the latest stable version.

mmagyar commented Dec 23, 2016

I'm using the default settings for Windows 10 Pro, not the insider or preview builds, and i don't defer updates. I guess that's the latest stable version.

@mslinn

This comment has been minimized.

Show comment
Hide comment
@mslinn

mslinn Feb 24, 2017

This code works fine on Linux, but on Windows Subsystem for Linux it never gives the REPL prompt:

  import ammonite.util.Bind
  import scala.concurrent.duration.Duration
  import scala.concurrent.{Await, Promise}

  def localRepl(replArgs: Seq[Bind[_]]=Nil): Any = {
    val jLine = if (scala.util.Properties.isWin) "JLineWindows" else "JLineUnix"
    Future { // TODO does running the REPL on another thread cause problems with out-of-date values?
      while (true) {
        ammonite.Main(
          predef = s"""repl.frontEnd() = ammonite.repl.FrontEnd.$jLine
                      |def stop(): Unit = System.exit(0)
                      |println(Console.RED + "Type stop, wait a second, then Control-C to terminate this program" + Console.RESET)
                      |""".stripMargin
        ).instantiateRepl(replArgs).run()
        println("Restarting REPL.")
      }
    }
  }

  val shutdownPromise = Promise[String]
  localRepl()
  Await.ready(shutdownPromise.future, Duration.Inf)
  System.exit(0)

mslinn commented Feb 24, 2017

This code works fine on Linux, but on Windows Subsystem for Linux it never gives the REPL prompt:

  import ammonite.util.Bind
  import scala.concurrent.duration.Duration
  import scala.concurrent.{Await, Promise}

  def localRepl(replArgs: Seq[Bind[_]]=Nil): Any = {
    val jLine = if (scala.util.Properties.isWin) "JLineWindows" else "JLineUnix"
    Future { // TODO does running the REPL on another thread cause problems with out-of-date values?
      while (true) {
        ammonite.Main(
          predef = s"""repl.frontEnd() = ammonite.repl.FrontEnd.$jLine
                      |def stop(): Unit = System.exit(0)
                      |println(Console.RED + "Type stop, wait a second, then Control-C to terminate this program" + Console.RESET)
                      |""".stripMargin
        ).instantiateRepl(replArgs).run()
        println("Restarting REPL.")
      }
    }
  }

  val shutdownPromise = Promise[String]
  localRepl()
  Await.ready(shutdownPromise.future, Duration.Inf)
  System.exit(0)
@carlrosenberger

This comment has been minimized.

Show comment
Hide comment
@carlrosenberger

carlrosenberger Mar 15, 2017

I am trying to use ammonite on Windows. Principally it seems to works but there is one ugly bug that hurts a lot: The key for the square closing bracket ']' does not work. Also copying from the clipboard swallows some characters. Is there a workaround?

Thanks for this very nice REPL, lihaoyi !

Edited: The bracket key only fails with German keyboard layout, with layout US it works.

carlrosenberger commented Mar 15, 2017

I am trying to use ammonite on Windows. Principally it seems to works but there is one ugly bug that hurts a lot: The key for the square closing bracket ']' does not work. Also copying from the clipboard swallows some characters. Is there a workaround?

Thanks for this very nice REPL, lihaoyi !

Edited: The bracket key only fails with German keyboard layout, with layout US it works.

@bblfish

This comment has been minimized.

Show comment
Hide comment
@bblfish

bblfish Jul 5, 2017

just to confirm. Ammonite seems to work very well on latest version of Windows WSL. But, we found that the openjdk had problems with the threadPool. Where we asked in to create 50 max it only ever created 2. The version we had trouble with was:

openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

Installing the Oracle JDK solved that problem. We followed the instructions here:

https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8

bblfish commented Jul 5, 2017

just to confirm. Ammonite seems to work very well on latest version of Windows WSL. But, we found that the openjdk had problems with the threadPool. Where we asked in to create 50 max it only ever created 2. The version we had trouble with was:

openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

Installing the Oracle JDK solved that problem. We followed the instructions here:

https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8

@mslinn

This comment has been minimized.

Show comment
Hide comment
@mslinn

mslinn Jul 5, 2017

Yes, I also find that Ammonite works fine with WSL and Oracle JDK

mslinn commented Jul 5, 2017

Yes, I also find that Ammonite works fine with WSL and Oracle JDK

@dray17

This comment has been minimized.

Show comment
Hide comment
@dray17

dray17 Jul 24, 2017

I got Ammonite to work on Windows with colors using the standard "amm" download (no tweaking source or compiling). No Cygwin or git bash, just "Cmder" terminal.

  • colors look beautiful
  • console editing: "Home, End, Left/Right arrows, etc. work
  • console history editing: Up/Down arrows work
  • editing multi-line history works but not as nicely as it is supposed to:
    • the moving back to a previous command you get one line with embedded newlines and tabs (^M^J)
    • you can edit this line and execute the command (even though it looks strange)

There are two keys to this solution:

  • using "Cmder" terminal (conemu) which can handle xterm type sequences while still being a windows terminal.
  • simply passing in the JLineWindows terminal type while starting Ammonite. There is no command line option for that, so I send in a command to programmatically set it inside of Ammonite.

Here is breakdown:

  • running on Windows 8.1
  • using Oracle java version "1.8.0_141"
  • download ammonite REPL (http://ammonite.io/#Ammonite-REPL)
    • select the version of ammonite (stable, latest) and grab the URL that looks like: https://git.io/vQEhd
    • in browser, paste the URL and save the file - it will have a name like "2.12-1.0.0"
  • rename file to something like "amm-2.12-1.0.0.jar" (prepend "amm-", and append ".jar")
  • move file to somewhere appropriate (d:\tools\ammonite\amm-2.12-1.0.0.jar)
  • start Cmder terminal (http://cmder.net/)
  • java -Xmx500m -XX:+UseG1GC -jar d:\tools\ammonite\amm-2.12-1.0.0.jar --predef-code "repl.frontEnd() = ammonite.repl.FrontEnd.JLineWindows"

The "-X" parameters came from looking at the first line of the downloaded file. In a Unix environment, it would use that first line to know how to start java. In Windows we have to explicitly start Java, so we add these parameters to keep the behavior as similar as possible.

One issue is that editing a multi-line command doesn't work quite right when trying to edit previous lines.
I hope this will save someone the hours of agony that I went through.

Dan

dray17 commented Jul 24, 2017

I got Ammonite to work on Windows with colors using the standard "amm" download (no tweaking source or compiling). No Cygwin or git bash, just "Cmder" terminal.

  • colors look beautiful
  • console editing: "Home, End, Left/Right arrows, etc. work
  • console history editing: Up/Down arrows work
  • editing multi-line history works but not as nicely as it is supposed to:
    • the moving back to a previous command you get one line with embedded newlines and tabs (^M^J)
    • you can edit this line and execute the command (even though it looks strange)

There are two keys to this solution:

  • using "Cmder" terminal (conemu) which can handle xterm type sequences while still being a windows terminal.
  • simply passing in the JLineWindows terminal type while starting Ammonite. There is no command line option for that, so I send in a command to programmatically set it inside of Ammonite.

Here is breakdown:

  • running on Windows 8.1
  • using Oracle java version "1.8.0_141"
  • download ammonite REPL (http://ammonite.io/#Ammonite-REPL)
    • select the version of ammonite (stable, latest) and grab the URL that looks like: https://git.io/vQEhd
    • in browser, paste the URL and save the file - it will have a name like "2.12-1.0.0"
  • rename file to something like "amm-2.12-1.0.0.jar" (prepend "amm-", and append ".jar")
  • move file to somewhere appropriate (d:\tools\ammonite\amm-2.12-1.0.0.jar)
  • start Cmder terminal (http://cmder.net/)
  • java -Xmx500m -XX:+UseG1GC -jar d:\tools\ammonite\amm-2.12-1.0.0.jar --predef-code "repl.frontEnd() = ammonite.repl.FrontEnd.JLineWindows"

The "-X" parameters came from looking at the first line of the downloaded file. In a Unix environment, it would use that first line to know how to start java. In Windows we have to explicitly start Java, so we add these parameters to keep the behavior as similar as possible.

One issue is that editing a multi-line command doesn't work quite right when trying to edit previous lines.
I hope this will save someone the hours of agony that I went through.

Dan

@eyalroth

This comment has been minimized.

Show comment
Hide comment
@eyalroth

eyalroth Aug 13, 2017

Trying to run it from cmd with java -jar file just print this exception over and over:

java.lang.RuntimeException: Nonzero exit value: -1
  scala.sys.package$.error(package.scala:27)
  scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
  scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
  ammonite.terminal.TTY$.stty(Utils.scala:118)
  ammonite.terminal.TTY$.init(Utils.scala:97)
  ammonite.terminal.Terminal$.x$1$lzycompute$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.x$1$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.initialConfig$lzycompute$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.initialConfig$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.readLine(Terminal.scala:52)
  ammonite.repl.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:113)
  ammonite.repl.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
  ammonite.repl.Repl$$anonfun$action$2.apply(Repl.scala:140)
  ammonite.repl.Repl$$anonfun$action$2.apply(Repl.scala:132)
  ammonite.util.Catching.flatMap(Res.scala:109)
  ammonite.repl.Repl.action(Repl.scala:132)
  ammonite.repl.Repl.loop$1(Repl.scala:172)
  ammonite.repl.Repl.run(Repl.scala:188)
  ammonite.Main$$anonfun$run$2.apply(Main.scala:191)
  ammonite.Main$$anonfun$run$2.apply(Main.scala:178)
  scala.Option.getOrElse(Option.scala:121)
  ammonite.Main.run(Main.scala:178)
  ammonite.MainRunner$$anonfun$runRepl$1.apply(Main.scala:355)
  ammonite.MainRunner$$anonfun$runRepl$1.apply(Main.scala:355)
  ammonite.MainRunner.watchLoop(Main.scala:336)
  ammonite.MainRunner.runRepl(Main.scala:355)
  ammonite.Main$.main0(Main.scala:277)
  ammonite.Main$.main(Main.scala:241)
  ammonite.Main.main(Main.scala)�[39m

This could be fixed by adding --predef-code "repl.frontEnd() = ammonite.repl.FrontEnd.JLineWindows" to the command (as pointed out by @dray17), but then the REPL doesn't support even the simplest console functions -- such as moving the cursor with the arrow-keys -- has a funny prompt, and lacks colors.

Running the jar directly (no java -jar) from bash (WSL) starts the REPL with the basic console functions; alas, many other operations don't work; such as moving between words, selecting, etc. Also, the time it takes to evaluate expressions is extremely slow.

I'm running the latest version (2.12-1.0.1) on Windows 10 with Oracle JDK 1.8.0_144.

This kind of makes the tool unusable to me as a Windows user.

eyalroth commented Aug 13, 2017

Trying to run it from cmd with java -jar file just print this exception over and over:

java.lang.RuntimeException: Nonzero exit value: -1
  scala.sys.package$.error(package.scala:27)
  scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
  scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
  ammonite.terminal.TTY$.stty(Utils.scala:118)
  ammonite.terminal.TTY$.init(Utils.scala:97)
  ammonite.terminal.Terminal$.x$1$lzycompute$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.x$1$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.initialConfig$lzycompute$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.initialConfig$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.readLine(Terminal.scala:52)
  ammonite.repl.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:113)
  ammonite.repl.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
  ammonite.repl.Repl$$anonfun$action$2.apply(Repl.scala:140)
  ammonite.repl.Repl$$anonfun$action$2.apply(Repl.scala:132)
  ammonite.util.Catching.flatMap(Res.scala:109)
  ammonite.repl.Repl.action(Repl.scala:132)
  ammonite.repl.Repl.loop$1(Repl.scala:172)
  ammonite.repl.Repl.run(Repl.scala:188)
  ammonite.Main$$anonfun$run$2.apply(Main.scala:191)
  ammonite.Main$$anonfun$run$2.apply(Main.scala:178)
  scala.Option.getOrElse(Option.scala:121)
  ammonite.Main.run(Main.scala:178)
  ammonite.MainRunner$$anonfun$runRepl$1.apply(Main.scala:355)
  ammonite.MainRunner$$anonfun$runRepl$1.apply(Main.scala:355)
  ammonite.MainRunner.watchLoop(Main.scala:336)
  ammonite.MainRunner.runRepl(Main.scala:355)
  ammonite.Main$.main0(Main.scala:277)
  ammonite.Main$.main(Main.scala:241)
  ammonite.Main.main(Main.scala)�[39m

This could be fixed by adding --predef-code "repl.frontEnd() = ammonite.repl.FrontEnd.JLineWindows" to the command (as pointed out by @dray17), but then the REPL doesn't support even the simplest console functions -- such as moving the cursor with the arrow-keys -- has a funny prompt, and lacks colors.

Running the jar directly (no java -jar) from bash (WSL) starts the REPL with the basic console functions; alas, many other operations don't work; such as moving between words, selecting, etc. Also, the time it takes to evaluate expressions is extremely slow.

I'm running the latest version (2.12-1.0.1) on Windows 10 with Oracle JDK 1.8.0_144.

This kind of makes the tool unusable to me as a Windows user.

@glmars

This comment has been minimized.

Show comment
Hide comment
@glmars

glmars Sep 18, 2017

Additional problem on Windows: "object ? is not a member of package cats" after import "cats._"

I run Ammonite on Windows with cmder by this instruction: #119 (comment)

After I import "cats._" any of the following commands lead to "Compilation Failed" error.

Welcome to the Ammonite Repl 1.0.2
(Scala 2.12.3 Java 1.8.0_144)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`org.typelevel::cats-core:1.0.0-MF`
import $ivy.$

@ import cats._
import cats._

@ exit
cmd2.sc:63: object ? is not a member of package cats
import _root_.cats.{
       ^
Compilation Failed

glmars commented Sep 18, 2017

Additional problem on Windows: "object ? is not a member of package cats" after import "cats._"

I run Ammonite on Windows with cmder by this instruction: #119 (comment)

After I import "cats._" any of the following commands lead to "Compilation Failed" error.

Welcome to the Ammonite Repl 1.0.2
(Scala 2.12.3 Java 1.8.0_144)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`org.typelevel::cats-core:1.0.0-MF`
import $ivy.$

@ import cats._
import cats._

@ exit
cmd2.sc:63: object ? is not a member of package cats
import _root_.cats.{
       ^
Compilation Failed
@Axiometry

This comment has been minimized.

Show comment
Hide comment
@Axiometry

Axiometry Dec 6, 2017

I have managed to make Ammonite 1.0.3 mostly functional under Cygwin. The changes I made can be found at:

Axiometry@14a1bf9

The changes are:

  • Set the frontend to JLineWindows (this can be done in the predef)
  • Convert the path to amm in the prepended script to Windows via cygpath -w
  • Switch to sbt-assembly 0.14.6 due to sbt/sbt-assembly#209 (make sure you sbt clean after switching)
  • Don't write err to /dev/tty in TTY.consoleDim

Most of these are hacks and need proper workarounds. Just leaving this here for anyone looking to use Ammonite with Cygwin.

Axiometry commented Dec 6, 2017

I have managed to make Ammonite 1.0.3 mostly functional under Cygwin. The changes I made can be found at:

Axiometry@14a1bf9

The changes are:

  • Set the frontend to JLineWindows (this can be done in the predef)
  • Convert the path to amm in the prepended script to Windows via cygpath -w
  • Switch to sbt-assembly 0.14.6 due to sbt/sbt-assembly#209 (make sure you sbt clean after switching)
  • Don't write err to /dev/tty in TTY.consoleDim

Most of these are hacks and need proper workarounds. Just leaving this here for anyone looking to use Ammonite with Cygwin.

@nilskp

This comment has been minimized.

Show comment
Hide comment
@nilskp

nilskp Dec 6, 2017

nilskp commented Dec 6, 2017

@lihaoyi

This comment has been minimized.

Show comment
Hide comment
@lihaoyi

lihaoyi Apr 7, 2018

Owner

@robby-phd can we close this?

Owner

lihaoyi commented Apr 7, 2018

@robby-phd can we close this?

@eyalroth

This comment has been minimized.

Show comment
Hide comment
@eyalroth

eyalroth Apr 8, 2018

In case you're not aware, Windows (10) now has built-in bash via Ubuntu.
After many years, I've finally switched off Cygwin.

Do note that it is only available for Pro versions of Windows 10 (not Home) and requires a manual installation procedure (quite short, but still).

eyalroth commented Apr 8, 2018

In case you're not aware, Windows (10) now has built-in bash via Ubuntu.
After many years, I've finally switched off Cygwin.

Do note that it is only available for Pro versions of Windows 10 (not Home) and requires a manual installation procedure (quite short, but still).

@robby-phd

This comment has been minimized.

Show comment
Hide comment
@robby-phd

robby-phd Apr 9, 2018

Collaborator

Ammonite now supports Windows (both batch or sh environments), though support for MSYS2 subsystem needs to wait until the next jline3 release.

@lihaoyi When the next stable version is released, the installation instructions for stable releases should be changed similar to what is in the unstable section.

Collaborator

robby-phd commented Apr 9, 2018

Ammonite now supports Windows (both batch or sh environments), though support for MSYS2 subsystem needs to wait until the next jline3 release.

@lihaoyi When the next stable version is released, the installation instructions for stable releases should be changed similar to what is in the unstable section.

@robby-phd robby-phd closed this Apr 9, 2018

@stevebakh

This comment has been minimized.

Show comment
Hide comment
@stevebakh

stevebakh Jun 19, 2018

Do note that it is only available for Pro versions of Windows 10 (not Home) and requires a manual installation procedure (quite short, but still).

This isn't true - the WSL is supported on Windows 10 home edition, too. Installation is fairly straightforward.

stevebakh commented Jun 19, 2018

Do note that it is only available for Pro versions of Windows 10 (not Home) and requires a manual installation procedure (quite short, but still).

This isn't true - the WSL is supported on Windows 10 home edition, too. Installation is fairly straightforward.

@eyalroth

This comment has been minimized.

Show comment
Hide comment
@eyalroth

eyalroth Jun 19, 2018

This isn't true - the WSL is supported on Windows 10 home edition, too. Installation is fairly straightforward.

You are correct, I really don't know why I said what I said. Perhaps I was confusing WSL with Hyper-V (which is required for Docker, but that is a different story).

eyalroth commented Jun 19, 2018

This isn't true - the WSL is supported on Windows 10 home edition, too. Installation is fairly straightforward.

You are correct, I really don't know why I said what I said. Perhaps I was confusing WSL with Hyper-V (which is required for Docker, but that is a different story).

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