Fork me on GitHub
#calva
<
2023-02-28
>
cjmurphy01:02:51

Our code-base root directory (where the deps.edn file is located), say called foo, has a symbolic link. So /opt/foo-app/ is the same root directory. When I F12 (Go to definition) a function call that has its definition in the same file something odd happens - VS Code opens a new tab where the file is under the 'symbolic link root directory'. So now VS Code has two files open in two tabs, whereas in reality there is only one file. Does anyone know what might be causing this or how to stop it? I have no idea how VS Code 'found out' about the symbolic link. I know this isn't actually a Calva question 😔

skylize02:02:34

> I know this isn't actually a Calva question At the present time

(= Calva Clojure-in-VSCode) ; => true
so any VS Code question falls under the Calva banner by default. (But, yeah, Calva maintainers don't work for Microsoft. So there will be limits on their ability to offer answers.)

🙂 2
bringe03:02:19

I don’t know what’s causing it or how to stop it, but maybe we can narrow it down a bit. Do you have a connected repl when this happens? And if so, does the same thing happen when you aren’t connected to a repl? If it does happen without a connected repl, this might be related to clojure-lsp, and pasting <https://calva.io/clojure-lsp/#viewing-the-logs-between-the-client-and-server%7Cthe client<->server logs> here for when you experience the issue might be helpful.

cjmurphy07:02:29

Yes it only happens with a connected repl. I can see the symbolic link 'version' of the file (file whose path starts with /opt/) in the log file you mentioned at "textDocument" and "arguments" to a "command".

pez10:02:55

Iirc, Calva has a setting for preferring clojure-lsp definitions over nREPL, see if that hides the problem for you.

cjmurphy10:02:12

This looks like the setting. I'll shutdown VS Code then bring it up again and test...

pez10:02:55

Why shutdown VS Code?

cjmurphy10:02:57

So that configuration changes take effect. Nice to know I don't need to.

😂 2
cjmurphy10:02:38

Great, that fixed the problem 🙂

pez10:02:43

Very few Calva settings demand restart. We try to tell in the descriptions if they do.

pez10:02:38

> Great, that fixed the problem 🙂 It hid the problem. Could be something with your classpath that makes the REPL find the wrong file.

cjmurphy10:02:45

I'll settle with hiding just for now. Makes sense it is a CP issue.

cjmurphy23:03:29

The classpath as evaluated at the REPL doesn't have any entries starting with "/opt/foo/"

(str/split (java.lang.System/getProperty "java.class.path") #":")
Here are the first ten (the rest being a long continuation of /root/.clojure/repos/ libraries):
("test"
 "user"
 "src"
 "resources"
 "/root/.clojure/repos/aero/aero/1.1.6/aero-1.1.6.jar"
 "/root/.clojure/repos/babashka/process/0.0.2/process-0.0.2.jar"
 "/root/.clojure/repos/binaryage/oops/0.7.1/oops-0.7.1.jar"
 "/root/.clojure/repos/buddy/buddy-auth/3.0.1/buddy-auth-3.0.1.jar"
 "/root/.clojure/repos/buddy/buddy-hashers/1.8.1/buddy-hashers-1.8.1.jar"
 "/root/.clojure/repos/cider/cider-nrepl/0.28.5/cider-nrepl-0.28.5.jar")
Presumably that means it isn't a classpath issue??

pez08:03:35

I agree. I do wonder what could be going on. Can you create a minimal repro project?

cjmurphy09:03:11

Not immediately but sure will do...

cjmurphy03:05:01

I think this issue would be solved if VS Code could be told to only care about project files, not what it calls 'Other files'. This picture should tell the story:

cjmurphy03:05:06

I looked for a VS Code option for 'only project files' but couldn't find one.

bringe19:05:23

@UKFSJSM38 Is there any way to configure clojure-lsp (assuming Calva is set to use/prefer that and it's running) to solve this problem?

ericdallo19:05:41

I couldn't understand the issue yet 😅 can anyone summarize or provide a minimal sample?

cjmurphy01:05:43

The issue is that VSCode thinks there are two files (normal file and symbolic link file) when in reality there is only one. Thus sometimes two tabs for the same file can be open - one for the actual file and another for the symbolic link version of it. These days when I notice I'm editing the symbolic link file I shut that tab down and re-navigate to the line I was on. Sorry I can't remember exactly what things go wrong, but the IDE does become buggy when there are two of the same. This is hardly a big deal problem, but didn't happen with IntelliJ.

cjmurphy02:05:21

In the picture above you can see for the file .../ui/drawings/domain.cljc that the real version is modified and symbolic link version not modified. If I opened the symbolic link version I would start editing a stale cached version of the file.

ericdallo12:05:36

I can't see how this is related to clojure-lsp, maybe a Vscode thing, I think a minimal repro would help calva maintainers confirm that

cjmurphy13:05:26

Just for the purposes of documenting the problem, it seems the symbolic link is from the outside (of the project) pointing in:

chris@pop-os:/opt$ pwd
/opt
chris@pop-os:/opt$ ls -al | grep foo-app
lrwxrwxrwx  1 root root   45 Feb 16 00:57 foo-app -> /home/chrismurphy/code/foo-app/foo-app/
It is the second foo-app that is the VSCode's project root directory, that has the deps.edn file. Something I might try is deleting the symbolic link. It shouldn't be necessary for ordinary development, and if something breaks it might give me a clue as to how VSCode is picking up 'outside' files.

🙏 2
bringe17:05:01

I think I forgot / reversed the above info on what "fixed" the problem - thinking that switching to using the repl for definitions over clojure-lsp fixed the problem, when really using clojure-lsp for definitions fixed it, if I understand correctly. CC @UKFSJSM38. Thanks for checking in here, though. simple_smile

👍 2
cjmurphy17:05:01

Yes, setting "Calva: Definition Provider Priority" to lsp, repl did seem to fix the problem, but I now work the opposite way round, the default, which is repl, lsp.

pez19:05:20

It is really strange that the REPL finds those symlinks.

ericdallo21:05:35

Glad to hear LSP is working more than the repl for that feature :)

clojure-lsp 4
cjmurphy23:05:12

I think the issue has to do with the fact that the nREPL Server is running inside a Docker container. If I look at the Dockerfile it has these lines:

COPY ./foo-app /opt/foo-app
WORKDIR /opt/foo-app 

👍 2
cjmurphy23:05:45

Getting rid of the symlink meant that navigation (from F12) couldn't proceed at all:

cjmurphy06:06:14

Note that the way I printed the classpath before was misleading. This code shows the long form for each CP file:

(do
    (require '[clojure.java.classpath :as cp])
    (->> (cp/classpath)
         (map #(.getAbsolutePath %))
         (take 5)))
Result:
("/opt/foo-app/test"
 "/opt/foo-app/user"
 "/opt/foo-app/src"
 "/opt/foo-app/resources"
 "/root/.clojure/repos/aero/aero/1.1.6/aero-1.1.6.jar")

cjmurphy17:06:27

We fixed this issue by having the Dockerfile take an arg:

WORKDIR ${HERE}/foo-app
COPY ./foo-app ${HERE}/foo-app
So now the container uses the directory it is started from. Happy ending.

🙌 4
woohoo 2
Thierry08:02:48

Where in the startup/jack-in can I add -D java options for my leiningen project? I get the logs I want up to the repl starting message in the jack-in cmd cli and after the repl is started I only seem get the java.net.debug output in the jack-in cmd cli. When I check the command lines both java.exe that are running none of the -D options I have set seem to be passed to java.exe? Am I overlooking something? I have tried the following ways: .code-workspace file setting:

"calva.jackInEnv": {
	"JAVA_TOOL_OPTIONS": "${env:JAVA_TOOL_OPTIONS} -Xdebug -Djavax.net.debug=all -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.defaultlog=trace"
}
project.clj alias:
:aliases {:debug {:jvm-opts ["--illegal-access=warn"
                             "-Xdebug"
                             "-Djavax.net.debug=all"
                             "-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog"
                             "-Dorg.apache.commons.logging.simplelog.defaultlog=trace"]}}

pez10:02:43

Neither of those (jackInEnv or :jvm-opts) are reflected on the command line. In the case of jackInEnv it is set in the environment in which the jack-in command line is run. Usually you should see an echo (from which tool I don't know) about which JAVA_TOOL_OPTIONS are used, when you override defaults.

pez10:02:23

You can provide some dummy environment variable with jackInEnv and look at it in the REPL to convince yourself that it is indeed passed on.

Thierry10:02:23

Well, thing is, something is logging when adding those. And I get the picking up JAVA_TOOL_OPTIONS message twice. But it logs so much that I cant scroll back to see what happens and why logging changes.

pez10:02:56

Increase the Terminal buffer so that you can read those logs. Might be enlightening.

Thierry10:02:12

Using windows and powershell ...

pez10:02:43

Some people enjoy pain 😃

👀 2
pez10:02:34

There is a VS Code setting for this. I think it should carry over to the Jack-in pseudo-terminal.

Thierry10:02:51

yea was just searching for scrollback

pez10:02:12

terminal lines something-something

Thierry10:02:25

found it, gonna check if it works

Thierry10:02:37

It works and can atleast look back now. After the first mention of JAVA_TOOL_OPTIONS I can clearly see log entries by javax.net.ssl wire - http-outgoing-0 and headers - http-outgoing-0 and others. Then a second mention of JAVA_TOOL_OPTIONS occurs just before the nREPL starts and only javax.net.ssl gets logged to console, really strange. Example logs:

2023/02/28 11:30:14:585 CET [DEBUG] wire - http-outgoing-0 << "Date: Tue, 28 Feb 2023 10:30:29 GMT[\r][\n]"
javax.net.ssl|DEBUG|12|clojure-agent-send-off-pool-3|2023-02-28 11:30:34.321 CET|SSLContextImpl.java:428|System property jdk.tls.client.cipherSuites is set to 'null'
First mention:
cmd.exe /d /c lein update-in :dependencies conj [nrepl,"1.0.0"] -- update-in :plugins conj [cider/cider-nrepl,"0.28.5"] -- update-in [:repl-options,:nrepl-middleware] conj '["cider.nrepl/cider-middleware"]' -- with-profile +dev repl :headless
Picked up JAVA_TOOL_OPTIONS:  -Djavax.net.debug=all -Dorg.apache.hc.client5.http=TRACE -Dorg.apache.hc.client5.http.wire=TRACE -Dorg.apache.hc.client5.http.header=TRACE -Dorg.apache.commons.logging.simplelog.defaultlog=TRACE -Dlog4j.category.org.apache.http.wire=TRACE --illegal-access=warn -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.org.apache.http=TRACE -Dorg.apache.commons.logging.simplelog.log.org.apache.http.impl.conn=TRACE -Dorg.apache.commons.logging.simplelog.log.org.apache.http.impl.client=TRACE -Dorg.apache.commons.logging.simplelog.log.org.apache.http.client=TRACE -Dorg.slf4j.simpleLogger.defaultLogLevel=TRACE -Xdebug
Second mention:
Picked up JAVA_TOOL_OPTIONS:  -Djavax.net.debug=all -Dorg.apache.hc.client5.http=TRACE -Dorg.apache.hc.client5.http.wire=TRACE -Dorg.apache.hc.client5.http.header=TRACE -Dorg.apache.commons.logging.simplelog.defaultlog=TRACE -Dlog4j.category.org.apache.http.wire=TRACE --illegal-access=warn -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.org.apache.http=TRACE -Dorg.apache.commons.logging.simplelog.log.org.apache.http.impl.conn=TRACE -Dorg.apache.commons.logging.simplelog.log.org.apache.http.impl.client=TRACE -Dorg.apache.commons.logging.simplelog.log.org.apache.http.client=TRACE -Dorg.slf4j.simpleLogger.defaultLogLevel=TRACE -Xdebug
nREPL server started on port 1078 on host 127.0.0.1 - 

Thierry10:02:06

I'm trying to debug an issue with the clj-http library and tls but cant get the log to work after the jack-in

Thierry10:02:42

Starting the jackin manually in a terminal now

Thierry10:02:49

lets see what happens 🙂

Thierry10:02:51

same thing, weird, After the nREPL is connected the http-outgoing-0 debug lines no longer get logged to console

Thierry11:02:27

Don't know if related, but getting a reflective access warning.

WARNING: Illegal reflective access by clojure.core$bean$fn__7278$fn__7279 (file:/C:/Users/thier/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar) to method sun.security.provider.certpath.SunCertPathBuilderException.getAdjacencyList()

pez11:02:32

Maybe try with just one option first?

Thierry11:02:49

without any option:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by clojure.core$bean$fn__7278$fn__7279 (file:/C:/Users/thier/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar) to method sun.security.provider.certpath.SunCertPathBuilderException.getAdjacencyList()
WARNING: Please consider reporting this to the maintainers of clojure.core$bean$fn__7278$fn__7279
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

pez13:02:31

Seems unrelated to your issue. But might be something to ask about here: https://ask.clojure.org/index.php/search?q=reflection

Thierry14:02:41

ill have a look

pez14:02:04

Dear Calva friends. Please consider to answer The State of Clojure Survey 2023 https://surveymonkey.com/r/clojure2023. It is used to guide the efforts of many people involved with Clojure and its ecosystem. It's also an opportunity to express appreciation towards us who are providing Calva. 😍 (You are super awesome at this, generally. This is yet another opportunity, haha.) Thanks in advance! ❤️ 🙏 calva

💯 4
calva 5
clojure 2
Thierry18:02:32

Done :facepunch::skin-tone-2:💪:skin-tone-2:

❤️ 4
🙏 2
stantheman20:03:01

Yeah done:raised_hands:

❤️ 5
calva 1