Fork me on GitHub
#cursive
<
2018-09-25
>
bill00:09:58

On a new laptop running Build #IU-182.4323.46, built on September 3, 2018 I installed Cursive 1.7.0-2018.2 and restarted IntelliJ as prompted. At IntelliJ startup I expect to be prompted for my Cursive license key but I’m not. In a new Leiningen project, when editing core.clj, I expect to see a “Cursive” menu item on the context menu but I don’t. I don’t see a way to open a REPL either.

kharus03:09:26

Hi, Is it possible to make scratch files working with Cursive? I’m creating a clojure scratch files in IntelliJ. But auto-complete in scratch file doesn’t work. Everything else works fine - I can edit code and send it to REPL.

cfleming10:09:30

@kharus Unfortunately I think that’s still tricky, the scratch files are weird. I’ll try to fix that soon.

cfleming10:09:07

@bill I’ve replied over on the mailing list.

👌 4
Sy Borg11:09:54

that flag, right. thanks

cfleming11:09:49

It’s more that the problem is loading into a namespace that you didn’t expect. Loading that namespace into the REPL will fix the problem, but may still be confusing if you’re not clear where your code is being loaded.

Sy Borg11:09:05

it works for me with that flag set, but when it's not I still get the error (even after 'Switch REPL NS to current file')

cfleming11:09:12

You need to load the namespace into the REPL or evaluate the ns form to actually create the namespace. “Switch REPL NS…” just does in-ns which has the problem described in that article.

cfleming11:09:44

i.e. you want “Load file in REPL” or to evaluate the ns form.

Sy Borg11:09:48

I see, but I don't need the whole file. though, I suppose, I don't have other choice

cfleming11:09:04

Yes, you can just load the NS form.

cfleming11:09:29

But it really depends on where (in which namespace) you actually want your loaded code to end up.

wilkerlucio13:09:28

@cfleming hello, I got situation where Cursive is complaining that I have a ciclic reference, but I dont, its a cljc file that requires the macros on itself for cljs,eg :

wilkerlucio13:09:33

(ns com.wsscode.pathom.connect
  #?(:cljs [:require-macros com.wsscode.pathom.connect])
  (:require [clojure.spec.alpha :as s]
            [com.wsscode.pathom.core :as p]
            [com.wsscode.pathom.parser :as pp]
            [com.wsscode.pathom.trace :as pt]
            [clojure.math.combinatorics :as combo]
            [#?(:clj  com.wsscode.common.async-clj
                :cljs com.wsscode.common.async-cljs)
             :as p.async
             :refer [let-chan go-promise go-catch <? <?maybe <!maybe]]
            [clojure.set :as set]
            [clojure.core.async :as async :refer [<! >! go put!]]))

wilkerlucio13:09:48

it complains that com.wsscode.pathom.connect requires com.wsscode.pathom.connect, but that was always ok

wilkerlucio13:09:31

now a bunch of comands don't work because Cursive don't want to run that (running tests for example)

cfleming13:09:23

@wilkerlucio I don’t think anything has changed with that code in a while - was Cursive ok with this namespace previously?

wilkerlucio13:09:44

yes, it was, started the problem since the last EAP I think

wilkerlucio13:09:08

this is a very common practice to do in cljc files to have macros available on CLJS from the file

wilkerlucio13:09:27

the project is public, you can try yourself if you want: https://github.com/wilkerlucio/pathom/

wilkerlucio13:09:38

and I'm running it though deps.edn (I only use lein to build the jar and publish)

cfleming14:09:07

Ok, I’ll try it out, thanks

cfleming14:09:56

@wilkerlucio Here’s the problem. That project depends on nubank/workspaces, and that one depends on com.wsscode/pathom:2.0.4. So this project depends on itself, and that is confusing things.

wilkerlucio14:09:44

humm, gotcha, so I guess I can make some alias shuffling to get it to run witouht workspaces, I don't it on CLJ side anyway, thanks for looking it up!

cfleming14:09:02

You can use:

nubank/workspaces          {:mvn/version "1.0.0-preview8"
                                             :exclusions [com.wsscode/pathom]}

cfleming14:09:31

Ugh, you get the idea

cfleming14:09:42

I tested that, it works.

wilkerlucio14:09:48

thanks, I didn't know :exclusions works on deps, awesome!

wilkerlucio14:09:47

I add the exclusions on the 2 places where workspaces is required but I still get the ciclic error

wilkerlucio14:09:50

this is my launch config:

wilkerlucio14:09:01

is that correct?

cfleming14:09:23

Did you refresh your project after modifying the deps.edn?

cfleming14:09:50

You should no longer see pathom in your dependencies under the deps toolwindow.

cfleming14:09:43

You’ll need to expand out workspaces since it’s pulled in transitively.

