Fork me on GitHub
#calva
<
2023-01-11
>
dangercoder09:01:35

Does anyone know why calva doesn't resolve vars in :required namespaces(sometimes) when I try to load a namespace and all dependencies? It works if I first load the dependency ns manually

pez09:01:09

I don't think I've seen this happen. If you can provide a repro that would be awesome.

👍 2
dangercoder10:01:37

Going to try and repro it and make an issue, it happens sometimes and I don't know why yet. • It doesn't appear after restarting the repl (which I don't want to do) • I load namespace foo which requires bar . foo/calculate is a function which uses a def: bar/currencies . I get the error: bar/currencies no such var

pez10:01:20

> It doesn't appear after restarting the repl Checking... If you restart the repl and then load foo, it works? Then you do some stuff and try to re-load foo , and the error happens?

skylize13:01:57

I have seen this numerous times too, but no idea yet what is the repro case. For now, I just manually eval the other ns and move on.

pez17:01:18

It sounds more like a REPL issue than a Calva one to me. Next time it happens, try do something like lein repl :connect and require foo with :reload. Would be interesting to know if that works.

skylize17:01:27

> try do something like lein repl :connect > I don't use Lein, so not really sure what you're asking for here.

bringe03:01:32

I see this too sometimes and also just eval the other namespace(s) and move on. Not sure what causes it but it does seem like it’s an issue with nrepl since Calva just delegates to nrepl for loading from what I know. If we can nail down a repro that would be great.

👍 2
pez10:01:58

>> try do something like lein repl :connect > I don't use Lein, so not really sure what you're asking for here. Sorry. I meant connect with another nrepl client.

pez10:01:09

An equivalent tools-deps command line is:

clojure -Sdeps '{:deps {reply/reply {:mvn/version "0.5.1"}}}' -M -m reply.main --attach `< .nrepl-port
`

Asher Serling22:01:10

I've been using calva on my luminus project with the Server + Client option, and it works great. In my current setup I have clojure installed locally, but I'd like to move to a docker development environment. It seems that if I connect vs code to a docker container, and install calva in that container, than i can continue to use calva the same way as I've been doing up until now. However, when I try connecting vs code to a docker container, my computer seems to be working really hard. I'd like to try to instead run an nrepl server in the docker container, and connect calva to that running server. Is there a way that I can do this which will imitate the Server + Client experience, or will I have two run to separate nrepl servers, and have two vs code windows open?

pez22:01:41

Hi! I think you should be able to set it up so that you run the nrepl server in the docker container and connect using the existing Server + Client connect sequence It can be a bit finicky (I am fighting this very battle today myself in a Luminus based project.). Findings so far: • Make sure the nrepl server is bound to 0.0.0.0. • Use a hard coded repl port • Forward the nrepl port to the host machine. ◦ If you are using a volume for the project, forward to same port number on the host, so that the nrepl-port file will contain the truth for Calva to find. • Probably more that I am forgetting right now. 😃

Asher Serling22:01:34

Hi @U0ETXRFEW, nice to hear there's someone else out there currently dealing with the same thing. What command did you run inside the container, just 'lein repl' or something more? I should also mention that I'm using shadow-cljs. I don't know if this makes a difference, I am pretty new to clojure

pez22:01:13

I use the same command as when starting it locally. If you use the command Calva: Copy Jack-in command line to clipboard and select the Server + Client sequence you will get the command.

Asher Serling22:01:47

ah cool, I'll try that. thanks so much

🙏 2
Asher Serling22:01:57

nice looks like that'll be a big help. thanks again

Asher Serling22:01:03

and calva is absolutely amazing

pez22:01:41

Glad to hear! Please consider filing a review on the marketplace. ❤️

Asher Serling23:01:37

the repl is now working after following your instructions. however there is no interaction with the browser. how can i fix this?

Asher Serling23:01:41

maybe i'm missing another port binding?

Asher Serling23:01:39

yep that was it, after binding port 9630 it's working like a charm

pez23:01:44

Great to hear!

Carsten Behring09:01:51

I see this as one of the biggest advantages of Calva compared to other Clojure IDEs. In this space VS Code + Calva is maybe even the only real option. (Emacs + TRAMP or SSH + tmux + Emacs is not the same) From my limited trials I have as well the impressions that Calva + VS Code has all needed features, it just need to be documented in a more prominent place and with several scenarios. I have as well the scenario of "docker on a remote sever", which works as well but is a but is even more finicky. Additionally I see the scenario of "windows Laptop with only VS Code" + "remote docker on Linux server" as potentially interesting for some people.

Asher Serling10:01:50

i'm finding that the 'go to definition' command in vs code is not working now that i'm using docker. is there a way i can fix this?

Asher Serling10:01:16

to be clear, it's not working for imported libraries

Asher Serling10:01:28

my mistake, it seems that it's not working for anything brought in from another file

pez13:01:31

@U049ALBMH4K how did you solve it?

pez13:01:54

As I understand the problem: The REPL is running in the container and have different paths to the files than you have locally. When the REPL responds with a path to file, VS Code doesn't find it there. Seems Calva (or maybe nREPL) would need to support some kind of mapping.

Asher Serling17:01:52

This is what I thought the problem is as well. i'm really not sure how to solve it

Asher Serling17:01:48

@U0ETXRFEW have you had a positive experience using the vs code 'attach to running container' feature?

Asher Serling17:01:37

it seems to be going pretty smoothly. it froze up my computer a bit at first but now it seems to be working

Asher Serling17:01:28

also, the 'go to definition' works fine with my clojure project when vs code is not connected to a repl. would it be possible to make a setting which allows the 'go to definition' feature to function independantly of the connection to the repl?

pez20:01:27

> have you had a positive experience using the vs code 'attach to running container' feature? I think it has been a bit painful. In the app I am working with I've now instead put the infrastructure it uses in a docker-compose system but run the Clojure REPL locally.

pez20:01:55

> would it be possible to make a setting which allows the 'go to definition' feature to function independantly of the connection to the repl? There is such a setting, actually. Search for ”calva definition priority” (or something like that) in the settings. Set it to prioritize lsp over repl. Usually it is better with repl definitions (e.g. for .cljc files), but a lying repl is another thing...

bringe03:01:50

@U7CAHM72M @U049ALBMH4K If either of you wanted to submit PRs for documenting this Docker stuff better in the Calva docs that would be great. I don’t use Calva with Docker so I’m not familiar with it. I’m not sure if that info should be added to https://calva.io/remote-development or if what you’re doing is different from that.