clr

pez 2023-05-10T23:46:04.919199Z

Success. Calva seems to like the clr.tools.nrepl server.

🎉 1
pez 2023-05-10T23:53:51.885369Z

In the process I created a small example project https://github.com/PEZ/clojure-clr-mini I’d really appreciate if some of you folks give it a spin. I don’t know what I am doing so before I share the link around, would be nice with some feedback. If you have Docker it should take only 2-3 minutes to have your editor connected. For Calva users it’s like: 1. docker compose build 2. docker compose up -d 3. Calva Jack-in BOOM. Thanks @anders982 and @dmiller for the assistance! 🙏 ❤️ Once @dmiller has had his speedy success with porting tools.deps, my example project can stop doing a bit of the silly stuff it is currently doing. 😃

🎉 3
seancorfield 2023-05-10T23:58:23.196719Z

When I start Calva in that project, with Docker up, I get this warning:

LSP classpath lookup failed when running `/usr/bin/lein with-profile +test,+dev classpath`. Some features may not work properly if ignored. Error: OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. Retrieving lein-clr/lein-clr/0.2.0/lein-clr-0.2.0.pom from clojars Retrieving lein-clr/lein-clr/0.2.0/lein-clr-0.2.0.jar from clojars Retrieving org/clojure/clr/tools.nrepl/0.1.0-alpha1/tools.nrepl-0.1.0-alpha1.pom from clojars

seancorfield 2023-05-11T00:01:30.690239Z

Other than that, it all worked as advertised. I jacked in. I evaluated some code. Works just like the JVM 🙂

3
🙏 1
pez 2023-05-11T00:27:15.841519Z

Thanks for the help, @seancorfield ! I think there are some issues mentioned recently in this channel about lsp.

dmiller 2023-05-11T01:34:43.771539Z

I'm very excited by this. Both the docker example and the report on Calva/clr.tools.nrepl. I still have to do the work to hook up to Calva, but it looks now more like a victory lap.

dmiller 2023-05-11T04:05:54.474739Z

Tried the instructions, get a docker error. On the command line:

PS C:\work\clojure\clojure-clr-mini> docker-compose exec -it dotnet-clojure /app/docker/start-repl.sh
service "dotnet-clojure" is not running container #1
Looking in Docker Desktop:
2023-05-11 00:00:09 clojure-clr-mini-dotnet-clojure-1  | exec /app/docker/entrypoint.sh: no such file or directory
I'm no docker expert. Any suggestions?

seancorfield 2023-05-11T04:11:28.328009Z

Sounds like it didn't mount the filesystem at startup? Missing -v option?

seancorfield 2023-05-11T04:14:15.715119Z

Although I would have expected that to be taken care of by the yml file config... I ran the command in wsl not Windows tho' so maybe the config isn't portable...

dmiller 2023-05-11T04:42:36.340459Z

I'll jump into WSL and try it. Tomorrow. Thanks.

seancorfield 2023-05-11T05:38:52.490949Z

I was able to get the Docker stuff running on Windows (PS). But I can't get Calva to jack-in on Windows -- I see this error in the Window log:

2023-05-10 22:34:52.443 [error] Unable to resolve filesystem provider with relative file path 'c:\Users\seanc\clojure\clojure-clr-mini/.calva/output-window': Error: Unable to resolve filesystem provider with relative file path 'c:\Users\seanc\clojure\clojure-clr-mini/.calva/output-window'
    at e.ExtHostCommands.h (c:\Users\seanc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:125669)
not sure why it's using / instead of \ in that path?

seancorfield 2023-05-11T05:39:53.907629Z

If I try to connect to the running nREPL server instead of jacking in, I get this error:

2023-05-10 22:38:59.237 [error] [Extension Host] Error writing to results doc: Error: cannot open c:%5CUsers%5Cseanc%5Cclojure%5Cclojure-clr-mini/.calva/output-window/output.calva-repl. Detail: Unable to resolve resource c:%5CUsers%5Cseanc%5Cclojure%5Cclojure-clr-mini/.calva/output-window/output.calva-repl
    at e.MainThreadDocuments.$tryOpenDocument ()
which is very similar...

pez 2023-05-11T05:42:35.257509Z

I really should spend some time with Calva on Windows. Though that looks unrelated to the REPL connection error.

pez 2023-05-11T05:44:13.266129Z

The docker-compose exec -it dotnet-clojure /app/docker/start-repl.sh command works for you, @seancorfield?

seancorfield 2023-05-11T05:44:55.508659Z

Yes, just ran that on PowerShell and it displayed the following and waited:

Started nREPL server at localhost:6667

seancorfield 2023-05-11T05:46:23.305919Z

