Fork me on GitHub
#calva
<
2019-07-22
>
punit-naik09:07:45

Hey Guys! How do I build the calva extension from source on my local system and test it? Is there any guide for building?

pez09:07:07

Hi @punit-naik! Yes there is a page about it on the wiki. How to contribute or something, iirc.

👍 1
pez10:07:06

@johnjelinek, and other windows users (and Mac and Linux users as well, actually). I need help testing this build. It fixes an issue where clojure.ps1 is not installed and CLJ/CLI projects fail in jack-in. I've changed the strategy of trying to find the executable (`lein`, clojure, etc) in the user's path before executing it. (Seems the OS already takes care of that, so not sure why it is done like that to begin with). I can still start Leiningen, CLJ/CLI, and shadow-cljs projects on my Mac. But I don't know if things still work on Windows and Linux (it really should still work on Linux), or even if it now works for the case the fix is for. Gold stars in heaven (as we say in Sweden) for everyone helping to test this.

✹ 1
johnjelinek16:07:31

failed:

> Executing task in folder yellowtheme: powershell.exe clojure -Sdeps "{:deps {nrepl {:mvn/version \`"0.6.0\`"} cider/cider-nrepl {:mvn/version \`"0.21.1\`"}}}"  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" <

Missing closing '}' in statement block or type definition.
+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndCurlyBrace

pez16:07:06

Can you try it using cmd as your default vscode terminal shell?

johnjelinek17:07:39

same error:

> Executing task in folder yellowtheme: powershell.exe clojure -Sdeps "{:deps {nrepl {:mvn/version \`"0.6.0\`"} cider/cider-nrepl {:mvn/version \`"0.21.1\`"}}}"  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" <

Missing closing '}' in statement block or type definition.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndCurlyBrace
 
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

johnjelinek17:07:52

I think you should get rid of those backticks in the command

johnjelinek17:07:27

new error if you remove the backticks:

>powershell.exe clojure -Sdeps "{:deps {nrepl {:mvn/version \"0.6.0\"} cider/cider-nrepl {:mvn/version \"0.21.1\"}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
Unknown option: "-i"
Unknown option: "-n"
Unknown option: "-p"
Unknown option: "-u"
Unknown option: "-t"
Unknown option: "-F"
Unknown option: "-o"
Unknown option: "-r"
Unknown option: "-m"
Unknown option: "-a"
Unknown option: "-t"
Unknown option: "-o"
Unknown option: "-u"
Unknown option: "-t"
Unknown option: "-p"
Unknown option: "-u"
Unknown option: "-t"
Unknown option: "-F"
Unknown option: "-o"
Unknown option: "-r"
Unknown option: "-m"
Unknown option: "-a"
Unknown option: "-t"

pez17:07:23

Powershell quoting is tricky as hell. It seems it is different between clojure.ps1 and the clojure command provided by that module.

pez17:07:26

What shell was the default vscode she'll for you before you made the last experiment?

pez17:07:37

For leiningen we cheat by temporarily switching to . Maybe we can do something similar for this, switching to powershell. Because the quoting gets extra crazy when executing powershell.exe from to run the clojure command.

pez17:07:12

Maybe @U051BLM8F has some advice?

bozhidar17:07:15

Unfortunately I don’t. I haven’t used Windows actively in a very long time.

johnjelinek18:07:44

@U0ETXRFEW: this is how I usually do it from powershell:

clj -Sdeps '{:deps {nrepl {:mvn/version \"0.6.0\"}}}' -m nrepl.cmdline

johnjelinek18:07:03

my default shell was pwsh (the open source impl of powershell)

johnjelinek18:07:19

> clj -Sdeps '{:deps {nrepl {:mvn/version \"0.6.0\"}}}' -m nrepl.cmdline

nREPL server started on port 51518 on host 127.0.0.1 - 

johnjelinek19:07:22

I've not figured out the quote magic to get this to work from command prompt via the powershell.exe command

johnjelinek21:07:36

@U0ETXRFEW: there's some vigorous discussion in #clj-on-windows on this topic. The official answer is: dump cmd; only powershell is supported

johnjelinek23:07:51

looks like someone made a wrapper to fix this problem for command prompt: https://github.com/cark/clojure-win-cli-wrap

pez06:07:35

Thanks @U051BLM8F, that link helps! ❀

pez06:07:38

I don't think I can bundle a wrapper like that, @johnjelinek. But I can maybe pick up some clues from the source.

pez12:07:41

New build for you to test, @johnjelinek. (And anyone else who wants to be kind enough to help me check if I have broken something with jack-in.)

johnjelinek14:07:52

> Executing task in folder yellowtheme: clojure -Sdeps "'{:deps {nrepl {:mvn/version ""0.6.0""} cider/cider-nrepl {:mvn/version ""0.21.1""}}}'"  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" <

'clojure' is not recognized as an internal or external command,
operable program or batch file.
The terminal process terminated with exit code: 1

johnjelinek14:07:00

if I change default terminal to pwsh instead of cmd, I get:

> Executing task in folder yellowtheme: clojure -Sdeps '{:deps {nrepl {:mvn/version ""0.6.0""} cider/cider-nrepl {:mvn/version ""0.21.1""}}}'  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" <

Error while parsing option "--config-data {:deps {nrepl {:mvn/version 0.6.0} cider/cider-nrepl 
{:mvn/version 0.21.1}}}": java.lang.NumberFormatException: Invalid number: 0.6.0

johnjelinek14:07:28

I think your command needs to look more like this:

clj -Sdeps '{:deps {nrepl {:mvn/version \"0.6.0\"}}}' -m nrepl.cmdline

johnjelinek03:07:51

@U0ETXRFEW: you wanna try a build with \s?

pez10:07:41

@johnjelinek sorry for the radio silence. I've been traveling and haven't been able to make any new tests. Now back at home and will make another attempt to make my poor computer run a virtual win10 machine. Your test results indicate that the switching to powershell doesn't work yet, so that is the first thing I need to fix. Then we'll get to the quoting. But reading the docs it seems we should be able to use unescaped double quotes inside single quotes, which would be awesome, because then we can use the same quoting for bash and powershell.

johnjelinek15:07:58

cmd calling powershell.exe does not work and that's a known issue and WONTFIX according to #clj-on-windows. If powershell is the default vscode shell, it works if you fix the quoting

pez16:07:39

Except that it doesn't. 😃 And except that running powershell.exe through cmd works for a lot of Calva users today. But, anyway, if you look at the command line of the latest test build is using, it is not using powershell.exe. I've ran a few experiments with this today and find that clj -Sdeps '{:deps {nrepl {:mvn/version \"0.6.0\"}}}' -m nrepl.cmdline as well as clj -Sdeps '{:deps {nrepl {:mvn/version ""0.6.0""}}}' -m nrepl.cmdline work if I run them manually in the integrated powershell in VS Code. But when running them through the VS Code Task, with the shell set to powershell, neither of them work. Both of them renders the same error (the version number is somehow stripped of the double quotes).

pez16:07:47

This looks to me as a VS Code + Powershell thing, but I have yet to figure out how to work it.

johnjelinek16:07:32

does clojure -Sdeps '{:deps {nrepl {:mvn/version """0.6.0"""}}}' -m nrepl.cmdline with powershell as default shell work for you?

pez16:07:50

Not really. 😃 I think triple quoting is for when you have double quotes around the string. With single quotes around the string then two double quotes around the version number suffices.

pez16:07:00

No, I was wrong. Using single quotes around the string I get the same result writing the double quotes around the version number like \", "", and """ (they all work). Quite odd. But this is all manually executing the command. Doing it through a VS Code Task, they all fail (in the same way).

😱 1
johnjelinek16:07:25

is it that same error? java.lang.NumberFormatException: Invalid number: 0.6.0

johnjelinek16:07:09

alternatively -- you could make a thing that makes sure these deps are in the deps.edn of your clojure installation and change the command to clojure -m nrepl.cmdline

pez17:07:06

That would defeat the whole jack-in thing. 😃

pez17:07:01

Anyway. I get it to work if I use seven (7!) double quotes. Like so: clojure -Sdeps '{:deps {nrepl {:mvn/version """""""0.6.0"""""""} cider/cider-nrepl {:mvn/version """""""0.21.1"""""""}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]". A new build coming your way soon.

pez17:07:41

See if that one works for you as well.

johnjelinek19:07:42

😆 how did you come up with SEVEN "? I'll be able to check it when I get home tonight

pez20:07:13

I got frustrated and tried with 50 something. The error message from that gave me a clue. 😎

😼 1
johnjelinek20:07:38

I 👏 your persistence -- what was the error with 50-something "?

pez20:07:14

> Executing task: clojure -Sdeps '{:deps {nrepl {:mvn/version """"""""""""""""""""""""""""""""""""""""""""""""""""""""0.6.0""""""""""""""""""""""""""""""""""""""""""""""""""""""""} cider/cider-nrepl {:mvn/version """"""""""""""""""""""""""""""""""""""""""""""""""""""""0.21.1""""""""""""""""""""""""""""""""""""""""""""""""""""""""}}}'  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" <

Error while parsing option "--config-data {:deps {nrepl {:mvn/version \"\"\"\"\"\"\"\"\"0.6.0\"\"\"\"\"\"\"\"\"} cider/cider-nrepl {:mvn/version \"\"\"\"\"\"\"\"\"0.21.1\"\"\"\"\"\"\"\"\"}}}": java.lang.IllegalArgumentException: Duplicate key:

👍 1
johnjelinek00:07:35

@U0ETXRFEW: MAGIC 🎉 you did it!

johnjelinek00:07:39

it works great now

johnjelinek00:07:11

@U0ETXRFEW: is there something about your latest change that is pinning my vscode to powershell terminal? I can't select any others now.

pez06:07:19

That sounds like it could be my change. Can you describe the problem a bit more, so that I can try reproduce it.

johnjelinek16:07:04

@U0ETXRFEW: I select a different default terminal and no matter what I pick, when I open a new terminal, it's powershell

johnjelinek16:07:26

I can't get to git bash, WSL bash, cmd, or pwsh(powershell core)

pez19:07:23

Thanks. I think I know what is going on. It is some confusion between user and workspace settings. While I look for a way to not create that problem I think you can clean up your settings.json files to get your shell selection back.

johnjelinek20:07:25

I think my settings.json looks clean already, anything specific you want me to look at?

pez16:07:35

terminal.integrated.shell.windows in your workspace settings.

👍 1
pez16:07:46

Sorry for the late reply. Had missed the question...

pez16:07:15

Also, in the new test build that I posted in #calva-dev , I have completely changed the implemantation, so not fiddling with default shell or anything. (And we're back to two " for escaping. 😃 )

johnjelinek16:07:08

waow! can't wait to see the PR!

johnjelinek18:07:52

k, here's my settings.json now:

{
    "window.titleBarStyle": "native",
    "editor.cursorStyle": "block",
    "editor.cursorBlinking": "solid",
    "editor.rulers": [
        80,
        100
    ],
    "window.zoomLevel": 2,
    "terminal.integrated.rendererType": "dom",
    "calva.jokerPath": "C:\\Program Files\\Joker\\joker",
    "calva.lintOnSave": true
}

johnjelinek18:07:12

if I tell it to change the default shell, it adds the last line here:

{
    "window.titleBarStyle": "native",
    "editor.cursorStyle": "block",
    "editor.cursorBlinking": "solid",
    "editor.rulers": [
        80,
        100
    ],
    "window.zoomLevel": 2,
    "terminal.integrated.rendererType": "dom",
    "calva.jokerPath": "C:\\Program Files\\Joker\\joker",
    "calva.lintOnSave": true,
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}

johnjelinek18:07:25

and when I open a new terminal with the + button, it still opens in powershell

johnjelinek18:07:34

@U0ETXRFEW: this is with the latest vsix (4)

johnjelinek18:07:04

Jack-In looks like it doesn't work though:

> Executing task in folder yellowtheme: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe clojure -Sdeps '{:deps {nrepl {:mvn/version ""0.6.0""} cider/cider-nrepl {:mvn/version ""0.21.1""}}}'  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" <

nREPL server started on port 51954 on host 127.0.0.1 - 

--
Start the REPL with the command *Start Project REPL and connect (aka Jack-in)*.
Default keybinding for Jack-in: ctrl+alt+c ctrl+alt+j
Jacking in...
No nrepl port file found. (Calva does not start the nrepl for you, yet.) You might need to adjust "calva.projectRootDirectory" in Workspace Settings.
Jack-in done.
Use the VS Code task management UI to control the life cycle of the Jack-in task.

johnjelinek18:07:54

tried again and it connected this time ... dunno what the issue was

johnjelinek18:07:59

still can't use different terminals though

pez19:07:31

I think the default shell is changed in the workspace settings (by fix-3). It overrides the user/global settings. You should have a .vscode/settings.json in the root of your project. Remove the terminal.integrated.shell.windows setting from that one and you should get back the control of this.

pez19:07:10

Regarding that ”No nrepl port file found” message. I get that too at times. Feels like a race condition. Strange because it happens in the file change watcher that triggers when that file is created... Please keep me informed about how frequently it happens for you.

johnjelinek02:07:55

oic, it was hiding in my workspace file

johnjelinek03:07:56

@U0ETXRFEW: ya, so first jack-in always fails to connect now, but restarting task succeeds

pez09:07:14

Thanks. I see what is happening now. On Windows I get two events for the nrepl port file, and on Mac only one. Expect a fix soon. 😎