wilkerlucio14:09:44

(I expanded the workspaces, not there too)

cfleming14:09:57

And you don’t see it in the project toolwindow under External Libraries?

wilkerlucio14:09:59

Ill try restarting intellij, just in case

wilkerlucio14:09:57

I think I know whats wrong

wilkerlucio14:09:17

I see it under Libraries on project, I still have that on the lein side, so that might be it

cfleming14:09:35

Oh right, did you import from lein or from deps?

cfleming14:09:59

Yeah, you should only use one of them in Cursive.

wilkerlucio14:09:18

I only added lein because it keeps asking to do it when you open the project.clj

wilkerlucio14:09:23

can we disasble that once deps is on?

cfleming14:09:41

Oh, I see - yes, that should definitely go.

wilkerlucio14:09:22

I just removed the lein module, re-add the deps and tried over, but still complaining... I'm trying to restart IntelliJ now

cfleming14:09:53

Check the lein toolwindow to make sure that the project is no longer registered.

wilkerlucio14:09:08

yeah, I removed from that window

cfleming14:09:50

Is the lib still under External Libraries?

wilkerlucio14:09:13

got it, removing by hand from Libraries on the project

wilkerlucio14:09:27

seem like it added back again when I refresh the deps project, which is strange given the exclusions is there

cfleming14:09:54

And it’s definitely not in the dependencies tree in the deps toolwindow anywhere?

wilkerlucio14:09:19

no, not at all in the deps dependencies

cfleming14:09:28

That’s very weird.

cfleming14:09:56

But now if you refresh your deps project from the deps toolwindow, the lib stays gone?

wilkerlucio14:09:58

and I confirmed if I refresh the project I get it on external libs again

cfleming14:09:16

That’s if you refresh via deps, right?

cfleming14:09:30

The only think I can think of is that it might be deps classpath caching or something.

cfleming14:09:49

If you get the classpath via deps on the command line, is pathom in there?

wilkerlucio14:09:49

Wilker-Nu-2:pathom wilkerlucio$ clj -Spath -A:dev,:provided,:test,:http-drivers
src:/Users/wilkerlucio/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar:/Users/wilkerlucio/.m2/repository/org/clojure/clojure/1.9.0/clojure-1.9.0.jar:/Users/wilkerlucio/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/Users/wilkerlucio/.m2/repository/org/clojure/core.specs.alpha/0.1.24/core.specs.alpha-0.1.24.jar:/Users/wilkerlucio/.m2/repository/org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.jar:/Users/wilkerlucio/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.1.3/httpasyncclient-4.1.3.jar:/Users/wilkerlucio/.m2/repository/slingshot/slingshot/0.12.2/slingshot-0.12.2.jar:/Users/wilkerlucio/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.4.6/httpcore-nio-4.4.6.jar:/Users/wilkerlucio/.m2/repository/spec-coerce/spec-coerce/1.0.0-alpha6/spec-coerce-1.0.0-alpha6.jar:/Users/wilkerlucio/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar:/Users/wilkerlucio/.m2/repository/com/wsscode/spec-inspec/1.0.0-alpha2/spec-inspec-1.0.0-alpha2.jar:/Users/wilkerlucio/.m2/repository/clj-http/clj-http/3.8.0/clj-http-3.8.0.jar:/Users/wilkerlucio/.m2/repository/org/apache/httpcomponents/httpcore/4.4.9/httpcore-4.4.9.jar:/Users/wilkerlucio/.m2/repository/clj-tuple/clj-tuple/0.2.2/clj-tuple-0.2.2.jar:/Users/wilkerlucio/.m2/repository/riddley/riddley/0.1.12/riddley-0.1.12.jar:/Users/wilkerlucio/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/wilkerlucio/.m2/repository/org/apache/httpcomponents/httpclient/4.5.5/httpclient-4.5.5.jar:/Users/wilkerlucio/.m2/repository/org/clojure/math.combinatorics/0.1.4/math.combinatorics-0.1.4.jar:/Users/wilkerlucio/.m2/repository/potemkin/potemkin/0.4.4/potemkin-0.4.4.jar:/Users/wilkerlucio/.m2/repository/camel-snake-kebab/camel-snake-kebab/0.4.0/camel-snake-kebab-0.4.0.jar:/Users/wilkerlucio/.m2/repository/org/apache/httpcomponents/httpmime/4.5.5/httpmime-4.5.5.jar

cfleming14:09:44

I’m afraid I don’t know what more to suggest sorry, when I add those exclusions here it definitely gets removed and everything works.

wilkerlucio14:09:09

might be some other type of cache, I'm starting trying cleaning the .idea and starting over

wilkerlucio14:09:17

is there any other place I might need to clean cache from?

