Git Bash for Windows not working 'lein repl' command
Asked Answered
L

5

2

I'm actually using git bash instead of default windows command shell (cmd).
But I cannot run 'lein repl' in git bash.
It doesn't show anything and I must press crtl + c to regain control.

Any suggestion? Thank you.

-- EDIT

I'm running lein instead of lein.bat because I added alias lein=lein.bat in my .bashrc, so I don't think it is a problem.

lein run is working fine in Git Bash and leiningen works fine in windows cmd. The problem is explicity with lein repl.

When I run which lein I got which: no lein in ([MY-PATH-VAR])

Linguistician answered 29/9, 2016 at 4:7 Comment(3)
Just checked, it works for me when I run lein.bat in git bash. Can you give a bit more details - your PATH, how you try to run lein under bash, if you can run java in bash etc?Brothel
I've added an edit. Tell me if you need any more information. Thank youLinguistician
Hmmm.. no idea what can be happening if lein run works and lein repl doesn't. Are you inside a project? Can you try lein repl outside of any project? Maybe even without lein profiles. Just shooting in the dark.Brothel
C
3

First Check if you have installed lein.bat in windows using below command in command prompt lein --version

Then if lein is available, then in your git bash type the below command alias lein='lein.bat'

Thein run your lein command it will work for sure...

Carnage answered 9/1, 2020 at 9:49 Comment(0)
C
1

I had exactly the same problem as ThomasH where calling lein repl from an Emacs shell would get me the introductory messages and a prompt ...

nREPL server started on port 55801 on host 127.0.0.1 - nrepl://127.0.0.1:55801
REPL-y 0.4.4, nREPL 0.8.3
Clojure 1.10.1
Java HotSpot(TM) 64-Bit Server VM 15.0.2+7-27
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

... but seemingly freeze when I try to get it to do anything, like:

user=> (+ 1 2 3 8) 

When I open up the Task Manager, I could see the underlying Java program continuously at ~30% CPU for no apparent reason, and the only way I could reliably get out of it was to end the Java process from there.

But through a lot of effort, I finally figured out that the reason this was happening was a shell environment variable TERM=emacs. Whenever you call M-x shell, the function comint-term-environment puts it in for you.

(According to the source code in comint.el, it's done so that it "lets us specify a width". And it also mentions that "Some programs that use terminfo get very confused if TERM is not a valid terminal type". So there you have it - it looks like Java is one of those.)

To resolve this, you can set the variable system-uses-terminfo to 't before calling M-x shell.

(setq system-uses-terminfo t) 

After having done so, Java is now finally responsive and I can evaluate things in the repl.

user=> (+ 1 2 3 8) 
14

If you have this problem and got fortunate enough to stumble here, I hope this helps! =D

Coma answered 19/3, 2021 at 13:6 Comment(1)
OP is not working in Emacs, so I'm not sure if this answer is helpful.Gerlac
C
1

The following worked for me to get this running in Git bash on Windows 10. When I originally got this working, it was freezing, but this post helped me figure out how to fix by including winpty.

  1. If you haven't added the lein.bat file to your Path variable, then do steps 1-3. Otherwise, skip to 4. In the System Properties -> Advanced -> Environment Variables area, select the Path variable
  2. Click Edit and add the directory containing lein.bat to this. Mine was C:\Program Files (x86)\lein - lein.bat was stored inside the lein folder
  3. Click OK until you close out of the prompts
  4. Confirm the update worked by opening a command prompt (windows key, then type cmd)
  5. Enter lein. If you haven't already, it should prompt you to run the install command. Do this if prompted, then enter lein again to make sure it worked (should output help menu)
  6. Close out of Git bash if already open, then open again
  7. Enter alias repl='winpty lein.bat repl'. You can choose what you want the alias to be, I used repl
  8. Type repl (or whatever alias you added). Should take a second, then begin a REPL prompt
Classis answered 2/4, 2021 at 15:31 Comment(0)
M
0

Using GitBash as your terminal, you can install the lein script rather than the lein.bat script.

The lein script will run correctly in GitBash (as it is effectively a Unix environment).

I recommend installing the lein script in a directory called bin in your user account directory, e.g.:

c:/Users/your-account/bin

Placing the lein script in bin will allow you to run the lein command anywhere on the GitBash command line.


A Note about Emacs, lein and windows

The lein script will also be called correctly from Emacs, assuming you run Emacs from the GitBash terminal, ie. runemacs. Add Emacs install directory to your user account PATH environment variable and GitBash will find it on the command line.

Emacs installed on Windows works better when run from the GitBash terminal, as you can then use ediff in Emacs, which requires the diff command that GitBash terminal provides.

My recommended Emacs installs for windows

Match answered 19/4, 2018 at 9:21 Comment(0)
J
0

My experience was that lein repl (and I do use the lein bash script) would start up ok, also printing the startup messages of the lein command to the shell, but would then stop to output anything (although the process might be running fine), part. not providing an interactive prompt (except for the first), not echoing user input (except for the first), nor printing evaluation results. When terminating the process with Ctrl-C all my inputs would be passed to the underlying shell (with funny results like $ (+ 3 4) bash: +: command not found).

My solution is to use Git CMD for interactive commands like lein repl, lein figwheel etc., which (unfortunately, as it might seem) works fine. Running a Git sh process inside a different terminal emulation (Cmder) also gives me a working interactive environment.

Jeffreyjeffreys answered 21/12, 2018 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.