And it creates the .nrepl-port file in the docker folder.

seancorfield 2023-05-11T05:51:00.174729Z

Jacking-in on WSL works. And I can tell it's really .NET because I can eval (System.Environment/GetEnvironmentVariable "HOME") => "/root" 🙂

seancorfield 2023-05-11T05:54:02.543149Z

Happy to try stuff out to debug on Windows (although it's "bedtime" here) @pez

pez 2023-05-11T05:57:53.637609Z

But connecting to that repl doesn’t work?

seancorfield 2023-05-11T05:58:53.546569Z

Doing it all on WSL2 (Ubuntu) works. Doing it all on Windows (Powershell) fails at the jack-in/connect step, with the error about the incorrect path.

seancorfield 2023-05-11T05:59:45.606949Z

I believe /.calva/output-window should be \.calva\output-window when run on Windows but I don't know how Calva builds that path?

seancorfield 2023-05-11T06:02:00.858039Z

Which sure looks like it should work -- unless my VS Code thinks it is on Linux instead of Windows for some reason?

pez 2023-05-11T06:03:49.736379Z

Can you connect to some other REPL, like a minimal deps project?

seancorfield 2023-05-11T06:06:55.158009Z

I'll have to create a Windows project to test that... just a sec...

seancorfield 2023-05-11T06:10:02.346139Z

It seems to just hang on Launching REPL using deps.edn

seancorfield 2023-05-11T06:10:53.088479Z

Hmm,

pushd c:\Users\seanc\clojure\minimal & java -jar ".calva\deps.clj.jar" -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""1.0.0""},cider/cider-nrepl {:mvn/version,""0.28.5""}}}" -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" & popd
Clojure tools not yet in expected location: C:\Users\seanc\.deps.clj\1.11.1.1273\ClojureTools\clojure-tools-1.11.1.1273.jar
Downloading  to C:\Users\seanc\.deps.clj\1.11.1.1273\ClojureTools\tools.zip
Unzipping C:\Users\seanc\.deps.clj\1.11.1.1273\ClojureTools\tools.zip ...
Successfully installed clojure tools!
Error building classpath. Error reading edn. Map literal must contain an even number of forms (c:\Users\seanc\clojure\minimal\deps.edn)
Jack-in process exited. Status: 1

seancorfield 2023-05-11T06:12:02.373349Z

I think that's a shell quoting issue?

seancorfield 2023-05-11T06:15:14.752949Z

Ah, it doesn't like a deps.edn file that contains {} -- which ought to work...

seancorfield 2023-05-11T06:18:33.235779Z

Hmm, it doesn't seem to matter what is in my deps.edn file -- it doesn't like it

pez 2023-05-11T06:18:41.374019Z

Wow, that’s strange.

seancorfield 2023-05-11T06:19:16.376329Z

I updated it to contain {:deps {org.clojure/clojure {:mvn/version "1.10.0"}}} and now it complains: Error building classpath. Error reading edn. Invalid file, expected edn to contain a single value. (c:\Users\seanc\clojure\minimal\deps.edn)

pez 2023-05-11T06:19:50.666929Z

Does the Getting Started REPL work?

seancorfield 2023-05-11T06:21:19.787739Z

Yes.

pez 2023-05-11T06:23:34.998139Z

So deps.clj actually works. It’s like the jack-in is happening from the wrong directory.

seancorfield 2023-05-11T06:25:21.490109Z

Well, it's pointing at the "correct" deps.edn file but not liking it...

seancorfield 2023-05-11T06:27:27.090409Z

Ugh! Wonky file encoding.

seancorfield 2023-05-11T06:27:52.902619Z

It was UTF-16 LE and that broke things. OK, let me get Docker stuff back up...

seancorfield 2023-05-11T06:29:50.201409Z