wilkerlucio14:09:42

and thanks a lot for hanging with me on this

cfleming14:09:45

Before trying that, try re-cloning the project and just importing the new copy, only using deps.

wilkerlucio14:09:24

I just saw a pom.xml there facepalm

wilkerlucio14:09:44

when I re-imported it seemed to use maven and pathom was in the libs, my guess the pom.xml was screwing things

cfleming14:09:12

Even so, the library name was Deps: <whatever> right? So it was deps adding it.

cfleming14:09:34

But maybe deps uses the pom under the hood? Seems unlikely, but who knows.

wilkerlucio14:09:33

no luck with that, still getting it, I'll try your suggestion and clone it again

wilkerlucio14:09:42

there is some weird cache it seems

cfleming14:09:02

Does the clone work correctly?

wilkerlucio14:09:03

even if I completly remove the workspaces dep, pathom still shows up in External Libraries

wilkerlucio14:09:18

no, new clone, same issue

cfleming14:09:28

That’s bizarre.

cfleming14:09:42

Let me close my project and re-open it, one sec.

cfleming14:09:26

I can’t get that lib to re-appear no matter what I do.

cfleming15:09:01

And the only changes to the version I cloned from your repo are the two exclusions.

wilkerlucio15:09:04

yeah, the thing about removing the workspaces and it still living there is bizarre

cfleming15:09:31

It’s even weirder that re-cloning the repo doesn’t fix it.

cfleming15:09:41

Did you clone from the link you sent me?

wilkerlucio15:09:52

cloned into a new folder

cfleming15:09:30

Then I have no idea, sorry.

cfleming15:09:58

That is definitely what the problem is, but I can only :shrugemoji: as to what is actually going on.

wilkerlucio15:09:00

no worries, should be something weird here, I'll try to clean some libs and try over again, I'll let you know if works out

cfleming15:09:16

Ok, thanks, I’d be interested to know if you figure it out.

wilkerlucio15:09:26

I figured, the pathom dep was coming from fulcro-inspect actually, not workspaces, adding exclusion there fixed the dep issue

wilkerlucio15:09:06

but weirdly, now it can't require core.async, CompilerException java.io.FileNotFoundException: Could not locate clojure/core/async__init.class or clojure/core/async.clj on classpath., compiling:(com/wsscode/pathom/core.cljc:1:1) , but the core.async is present on the deps, cursive can navigate to it, sorry, too many problems I'm bringing on a batch XD

wilkerlucio17:09:44

@cfleming I just got it working using IntelliJ classpath

wilkerlucio17:09:02

but when I do via Deps on the REPL command menu, the core.async is not going on the classpath

wilkerlucio17:09:13

but when I try via terminal using clj it works (using same aliases)

wilkerlucio18:09:43

one more hint: I works if I manually add the aliases to the REPL configuration, but the same aliases are already checked in the Aliases under deps menu, is expected to have to manually add those again to the deps run?

cfleming18:09:54

@wilkerlucio I don’t get it, why didn’t it appear in the classpath from the deps CLI then?

wilkerlucio18:09:23

let me clarify, because I might just had a wrong assumption

cfleming18:09:28

And in my project, fulcro-inspect doesn’t pull that dependency in.

cfleming18:09:56

Oh, one sec

cfleming18:09:13

Re: this: > I works if I manually add the aliases to the REPL configuration, but the same aliases are already checked in the Aliases under deps menu, is expected to have to manually add those again to the deps run?

cfleming18:09:43

Yes, it’s expected to have to add them to the run config. This is because you will probably want to use different aliases when running than when syncing your project.

wilkerlucio18:09:00

yeah, that's were I find my assumption wrong, but it makes sense

wilkerlucio18:09:53

if more people get this, might worth to add a note on the deps alias, something like (project aliases will not be considered, you have to add the ones you want)

cfleming19:09:27

Sure, this all needs proper documentation.

tanzoniteblack15:09:58

if I have a form like

(clj-time.coerce/from-sql-time (:some_key (first (korma/exec-raw ["select now() as some_key -- obfuscated"]))))
How can I get cursive to change it to:
(-> ["select now() as some_key -- obfuscated"]
    korma/exec-raw
    first
    :some_key
    clj-time.coerce/from-sql-time)
I know there's a Thread form command, but no matter where I place the carrot, it seems to only thread the most narrow sexp?

tanzoniteblack15:09:21

nevermind, immediately just figured it out after asking. Just run the command again in the next sexp up and it pulls it into the -> form inside of it

tanzoniteblack15:09:57

I'm trying out cursive after having used emacs+cider for several years, so adjusting to a slightly different way of thinking in the editor. With cider & clj-refactor, you highlight the sexp you want put into the threaded form, so that is what I was expecting and couldn't get to work