Fork me on GitHub
#cider
<
2019-09-18
>
Ian Fernandez02:09:28

guys, how can I use cider with shadow-cljs node-repl?

Ian Fernandez02:09:50

I'm having some problems on the repl recognizing deps

Ian Fernandez03:09:39

that was related to this

Ian Fernandez02:09:49

shadow-cljs.edn

{:deps         true
 :builds       {:cloud-function {:target           :node-library
                                 :main             firstfunction.firstfunction.foo/hello
                                 :output-to        "index.js"
                                 :compiler-options {:optimizations :simple}
                                 :exports-var      firstfunction.firstfunction.foo/exports}
                :test      {:target    :node-test
                            :output-to "target/firstfunction.firstfunction.js"
                            :compiler-options {:optimizations :simple}
                            :autorun   true}
                }}

Ian Fernandez02:09:27

deps.edn

{:paths ["resources" "src"]
 :deps  {org.clojure/clojure            {:mvn/version "1.10.1"}
         org.clojure/clojurescript      {:mvn/version "1.10.520"}
         org.clojure/core.async         {:mvn/version "0.4.500"}
         org.clojure/tools.logging      {:mvn/version "0.5.0"}
         ch.qos.logback/logback-classic {:mvn/version "1.2.3"}

         tick                                {:mvn/version "0.4.17-alpha"}
         com.lucasbradstreet/cljs-uuid-utils {:mvn/version "1.0.2"}
         cljs-bean                           {:mvn/version "1.3.0"}
         thheller/shadow-cljs                {:mvn/version "2.8.51"}
         funcool/promesa                     {:mvn/version "2.0.1"}}
 :aliases {:test                 {:extra-paths ["test"]
                                  :extra-deps  {org.clojure/test.check {:mvn/version "0.10.0-RC1"}}}
                                  :main-opts  ["-m" "cognitect.test-runner" "-d" "test"]}
           :build-cloud-function {:main-opts ["-m" "shadow.cljs.devtools.cli" "compile" "cloud-function"]}}}

Ian Fernandez02:09:46

when I try

M-x cider-jack-in-cljs
using shadow-cljs it gives me:
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: env: node: No such file or directory

Ian Fernandez02:09:25

I've added on emacs path the nvm path

Ian Fernandez03:09:22

and when I connect from an external repl initialized on a terminal I can't require mine dependencies

dpsutton03:09:14

What command do you run from a repl and what error message or behavior do you observe when you connect

Ian Fernandez03:09:43

[nREPL] Starting server via /home/ianffcs/.nvm/versions/node/v12.10.0/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.1 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.22.0-beta8 -d nubank/midje-nrepl:1.2.0-SNAPSHOT server error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: /usr/bin/env: “node”: unexistent directory or archive error in process sentinel: Could not start nREPL server: /usr/bin/env: “node”: unexistent directory or archive

dpsutton03:09:36

i'm heading to bed so most likely culprits: 1. when starting from the repl. you aren't including the necessary cider-nrepl middleware. Do another jack-in-cljs and see the startup command used (it can be found in *Messages*) and connect to a shadow started from the terminal with that same startup command 2. you still don't have npx on the exec-path for emacs. try running (shell-command-to-string "which npx"). If it returns nil or some kind of message saying no command is found, you need to keep going. I used to use nvm but it didn't play nicely with emacs so i switched to a more traditional installation method

Ian Fernandez03:09:32

this are in messages buffer

dpsutton03:09:47

can you run node in your terminal?

dpsutton03:09:13

i think i ran into this with a custom installation directory and shadow expects node to be at /usr/bin/env. Not sure. that's just guess and hazy recollectoin

Ian Fernandez03:09:23

$which node
gives me

Ian Fernandez03:09:40

/home/ianffcs/.nvm/versions/node/v12.10.0/bin/node

Ian Fernandez03:09:59

maybe I'll make some symbolic links on bin?

dpsutton03:09:47

and can you run npx shadow-cljs?

Ian Fernandez03:09:22

my symbolic links worked

Ian Fernandez03:09:50

kinda sad if I have to upgrade nvm

Ian Fernandez03:09:02

Syntax error (FileNotFoundException) compiling at (src/firstfunction/firstfunction/foo.cljs:1:1).
Could not locate cljs_bean/core__init.class, cljs_bean/core.clj or cljs_bean/core.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.

Ian Fernandez03:09:20

now it's giving this when I try to load the namespace

dpsutton03:09:51

no idea. do you require cljs-bean anywhere?

dpsutton03:09:56

or is that some transitive dep?

Ian Fernandez03:09:58

(ns firstfunction.firstfunction.foo
  (:require
     [cljs-bean.core :refer [bean ->clj ->js]]))

dpsutton03:09:52

and did you add that dep?

dpsutton03:09:52

is that a clj or cljs file?

dpsutton03:09:13

weird that its saying its looking for .class, clj, or cljc files

Ian Fernandez03:09:42

I rerun the repl and it's like these now

dpsutton03:09:04

ask in #shadow-cljs i think there may have been a bug with the node-* repls

dpsutton03:09:17

its saying its not connected to an app there

Ian Fernandez03:09:55

also, when I load the buffer

Ian Fernandez03:09:01

it's eternal loading =<

dpsutton03:09:41

it can't load. you still have a clj repl. it hasn't connected to the js runtime

dpsutton03:09:00

which explains the reason why its trying to load cljs bean as a clj lib

Ian Fernandez03:09:06

yeah, I thought it would be something like this

Ian Fernandez03:09:29

I'll try to load that stuff on IntelliJ for now =<

Ian Fernandez04:09:27

I did it @dpsutton!

Ian Fernandez04:09:36

https://andrearichiardi.com/blog/posts/clojurescript-cursive-shadow-setup.html => We need to run that JavaScript file in the node runtime in order to get to our REPL, therefore we run in a terminal ...

malch05:09:49

Is there a way to disable suitable?

malch05:09:12

It breaks for me with the latest snapshot (I'm using CIDER with shadow-cljs)

bozhidar06:09:44

@malch Currently that’s not possible, but if you submit a bug report probably @robertkrahn is going to address it pretty quickly.

bozhidar06:09:04

Making it possible to disable suitable is in our todo list.

malch06:09:13

Ok, thanks! Will do it later today