Back to the CLR project (now that we've confirmed Calva works in a minimal project!)

pez 2023-05-11T06:31:02.828709Z

That’s a big relief. There are a lot of Windows Calva users out there.

seancorfield 2023-05-11T06:31:11.938999Z

Nope, that fails because of this error

2023-05-10 23:30:11.010 [error] Unable to resolve filesystem provider with relative file path 'c:\Users\seanc\clojure\clojure-clr-mini/.calva/output-window': Error: Unable to resolve filesystem provider with relative file path 'c:\Users\seanc\clojure\clojure-clr-mini/.calva/output-window'
    at e.ExtHostCommands.h (c:\Users\seanc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:125669)
which I do not get in the other project...

pez 2023-05-11T06:31:53.212179Z

In that minimal project. Do you see that same error, maybe?

pez 2023-05-11T06:32:11.489379Z

I’m wondering if that is the real problem…

seancorfield 2023-05-11T06:32:22.869769Z

The minimal project works.

seancorfield 2023-05-11T06:32:39.983429Z

i.e., a minimal deps.edn project I created.

pez 2023-05-11T06:32:44.125149Z

Yes, that’s why I wonder about the error message 😃

seancorfield 2023-05-11T06:32:45.673299Z

The CLR project does not.

pez 2023-05-11T06:34:23.766599Z

Can you connect some other nrepl client to the server started in the CLR project?

pez 2023-05-11T06:36:15.020939Z

Something like:

clojure -Sdeps '{:deps {reply/reply {:mvn/version "0.5.1"}}}' -M -m reply.main --attach 6667

seancorfield 2023-05-11T06:36:58.463629Z

That looks like a linux command, not Windows?

seancorfield 2023-05-11T06:37:40.196929Z

And I don't have nREPL up in the CLR docker because Calva cannot jack-in

seancorfield 2023-05-11T06:38:03.111089Z

I can try to manually start that nREPL on the Windows side...

pez 2023-05-11T06:38:17.012009Z

I’m a Windows noob. Yes probably needs to look different on Windows.

pez 2023-05-11T06:38:48.137419Z

That docker compose exec command seemed to start the nREPL server.

pez 2023-05-11T06:39:45.423499Z

I’m thinking that maybe it isn’t exposed correctly on 127.0.0.1:6667. So that’s why reply might help in testing that.

seancorfield 2023-05-11T06:40:40.598189Z

OK, if I manually start that repl in a powershell window, I can connect to it from that REPLy command (from linux):

-> clojure -Sdeps '{:deps {reply/reply {:mvn/version "0.5.1"}}}' -M -m reply.main --attach 6667
: Can't set!: *print-length* from non-binding thread user
clojure.lang.TypeNotFoundException: Unable to find type: nrepl.core user

Error loading namespace; falling back to user
#object[Namespace 0x86c47 "user"]nil
user=> WARNING: cat already refers to: #'clojure.core/cat in namespace: net.cgrand.parsley.fold, being replaced by: #'net.cgrand.parsley.fold/cat

seancorfield 2023-05-11T06:41:34.856899Z

And to confirm it's really the CLR repl:

user=> (System.Environment/GetEnvironmentVariable "HOME")
"/root"
user=>

seancorfield 2023-05-11T06:41:58.295659Z

I'm pretty sure the problem is the / in those file paths.

seancorfield 2023-05-11T06:44:19.379109Z

The very first thing Calva tries to do when you jack-in is create that file -- before it even runs any commands -- and that creation fails so jack-in fails.

pez 2023-05-11T06:46:31.274909Z

Makes sense. Though why would it differ between the minimal project and this one…

seancorfield 2023-05-11T06:47:50.369829Z

I don't know how VS Code figures out what separator to use...

pez 2023-05-11T06:51:05.195189Z

Hmmm, yes, actually there is a difference, in that the connect sequence pretends that the mini-project is a Leiningen project…

pez 2023-05-11T06:54:05.249809Z

Might be that we construct some path differently then. I’ll have to check.

seancorfield 2023-05-11T06:56:52.703329Z

If I change the auto connect settings to false and jack-in and select the ClojureCLR Starter, it fails like this:

2023-05-10 23:55:23.251 [error] spawn docker compose exec -it dotnet-clojure /app/docker/start-repl.sh ENOENT: Error: spawn docker compose exec -it dotnet-clojure /app/docker/start-repl.sh ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:497:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

seancorfield 2023-05-11T06:57:38.151699Z

(I tried with the original docker-compose but that failed too, so I wondered if it wanted docker compose but apparently not)

pez 2023-05-11T06:58:27.326189Z

What a boring error message…

pez 2023-05-16T08:49:59.154899Z

Done. Thanks again!

pez 2023-05-13T09:41:58.912139Z

The example project is now updated for the increased Dx enabled by the fixes in latest Calva: https://clojurians.slack.com/archives/CBE668G4R/p1683968626977079 It should support the no-prompts jack-in, as well as REPL auto-connect-on-worskpace open. Please scrutinize the README and see that it makes sense. @dmiller you will need to update the workspace settings. Pulling the changes is enough, but you can also just paste the new settings into .vscode/settings.json in the project. Please let me know how you fare. 🙏

seancorfield 2023-05-13T17:35:17.035479Z

Smooth as butter! I reset the repo and did git pull. I built & started the Docker setup. I started VS Code, reloaded to get the new Calva, opened hello.cljr and jacked in -- all worked as expected! Nice work @pez!!!

🙏 1
pez 2023-05-13T20:19:29.652389Z

That’s super nice to hear, @seancorfield! Did you also try to close the workspace and open it again? It should reconnect the REPL automatically.

seancorfield 2023-05-13T20:25:01.661649Z

I'd shutdown Docker, so it left the .nrepl-port file behind -- and Calva tried to connect to port 6667 and hung up. I restarted Docker and jacked-in and that worked. Closing and reopening VS Code now...

seancorfield 2023-05-13T20:25:59.460209Z

...and, yes, that worked with Docker still running. So maybe you need some cleanup code to remove .nrepl-port if Docker is shutdown?

seancorfield 2023-05-13T20:29:50.815649Z

I think your entrypoint.sh script could catch the SIGKILL and rm the file?

seancorfield 2023-05-13T20:30:48.566399Z

I haven't tried it, but this seems to suggest you can... https://stackoverflow.com/questions/42564155/gracefully-stopping-docker-containers

pez 2023-05-13T20:35:46.576669Z

If you shut down the Docker container the port file should be removed. Does that not happen for you?

seancorfield 2023-05-13T20:36:16.232919Z

Nope. Otherwise that would have worked above 🙂

pez 2023-05-13T20:37:56.023149Z

Oh, I missed that comment. Strange…

seancorfield 2023-05-13T20:38:25.310059Z

I tried adding trap to entrypoint.sh with a handler to rm /app/docker/.nrepl-port but that didn't seem to work either (for SIGTERM and SIGKILL)

pez 2023-05-13T20:39:14.795119Z

I do that in the start-repl.sh script already. And it seemed to work when I tried it.

pez 2023-05-13T20:44:55.759729Z

Hmmm, no that’s not what I tried. I hit ctrl+c on the docker exec command. That removes the file. Seems it doesn’t get the signal when the container is shut down.

seancorfield 2023-05-13T20:46:19.766539Z

Right, if you jack-in, there's no exec command to interrupt.

seancorfield 2023-05-13T20:47:22.126819Z

Ah, maybe SIGINT -- let me try that...

pez 2023-05-13T20:49:13.455059Z

Well, killing the jack-in process should be that. But it doesn’t do it either.

seancorfield 2023-05-13T20:53:42.249889Z

I tried adding the following to the YAML file:

stop_signal: SIGINT
    stop_grace_period: 30s
and while that extended the shutdown to 30 seconds, it still didn't seem to trap the SIGINT in entrypoint.sh:
term_handler() {
  echo "Stopping..."
  rm -rf /app/docker/.nrepl-port
  exit 0
}

trap 'term_handler' SIGTERM
trap 'term_handler' SIGKILL
trap 'term_handler' SIGINT
trap 'term_handler' EXIT

pez 2023-05-13T20:58:07.288359Z

Until fixed a note in the README will have to do. 😃

dmiller 2023-05-13T21:01:12.604509Z

I'll testify to the "smooth as butter" re connecting. It is amazing to see suggested completions after having typed (System/ 🙂 And for everyone's reference

(Environment/TickCount)  => 203604339
Toto, we're not in Java anymore.

pez 2023-05-13T21:02:48.329959Z

What’s the significance of the TickCount?

dmiller 2023-05-13T21:03:38.942199Z

Nothing in particular. I just wanted to evaluate (System/<something>) to provie I was talking to ClojureCLR.

seancorfield 2023-05-13T21:06:36.529879Z

(System.Environment/GetEnvironmentVariable "HOME") instead of (System/getenv "HOME") 🙂

dmiller 2023-05-13T21:15:03.669569Z

A great way to prove you are running the CLR on not-WIndows. 🙂

(Environment/GetFolderPath (System.Environment+SpecialFolder/UserProfile))
if you want to a platform-independent call. Still comes back with "/root"

seancorfield 2023-05-13T21:15:46.603419Z

Dot Net is very verbose 🙂

pez 2023-05-13T21:18:03.221129Z

> to prove I was talking to ClojureCLR 😃 I do this often with ClojureScript (js/alert).

seancorfield 2023-05-11T07:04:46.131189Z

https://github.com/microsoft/vscode/issues/109209

seancorfield 2023-05-11T07:04:56.679169Z

Looks similar...

seancorfield 2023-05-11T07:05:46.839189Z

And https://github.com/BetterThanTomorrow/calva/issues/825 (was linked from the Calva issue ref'd in that VS Code issue)

seancorfield 2023-05-11T07:06:54.768579Z

So maybe this has broken again in some situations?

pez 2023-05-11T07:10:32.907399Z

Seems like that, for sure.

seancorfield 2023-05-11T07:12:18.912999Z

Also, Calva doesn't seem to download/run LSP correctly on Windows right now. I end up with these files in the extension folder:

-rwxrwxrwx 1 sean sean 25642392 May 11 00:09 clojure-lsp-native-windows-amd64.zip
-rwxrwxrwx 1 sean sean 26545152 May 11 00:09 clojure-lsp.exe
but no clojure-lsp-version

👀 1
seancorfield 2023-05-11T07:13:06.362249Z

what clojure-lsp.exe command would display the version or some help or something?

seancorfield 2023-05-11T07:16:54.704849Z

Anyways, after midnight here... really bedtime!

💤 1
pez 2023-05-11T08:06:16.860519Z

It is the autoSelectFor… in the workspace settings that exposes the error. If I remove that and thus get to select the connect sequence manually, it works. I’ll update the project. Much more boring howto-instructions, but it will serve as a incentive for me to fix the problem in Calva.

pez 2023-05-11T09:07:52.405399Z

I could reproduce the problem in a (painfully slow) Azure machine. Now updated the project. Hopefully temporarily. It doesn’t fix the problem that @dmiller had though. Which I couldn’t reproduce.

dmiller 2023-05-11T13:18:42.479519Z

I'm not sure where all this stands at this point. I'm out for the next few hours, so I'll tune back in later. On my end, my Docker installation might have had some problems. I was getting errors a while back, never did anything about. So I uninstalled Docker (which cause a bluescreen -- not a good sign), reinstalled. Will do some tests when I get back and try again.

seancorfield 2023-05-11T15:29:08.145219Z

@pez I changed those autoSelect... settings to false and tried to manually select the connect sequence but it produced that "spawn" error I posted above. Is something else needed?

pez 2023-05-11T16:03:12.961379Z

I updated the README of the project. See if those instructions work. Or maybe, that’s what you did, @seancorfield? @dmiller, we’re at where there’s a bug (at least one) in Calva which trips the setup up. Manually starting the nREPL server (with docker compose exec -it dotnet-clojure /app/docker/start-repl.sh) and then connecting an nREPL client to that server should work. The project is updated with Calva settings that should avoid the bug on Windows. And the Calva stuff in the README is also updated. Hopefully it should work now, following those instructiions, but who knows.

pez 2023-05-11T16:05:33.287839Z

Regardless if you people get it working or not, please scrutinize the scripts in there a bit. The readme declares that I do not know what I am doing, which I don’t. I guess it’s the cheap-deps.sh script that is the funky one. Can we expect that to work as people add dependencies to their project?

seancorfield 2023-05-11T16:16:04.554329Z

@pez I can confirm that those modified instructions work for me, with the ["docker", ".nrepl-port"] change as well.

seancorfield 2023-05-11T16:17:32.788009Z

On Windows, I can't manually jack-in via that connect sequence: that throws the spawn docker ... error. If I manually run the start-repl.sh command and then connect via that connect sequence it works. Just to clarify.

seancorfield 2023-05-11T16:18:44.005999Z

LMK if you want me to run any other tests.

pez 2023-05-11T16:26:01.457319Z

Thanks, @seancorfield! I’ll be trying to fix the most glaring of the Jack-in bugs there. Might send Calva dev versions your way at some points. 😃

👍🏻 1
dmiller 2023-05-11T19:19:46.133089Z

Problem with starting continues.

seancorfield 2023-05-11T19:25:07.743219Z

@dmiller So, just to check, you clone the repo, cd into it, run docker compose build and that works, but when you run docker compose up, it fails? (if you run it without -d you'll see more log output indicating perhaps something useful).

dmiller 2023-05-11T19:34:10.624389Z

docker compose up -d appears to work:

PS C:\work\clojure\clojure-clr-mini> docker compose up -d
[+] Running 1/0
 ✔ Container clojure-clr-mini-dotnet-clojure-1  Running
(I had killed Docker and restarted, so it might have cleared something.) And I can see the image running in Docker Desktop -- that wasn't happening before. I had gotten a hint that line endings in .sh files might have been an issue with the missing entrypoint.sh problem, so I ran dos2unix on it, as was suggested. Perhaps that fixed the initial problem. Now I'm getting an error that I wasn't getting before.
2023-05-11 15:26:41 clojure-clr-mini-dotnet-clojure-1  | /app/docker/entrypoint.sh: /app/docker/cheap-deps.sh: /bin/bash^M: bad interpreter: No such file or directory
2023-05-11 15:26:41 clojure-clr-mini-dotnet-clojure-1  | /app/docker/entrypoint.sh: /app/docker/cheap-deps.sh: /bin/bash^M: bad interpreter: No such file or directory
2023-05-11 15:26:41 clojure-clr-mini-dotnet-clojure-1  | /app/docker/entrypoint.sh: line 4: /app/dependencies/load-path.sh: No such file or directory
And the appearance here of ^M is mighty suspicious. Off to try again.

pez 2023-05-11T19:37:39.430209Z

Ah, interesting. It should be unix line endings there. I wonder what can have happened… Anyway, will fix that right away. Good find!

seancorfield 2023-05-11T19:41:18.530919Z

git config can affect that -- so it could be linux line endings in the repo but git can check files out with crlf on windows.

pez 2023-05-11T19:41:34.962169Z

It’s all unix line endings when I look at the file locally:

od -c docker/cheap-deps.sh
0000000    #   !   /   b   i   n   /   b   a   s   h  \n  \n   o   r   i
0000020    g   i   n   a   l   _   c   l   a   s   s   p   a   t   h   =
0000040    $   (   l   e   i   n       c   l   a   s   s   p   a   t   h
0000060    )  \n  \n   n   e   w   _   c   l   a   s   s   p   a   t   h
0000100    =   "   "  \n   I   F   S   =   "   :   "  \n   f   o   r    
0000120    p   a   t   h       i   n       $   o   r   i   g   i   n   a
0000140    l   _   c   l   a   s   s   p   a   t   h   ;       d   o  \n
0000160                    i   f       [   [       $   p   a   t   h    
0000200    =   =       *   .   j   a   r       ]   ]   ;       t   h   e
0000220    n  \n                                   j   a   r   _   b   a
0000240    s   e   n   a   m   e   =   $   (   b   a   s   e   n   a   m
0000260    e       "   $   p   a   t   h   "       .   j   a   r   )  \n
0000300                                    t   a   r   g   e   t   _   d
0000320    i   r   =   "   /   a   p   p   /   d   e   p   e   n   d   e
0000340    n   c   i   e   s   /   $   j   a   r   _   b   a   s   e   n
0000360    a   m   e   "  \n                                   m   k   d
0000400    i   r       -   p       "   $   t   a   r   g   e   t   _   d
0000420    i   r   "  \n                                   u   n   z   i
0000440    p       -   q       -   o       "   $   p   a   t   h   "    
0000460    -   d       "   $   t   a   r   g   e   t   _   d   i   r   "
0000500   \n                                   n   e   w   _   c   l   a
0000520    s   s   p   a   t   h   =   "   $   n   e   w   _   c   l   a
0000540    s   s   p   a   t   h   :   $   t   a   r   g   e   t   _   d
0000560    i   r   "  \n                   e   l   s   e  \n            
0000600                        n   e   w   _   c   l   a   s   s   p   a
0000620    t   h   =   "   $   n   e   w   _   c   l   a   s   s   p   a
0000640    t   h   :   $   p   a   t   h   "  \n                   f   i
0000660   \n   d   o   n   e  \n  \n   e   c   h   o       "   $   {   n
0000700    e   w   _   c   l   a   s   s   p   a   t   h   #   :   }   "
0000720   \n                                                            
0000721

seancorfield 2023-05-11T19:41:38.810129Z

I forget what the default behavior is.

seancorfield 2023-05-11T19:42:34.432809Z

Maybe @dmiller has git configured to checkout files with CRLF even from Linux repos?

dmiller 2023-05-11T19:43:00.197659Z

Fixing the line endings on cheap-deps.sh took me one step deeper. Error message not appearing in Docker Desktop. Now I'm at at this point:

PS C:\work\clojure\clojure-clr-mini> docker-compose exec -it dotnet-clojure /app/docker/start-repl.sh
/app/docker/start-repl.sh: line 3: /app/dependencies/load-path.sh: No such file or directory
Execution error (FileNotFoundException) at System.Diagnostics.StackFrame/ (NO_FILE:0).
Could not locate user with extensions .cljr, .cljc, .cljr, .cljr.dll, .cljc.dll, or .clj.dll on load path.

Full report at:
/tmp/clojure-c6458361-e6ac-44eb-baf0-822b7b476500.edn
That .edn report indicates that it is failing to find the user file:
{:clojure.main/message
 "Execution error (FileNotFoundException) at System.Diagnostics.StackFrame/ (NO_FILE:0).\nCould not locate user with extensions .cljr, .cljc, .cljr, .cljr.dll, .cljc.dll, or .clj.dll on load path.\n",
 :clojure.main/triage
 {:clojure.error/class System.IO.FileNotFoundException,
  :clojure.error/line 0,
  :clojure.error/cause
  "Could not locate user with extensions .cljr, .cljc, .cljr, .cljr.dll, .cljc.dll, or .clj.dll on load path.",
  :clojure.error/symbol System.Diagnostics.StackFrame/,
  :clojure.error/source "NO_FILE",
  :clojure.error/phase :execution},

pez 2023-05-11T19:43:36.081809Z

Can the repo specify line endings overriding local configs?

dmiller 2023-05-11T19:43:41.051389Z

My git config is always is a source of wonder and mystery.

pez 2023-05-11T19:44:51.091249Z

I can maybe fix that when copying in the files into the Docker container.

dmiller 2023-05-11T19:46:03.696579Z

core.autocrlf=true I believe this is what is suggested for Windows users.

pez 2023-05-11T19:47:10.288359Z

If you do docker-compose exec -it dotnet-clojure Clojure.Main and examine CLOJURE_LOAD_PATH, what gives?

pez 2023-05-11T19:48:08.155309Z

Hmmm, sorry, that’s not a good test. Hang on…

pez 2023-05-11T19:49:52.033159Z

docker-compose exec -it dotnet-clojure bash
Then from the bash prompt:
source /app/dependencies/load-path.sh
echo CLOJURE_LOAD_PATH
Or just cat that file.

pez 2023-05-11T19:50:42.114379Z

> core.autocrlf=true I guess this means I need to take care of it when copying in the files.

dmiller 2023-05-11T19:54:49.401889Z

root@d4174c2efbe2:/app# source /app/dependencies/load-path.sh
bash: /app/dependencies/load-path.sh: No such file or directory

pez 2023-05-11T19:57:35.078259Z

When the container starts. You should see the dependencies directory created on the host machine. Do you?

pez 2023-05-11T19:59:09.998379Z

I have pushed a .gitattributes file to the repo which looks like:

docker/*.sh text eol=lf
Should override your git settings, @dmiller. Easiest way to apply it is to re-clone.

dmiller 2023-05-11T19:59:22.632059Z

I'm back to seeing this in Docker Desktop:

2023-05-11 15:26:41 clojure-clr-mini-dotnet-clojure-1  | /app/docker/entrypoint.sh: /app/docker/cheap-deps.sh: /bin/bash^M: bad interpreter: No such file or directory
2023-05-11 15:26:41 clojure-clr-mini-dotnet-clojure-1  | /app/docker/entrypoint.sh: /app/docker/cheap-deps.sh: /bin/bash^M: bad interpreter: No such file or directory
2023-05-11 15:26:41 clojure-clr-mini-dotnet-clojure-1  | /app/docker/entrypoint.sh: line 4: /app/dependencies/load-path.sh: No such file or directory

dmiller 2023-05-11T19:59:53.791669Z

I'll reclone, kill everything over on Docker , and start again. 👍

pez 2023-05-11T20:00:44.624709Z

Very good that you were using that setting! 😃

dmiller 2023-05-11T20:11:14.442939Z

Miracle of miracles:

PS C:\work\clojure\clojure-clr-mini> docker-compose exec -it dotnet-clojure /app/docker/start-repl.sh
Started nREPL server at localhost:6667
and the log over on Docker shows retrievals from clojars. I'm new to Calva. Given that I've had to start things this way, how best to connect?

dmiller 2023-05-11T20:12:44.367269Z

Looks like ctrl+alt+c ctrl+alt+j did the trick

pez 2023-05-11T20:16:08.488839Z

It did? I can’t get that to work yet on Windows. Anyway that’s the command for starting the REPL. Since you have started it manually you should do Connect instead: ctrl+alt+c ctrl+alt+c should work.

pez 2023-05-11T20:16:47.521669Z

The idea with the repo is that people should use the editor they know how to use, so you are a special case. 😃

dmiller 2023-05-11T20:16:50.287639Z

Well, no, it didn't work. False alarm.

dmiller 2023-05-11T20:18:40.411169Z

ctrl+alt+c ctrl+alt+c worked! I have officially evaluated (+ 2 3). (More advanced than (+ 1 2).)

pez 2023-05-11T20:19:30.666399Z

Double the advanced!

pez 2023-05-11T20:19:55.180289Z

🎉

pez 2023-05-11T20:21:30.643709Z

To evaluate stuff in the files, use alt+enter for top level forms, and ctrl+enter for “current” form.

dmiller 2023-05-11T20:29:49.835419Z

That much I got. But that's all. I have a lot to learn about Calva. But compared to the last 14 years of using Notepad++ and the command line to do my dev work on the Clojure-y aspects of ClojureCLR -- all those ported libs! -- I'm looking forward so much to the reduced friction.

pez 2023-05-11T20:33:45.034719Z

Oh, wow, am I talking to a potential Calva user? 😃

dmiller 2023-05-11T20:36:03.295479Z

Totally. (I ceased being an Emacs purist some 40+ years ago. Literally. 🙂 )

pez 2023-05-11T20:39:18.692509Z

Back then I was using ed and vi.

dmiller 2023-05-11T20:45:53.888759Z

Emacs on the VT-220, plus whatever we had available on our Vaxen. I was never "semper vi". But my first lisp was a maclisp (I think) clone running on a DEC-10 on a DECWriter pushing through green-bar fanfold paper. But perhaps TMI. 🙂

pez 2023-05-11T21:40:52.342239Z

I wish I had found lisp long ago. But I am also happy i finally found it.

pez 2023-05-14T09:41:40.717139Z

Back again with asking for help. 😃 I decided to use tools.deps instead of Leiningen for the cheap-deps handling. It works on my machine, but I don’t trust my testing enough. Please help me ensure that I didn’t break it. I also renamed the project so now it is found at https://github.com/PEZ/clojure-clr-starter If you’ve tested the previous versions, probably the most reliable way to test this one is to clone it to a fresh directory.

dmiller 2023-05-14T12:59:13.477609Z

I can get the docker image up and running. I seemed to have hosed my Calva installation somehow. Need to go figure out what I'm doing wrong. Or just take the day off. It's not starting well.

pez 2023-05-14T13:21:13.859799Z

We’re happy to help in #calva.

dmiller 2023-05-14T13:22:47.334669Z

Thanks. I should probably spend some time going through the tutorials first.

seancorfield 2023-05-14T16:36:25.059589Z

Basic build/start/jack-in worked here. Closed & restarted VS Code and it auto-reconnected.

seancorfield 2023-05-14T16:36:51.155189Z

Still leaves the .nrepl-port file behind after docker compose down.

dmiller 2023-05-14T18:43:10.400189Z

I got it connected.

seancorfield 2023-05-14T19:12:49.735199Z

@pez if you change defn main to defn -main your example can be run directly (on Windows with .NET etc installed):

$Env:CLOJURE_LOAD_PATH='src'; Clojure.Main -m starter.hello

🙏 1
pez 2023-05-14T19:28:30.253639Z

Fixed.

👍🏻 1
pez 2023-05-14T19:29:27.572939Z

Now I’ve switched from clojure to Babashka for the dependency management. 😃

pez 2023-05-17T07:23:04.166519Z

A problem with using .cljr for the extensions is that clojure-lsp does not help with them then. I wonder if this is maybe configurable.

pez 2023-05-15T07:00:27.107429Z

Fixed so that the nREPL port file is deled when the container is shut down. There’s still an issue with the REPL being kept running when Calva Jack-in is killed, but that is probably a Calva issue.

pez 2023-05-15T07:01:45.604059Z

Starting the REPL manually with docker compose exec -it dotnet-clojure /app/docker/start-repl.sh and then exiting that, stops the REPL and removes the port as it should.

seancorfield 2023-05-15T15:34:14.259929Z

I think the .clj files should be .cljr files - or at least .cljc files?

seancorfield 2023-05-15T15:34:50.822589Z

(for them to be runnable with Clojure.Main)

pez 2023-05-15T15:35:13.234399Z

But, yes, .cljc I could have used.

seancorfield 2023-05-15T15:36:21.613319Z

Hmm, I changed them to .cljr (to run them) and thought they were still treated as Clojure by Calva... But maybe I'd also changed that association in the settings?

pez 2023-05-15T15:52:18.070219Z

VS Code has a language setting for each editor pane. I think that if it was Clojure and then changes to “nothing” it might keep Clojure associated.

seancorfield 2023-05-15T18:21:45.194959Z

Oh... and I already had the files open! Got it!

seancorfield 2023-05-16T04:41:14.817839Z

3194 is merged to dev but not published yet, am I understanding the workflow correctly?

pez 2023-05-16T04:55:20.005679Z

Yes, I should publish it.

seancorfield 2023-05-16T04:55:41.708769Z

That wasn't a prompt, it was a question! 🙂

pez 2023-05-16T05:23:54.436259Z

Haha. I meant it like: Yes, you understand the workflow correctly. I really should publish it. It’s the press of a button and with zero risk involved.

👍🏻 1
seancorfield 2023-05-16T05:25:34.651909Z

And once that's out there, you can update the starter project to use .cljr extensions and maybe add a note about running the main function on cmd/powershell 🙂

seancorfield 2023-05-16T05:26:05.120929Z

It's very cool that this all works so smoothly! Major props to you for that!

🙏 1
pez 2023-05-16T05:31:05.396289Z

Will do.