Fork me on GitHub
#cursive
<
2018-06-29
>
arlicle04:06:42

I use clojurescript + boot-cljs+cursive , I can't create a repl, the Context module show <unkown>, and get a error: Run Configuration Error: No modules containning clojure.main found. So how I can do now ?

cfleming06:06:46

@arlicle How are you creating your project in IntelliJ? Using lein and boot-lein-generate?

cfleming06:06:41

That error normally means that you don’t have Clojure attached to your project.

arlicle06:06:51

I have create it, I can run repl, but I can't connect to boot repl run in my terminal

cfleming06:06:44

That’s why I’m asking how you create your project - that error message normally means that you don’t have Clojure attached to your project anywhere.

cfleming07:06:29

@arlicle Have you seen this? This is the recommended approach: https://github.com/boot-clj/boot/wiki/For-Cursive-Users

cfleming07:06:02

Basically, you generate a project.clj from your boot file, and then import that into Cursive so it will set up your dependencies correctly.

arlicle07:06:12

I have read it, my profile.clj is from boot-lein-generate

cfleming09:06:25

@arlicle So you have generated a project.clj and then imported it into Cursive? If you open the Leiningen tool window (View-&gt;Tool Windows-&gt;Leiningen), do you see your project registered there? If not, does right-clicking it in the project toolwindow and selecting “Add as Leiningen project” help?

arlicle10:06:01

and I can't add

cfleming10:06:34

What do you mean you can’t add? Do you get an error?

arlicle10:06:14

I restart intelj, and it ok now

arlicle10:06:19

thank you very much @cfleming

arlicle10:06:55

I can connect to the remote repl now , but still have error : java.lang.ClassNotFoundException: cljs.analyzer clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: cljs.analyzer, compiling:(reagent/debug.clj:49:12)

arlicle11:06:16

change `(ns naotu.core (:require [reagent.core :as reagent] [ajax.core :refer [GET POST]] [cljs-uuid-utils.core :as uuid] ))` to `(ns naotu.core #?(:cljs (:require [reagent.core :as reagent] [ajax.core :refer [GET POST]] [cljs-uuid-utils.core :as uuid] )))`

arlicle11:06:01

@cfleming thank you very much 👍

kenny15:06:04

Just ran into an issue where Cursive throws an exception if I right click on a project.clj and click "Add as leiningen project" and a project with that name already exists. Cursive will add the most recent one and throw an exception. I would've expected some warning message that I already have a project with that name in my projects list.

kenny20:06:44

How are you planning on identifying the name of a tools-deps project @cfleming?

cfleming22:06:14

@kenny Right now it’s the name of the containing directory.

kenny22:06:34

That's how I ran into the above exception. I suppose you'll have to handle that more elegantly? 🙂

cfleming22:06:39

There really isn’t a good solution for that unfortunately - that’s the best I could come up with.

cfleming22:06:03

I hope so, but unfortunately deps doesn’t make that easy.

cfleming22:06:40

Alex is going to write about some discussions they’ve had around this, but he’s been busy.

cfleming22:06:10

Suggestions are welcome 🙂

kenny22:06:11

Oh cool. Just to spitball, perhaps if the project has Git enabled you could use part of the Git URI.

cfleming22:06:07

Possibly - the problem is knowing which part to use, and also that the results will be different if you check the project out without git.

cfleming22:06:34

I could also use more of the full project path, but again knowing how much to use is difficult.

cfleming22:06:55

Basically I have to come up with a reproducible name using only the deps file.

cfleming22:06:42

I could also allow a :cursive/name key in deps.edn, but Alex didn’t like that idea.

kenny22:06:02

TBH I don't care what IntelliJ/Cursive names the project. I navigate everything based on directory. So maybe you could name each project based on the full path and give it a "nickname" based on the parent dir.

kenny22:06:31

The nickname is only there so as to not pollute the project panel with absolute paths.

cfleming22:06:08

In IntelliJ modules have to have a single name. I’m not sure they allow slashes.

cfleming22:06:01

One possibility is to use module groups for intermediate directories. There’s still lots of potential edge cases though, such as modules outside the project base dir (which you know someone is going to do sooner or later)

kenny22:06:31

How about name of the parent directory and if two modules have the same parent, include the parent's parent in the name. Apply recursively until unique.

cfleming22:06:38

The problem is that due to the way that the IntelliJ external system integration works, I can’t look at information from other modules when determining the name.

kenny22:06:56

Well that makes things tricky... 😬

cfleming22:06:07

This is a higher-level API than the one I used for Leiningen. It makes lots of things easier, but some things harder. I’m still not sure it’s a good trade-off.

cfleming22:06:26

But it automatically handles lots of edge cases like the one you found above.

kenny22:06:49

Can you force the user to provide a name?

cfleming22:06:01

I’m still waiting for feedback from JetBrains, perhaps I’m missing something.

cfleming22:06:07

On every resolve, maybe 🙂

cfleming22:06:13

But no-one wants that.

cfleming22:06:35

I could force the user to supply a name and then write it to an auxiliary file, but… yuk.

cfleming22:06:48

I just wish tools.deps wasn’t so allergic to naming things.

kenny22:06:58

Are you able to detect if a module with a particular name exists when adding a new module?

cfleming22:06:27

I don’t think so, no, but then I’m not sure what happens - I haven’t tested this much yet.

cfleming22:06:29

Needs more investigation, and hopefully also feedback from JetBrains.

4
cfleming22:06:08

I may just end up using the lower level API I used for lein, which is more work but more flexible. The lein integration is mostly pretty solid these days after several years of bugfixes, so I should be able to just copy that.