I got a support question (via e-mail!) about how to create a first project. (Along with well deserved feedback about how this is lacking in Calva's getting started repl experience). I started to reply, but wanted to check that I was correct by heading over to http://clojure.org looking for a instructions on how to do it. But I fail to find it. I seem to recall it has been there. Maybe it is just because it is late Saturday night here. Anyway, something for us to think about.
Create a src folder to put source code in and add a deps.edn at the top-level if you have external dependencies. Which is pretty much what https://clojure.org/guides/deps_and_cli says...
It says so in a quite roundabout way. And it's hard to find it going via https://clojure.org/guides/getting_started, which I did. I'm going to restructure the Calva Getting Started setup and docs for this a bit, because it suffers from a similar problem. It get's people to the REPL, but then leaves no clues what to do to get yourself a project REPL. Here's the e-mail letter I got: > Hello, > > I’m very new to VSCode and want to use it to learn Clojure. > > I have done extensive programming in Xojo and quite a bit of Swift in Xcode and so am not particularly stupid. Have to say as a noob to LISP/Clojure and VSCode the Calva help information provided isn’t helpful to me at all!!! > > I installed Java, then Calva following your instructions. When I loaded the “Fire up the Getting started REPL” everything runs fine but from an obscure temporary folder. If I move the three files to a folder on my drive, nothing works. I get the following error > >
LSP classpath lookup failed when running `lein with-profile +test,+dev classpath`. Some features may not work properly if ignored. Error: Cannot run program "lein" (in directory "D:\Clojure"): CreateProcess error=2, The system cannot find the file specified Choose an option: LSP classpath lookup failed when running `lein with-profile +test,+dev classpath`. Some features may not work properly if ignored. Error: Cannot run program "lein" (in directory "D:\Clojure"): CreateProcess error=2, The system cannot find the file specified Choose an option: LSP classpath lookup failed when running `lein with-profile +test,+dev classpath`. Some features may not work properly if ignored. Error: Cannot run program "lein" (in directory "D:\Clojure"): CreateProcess error=2, The system cannot find the file specified Choose an option:
>
>
> I just need an explanation of how I can create my own file structure (D:/Clojure/project.clj) and a Workspace to access the REPL of Calva with my own code so as to evaluate expressions on the go.
>
> Much appreciated for any help you can offer.
To which I replied:
> Hi <name>
>
> Thanks for this feedback. You are pointing at a glaring hole in Calva's beginner-with-clojure experience. We should fix that.
>
> What you tried is interesting. I'm thinking a first step would be to inform the user of this way of doing it...
>
> The only thing you missed is to also copy the deps.edn file from there, I think. Though it's not idiomatic to have the Clojure files in the root directory. Usually we put those in the src subdirectory. (Note to self: I should probably restructure the getting-started directory like this.)
>
> So to create a more idiomatic project of the getting started things there:
>
> 1. Place the three files in a src subdirectory
> 2. Place the deps.edn file in the root directory
> 3. Edit the deps.edn file to have the contents: {:paths ["src"]} (Actually I think src is default and the content could be as simple as {}, but I think it is better to be explicit here. Then it gets clearer where to add source paths, like test, or whatever.)
> 4. Use the Calva command Calva: Start a Project REPL and Connect (aka Jack-in), choose the project type deps.edn
> 5. When the REPL is connected you should start with loading a Clojure file in the REPL: Calva: Load/Evaluate Current File and its Requires/Dependencies
>
> Then you should be good to go. You probably need to restart clojure-lsp to get rid of those errors. (There's a button in the status bar that can help with this.)
>
> Please let me know if this works or not. Also feel very welcome to join the #calva Channel over at the Clojurians slack. There is a great #beginners channel there as well to get help with your Clojure journey. I think you should be able to get in via: http://clojurians.net/I am a bit surprised that clojure-lsp gives those errors, but the guy writing me did say something about a project.clj... It also points at another problem, that with bundling clojure-lsp. I often get contacted from people who think ”nothing is working” because clojure-lsp is not happy with something. I mean, all the rest of Calva is working, clojure-lsp is mostly very sweet icing on the cake. But they have not installed clojure-lsp themselves, we bundled it with Calva. Which I do not in any way regret, but it does have this effect...
Alex is already working on improving the navigation around getting started and the CLI guide etc. There was a discussion about exactly this in another channel just the other day, funnily.
If anyone ever questions whether Clojure is a true Lisp, we can point out that it certainly qualifies based on its callous neglect of newcomers in re getting started. 🤣 Fortunately the support on Clojurians rocks. 👏 Hmm, can we pretend this a feature guaranteeing that we get to meet noobs?
For everything else you might say about the Clojure community, I'm happy that any random jabroni can reasonably get a response from the most senior people here in charge of the most important libraries in the ecosystem