clr

pez 2023-05-09T20:41:13.071029Z

I want to test the nrepl stuff and ClojureCLR in general. Though I have no clue how to. I’m on a Mac. Want to see if I can keep the .Net stuff in Docker. Here’s my WIP project: https://github.com/PEZ/clojure-clr-test Am I even close? Clojure.Main fails if I run it from the terminal in the docker container…

Anders Eknert 2023-05-09T21:07:58.574379Z

Clojure.Main is not on your PATH

Anders Eknert 2023-05-09T21:08:00.997499Z

try this

Anders Eknert 2023-05-09T21:08:02.612699Z

FROM 

RUN apt-get update \
    && apt-get install -y wget unzip

RUN dotnet tool install --global --version 1.12.0-alpha7 Clojure.Main

RUN apt-get clean \
    && rm -rf /var/lib/apt/lists/*

CMD ["/root/.dotnet/tools/Clojure.Main"]

Anders Eknert 2023-05-09T21:08:57.785349Z

you can run the stable version too, but then you’ll need a base image that provides version 6 of .NET

Anders Eknert 2023-05-09T21:09:33.267759Z

I’d go with the latest alpha 🙂

pez 2023-05-09T21:44:51.547509Z

Thanks! Now I get the REPL prompt!

👍 1
Diego B. Fernandez 2023-05-15T18:30:39.945149Z

A bit late to the party but I came here say you can run dotnet tools like this: dotnet tool run Clojure.Main .

💡 1
pez 2023-05-09T21:50:13.584399Z

Now trying to figure out how to test clr.tools.nrepl . There are Leiningen/maven coordinates in the README…. Is there a tutorial on how to create a project setup?

dmiller 2023-05-10T12:20:26.186099Z

environment variable CLOJURE_LOAD_PATH is the equivalent.

pez 2023-05-10T12:41:08.686579Z

The equivalent to the classpath? I tried this now:

user=> (System.Environment/GetEnvironmentVariable "CLOJURE_LOAD_PATH")
"/my_clojureclr_project/test:/my_clojureclr_project/src:/my_clojureclr_project/dev-resources:/my_clojureclr_project/resources:/my_clojureclr_project/target/classes:/root/.m2/repository/org/clojure/clr/tools.nrepl/0.1.0-alpha1/tools.nrepl-0.1.0-alpha1.jar:/root/.m2/repository/org/clojure/clr/tools.reader/1.3.7/tools.reader-1.3.7.jar:/root/.m2/repository/nrepl/nrepl/1.0.0/nrepl-1.0.0.jar:/root/.m2/repository/org/nrepl/incomplete/0.1.0/incomplete-0.1.0.jar"
user=> (require '[clojure.tools.nrepl])
Execution error (FileNotFoundException) at System.Diagnostics.StackFrame/ (NO_FILE:0).
Could not locate clojure/tools/nrepl with extensions .cljr, .cljc, .cljr, .cljr.dll, .cljc.dll, or .clj.dll on load path.

pez 2023-05-10T12:42:05.981089Z

A big part of the problem here is that I do not know what I am doing. It was 15 years ago since I did anything .Net.

pez 2023-05-10T12:48:29.445139Z

(I created that load path using Leiningen.)

dmiller 2023-05-10T13:13:10.223629Z

The code for breaking down the components of the CLOJURE_LOAD_PATH is

string rawpaths = (string)System.Environment.GetEnvironmentVariable(ClojureLoadPathString);            
 string[] paths = rawpaths.Split(Path.PathSeparator);
The value of Path.PathSeparator is supposed to be system-dependent. Maybe eval
System.IO.Path/PathSeparator
and see what it says. Leiningen should know the proper paths, for sure.

dmiller 2023-05-10T13:15:56.211529Z

Are you still doing this out of Docker? Getting paths right in that circumstance is beyond my knowledge.

pez 2023-05-10T13:56:11.642159Z

Still in Docker, yes. Am I supposed to be able to do lein run?

pez 2023-05-10T13:57:43.065379Z

What do I do with the paths once I have separated them?

pez 2023-05-10T13:58:45.338429Z

Ah, so that’s the code that ClojureCLR uses?

pez 2023-05-10T13:59:07.491949Z

user=> System.IO.Path/PathSeparator
\:
user=> 

pez 2023-05-10T14:02:42.384579Z

The path looks cool to me.

# ls /root/.m2/repository/org/clojure/clr/tools.nrepl/0.1.0-alpha1/
_remote.repositories               tools.nrepl-0.1.0-alpha1.pom
tools.nrepl-0.1.0-alpha1.jar       tools.nrepl-0.1.0-alpha1.pom.sha1
tools.nrepl-0.1.0-alpha1.jar.sha1

dmiller 2023-05-10T19:41:16.243019Z

Lein runs in java land and knows how to use maven, read poms, grok jars. That's what is doing in the background to get the code in your local cache. ClojureCLR can't handle all that. (which is why i'm working feverishly to port tools.deps -- then we weill be able to get automatic pulls of dependencies from git repos and nuget.) For now, I'd just clone the repo into someplace nice and have the path include something-nice.../src/main/clojure . And wish me speedy success on porting tools.deps.

pez 2023-05-10T20:18:46.380239Z

Wishing you speedy success!

pez 2023-05-10T20:19:33.994839Z

Clone what repo? The nrepl one?

dmiller 2023-05-11T01:16:21.335789Z

nrepl and whatever it depends on.

pez 2023-05-10T06:38:46.532919Z

I tried with installing Leiningen in the container and can adding a project.clj, using the :main.cmd to launch the nrepl server. But this is probably not the way to go. Leiningen is run by Java and and complains.

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
So, how do I get clr.tool.nrepl on the classpath? (If classpath is even a concept on the CLR…) My test project is here: https://github.com/PEZ/clojure-clr-test