Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cljs repl switches to previous ns after cider-repl-set-ns change followed by single eval (again) #3728

Open
mrrodriguez opened this issue Jul 23, 2024 · 8 comments

Comments

@mrrodriguez
Copy link

mrrodriguez commented Jul 23, 2024

I am observing the same problem again as reported and solved in #3503
The only differences will be in the versions involved.

After initializing a cider clj & cljs repl via cider-jack-in-clj&cljs I expect that after performing cider-repl-set-ns to change to some cljs namespace, the cljs repl buffer will remain in that namespace as I evaluate forms (unless it was in-ns or similar of course).

I have not had this issue in any recent cider versions over the last 6 months or so with emacs 29.1. I was using a few versions of cider along the way after the fix in CIDER 1.8.0-snapshot up until 1.15 I had no issues. The emacs upgrade alone (and maybe lein at the same time) is where I started to see this behavior come back again.
I had this problem with 1.15 of cider so I tried 1.15.1 and I get the same behavior.

Actual behavior

After using cider-repl-set-ns to change to a new cljs ns, the cljs repl correctly is set to that ns. I can then evaluate one time within the context of that namespace and get the eval output expected. However, the cljs repl then immediately returns to the last ns prior to cider-repl-set-ns - typically cljs.user.

Steps to reproduce the problem

Using this repo https://github.com/reducecombine/fig-main and running npm install there first. Then do cider-jack-in-clj&cljs in emacs.

Go to the cljs repl buffer. use cider-repl-set-ns to change to the cljs ns vemv.fig-main. Eval any form now, eg. 1, and the ns immmediately changes back to the prior ns, which is cljs.user by default.

The eval actually does work in the correct vemv.fig-main ns context, because doing something like (multiply 2 2) correctly resolves multiply and returns 4.

Environment & Version information

Mac OS - Intel chip

CIDER version information

CIDER 1.15.1 (Cogne)

(I've tried with other Clojure versions and it doesn't matter).

Lein / Clojure CLI version

Leiningen 2.11.2

Emacs version

GNU Emacs 29.4 (build 1, x86_64-apple-darwin23.5.0, NS appkit-2487.60 Version 14.5 (Build 23F79)) of 2024-07-21

Spacemacs/emacs using emacs-plus this

Operating system

OS X 14.5 "Sonoma"

JDK distribution

OpenJDK Runtime Environment Temurin-11.0.24+8 (build 11.0.24+8)
OpenJDK 64-Bit Server VM Temurin-11.0.24+8 (build 11.0.24+8, mixed mode)
@mrrodriguez
Copy link
Author

mrrodriguez commented Jul 23, 2024

I will give diagnostics here the same as I did before in #3503 (comment)

Using:

(setq inhibit-message nil)
(setq nrepl-log-messages t)
M-x toggle-debug-on-error

Reproducing the issue from "Steps to reproduce the problem" in the PR description:

The (clj) `nrepl-messages buffer has no activity during this.

The (cljs) `nrepl-messages buffer has this:

(-->
  id         "14"
  op         "eval"
  session    "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp "2024-07-23 15:34:39.181694000"
  code       "(in-ns 'vemv.fig-main)"
)
(<--
  id         "14"
  session    "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp "2024-07-23 15:34:39.240514000"
  ns         "vemv.fig-main"
  value      "nil"
)
(<--
  id         "14"
  session    "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp "2024-07-23 15:34:39.282608000"
  status     ("done")
)
(<--
  id                 "14"
  session            "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp         "2024-07-23 15:34:39.283462000"
  changed-namespaces (dict)
  repl-type          "cljs"
  status             ("state")
)
(-->
  id                                 "17"
  op                                 "eval"
  session                            "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp                         "2024-07-23 15:35:00.668720000"
  code                               "(inc 1)"
  column                             16
  file                               "*cider-repl dbg-cider/fig-main:localhost:53483(cljs:figwheel..."
  line                               2
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
  ns                                 "vemv.fig-main"
)
(<--
  id         "17"
  session    "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp "2024-07-23 15:35:00.709321000"
  value      "2"
)
(<--
  id         "17"
  session    "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp "2024-07-23 15:35:00.710491000"
  ns         "cljs.user"
)
(<--
  id         "17"
  session    "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp "2024-07-23 15:35:00.756109000"
  status     ("done")
)
(<--
  id                 "17"
  session            "f4de252d-4117-4458-8e4f-cee4382a6dbd"
  time-stamp         "2024-07-23 15:35:00.774130000"
  changed-namespaces (dict ...)
  repl-type          "cljs"
  status             ("state")
)

Note: It doesn't matter what form I eval, I always get the result of that expression and then the immediate changing of the ns back to cljs.user.

@vemv
Copy link
Member

vemv commented Jul 23, 2024

Thanks!

I'll check it.

Might be a Figwheel-specific issue - nowadays we put far more attention to shadow-cljs, which is why a minimal repro over https://github.com/reducecombine/icd.scroll would be also useful.

Either ways, I'll try to repro the problem in both projects as time allows.

@mrrodriguez
Copy link
Author

Thanks!

I'll check it.

Might be a Figwheel-specific issue - nowadays we put far more attention to shadow-cljs, which is why a minimal repro over https://github.com/reducecombine/icd.scroll would be also useful.

Either ways, I'll try to repro the problem in both projects as time allows.

My real problem case is in a figwheel-main project (the same as the last time I reported this same sort of issue in #3503 ). I will try (tomorrow) to give some details for the shadow-cljs setup as well just to provide more information.

@mrrodriguez
Copy link
Author

mrrodriguez commented Jul 24, 2024

I ran the same experiment as above with the https://github.com/reducecombine/icd.scroll which notably uses jack-in with shadow-cljs instead of figwheel-main.

I do NOT observe this issue in the shadow-cljs case. So it is looking to be specific to figwheel-main somehow. ie. I can eval forms and remain in the same ns in the CLJS repl as I'd expect. I also understand that shadow is typically more popular than figwheel nowadays. I have repos using both and this is just a quite painful issue when trying to work in the figwheel projects (hard to use the repl when the ns is reset after every eval).

For completeness:

I will give diagnostics here the same as I did before in #3503 (comment)

Using:

(setq inhibit-message nil)
(setq nrepl-log-messages t)
M-x toggle-debug-on-error

Reproducing the issue from "Steps to reproduce the problem" in the PR description:

The (clj) `nrepl-messages buffer has no activity during this.

The (cljs) `nrepl-messages buffer has this:

(-->
  id         "14"
  op         "eval"
  session    "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp "2024-07-24 16:08:02.239691000"
  code       "(in-ns 'icd.scroll.app)"
)
(<--
  id         "14"
  session    "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp "2024-07-24 16:08:02.290441000"
  ns         "icd.scroll.app"
  value      "nil"
)
(<--
  id         "14"
  session    "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp "2024-07-24 16:08:02.340799000"
  status     ("done")
)
(<--
  id                 "14"
  session            "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp         "2024-07-24 16:08:02.363098000"
  changed-namespaces (dict)
  repl-type          "cljs"
  status             ("state")
)
(-->
  id                                 "16"
  op                                 "eval"
  session                            "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp                         "2024-07-24 16:09:06.938388000"
  code                               "(inc 1)"
  column                             17
  file                               "*cider-repl dbg-cider/icd.scroll:localhost:3333(cljs:shadow)..."
  line                               5
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
  ns                                 "icd.scroll.app"
)
(<--
  id         "16"
  session    "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp "2024-07-24 16:09:06.973878000"
  value      "2"
)
(<--
  id         "16"
  session    "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp "2024-07-24 16:09:06.975791000"
  ns         "icd.scroll.app"
)
(<--
  id         "16"
  session    "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp "2024-07-24 16:09:07.543333000"
  status     ("done")
)
(-->
  id         "17"
  op         "cider/get-state"
  session    "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp "2024-07-24 16:09:07.544368000"
)
(<--
  id                 "16"
  session            "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp         "2024-07-24 16:09:07.585111000"
  changed-namespaces (dict)
  repl-type          "cljs"
  status             ("state")
)
(<--
  id                 "17"
  session            "639fafcc-1c16-4252-9075-5edc5bb08d4e"
  time-stamp         "2024-07-24 16:09:07.625485000"
  changed-namespaces (dict)
  repl-type          "cljs"
  status             ("state")
)

@vemv
Copy link
Member

vemv commented Jul 24, 2024

Hi Mike, awesome, I appreciate a lot the thorough effort.

Now it might be a matter of nailing down the issue to a specific Fig version.

Does it work correctly for you if you use the latest Fig version as of #3503 (comment)?

I reckon the variables that you can play with are

  • Fig version
  • cider version
  • Lein version (some months ago misc plugins broke because of Lein changes)

From intuition, it should be a Fig thing, but let me know.

@mrrodriguez
Copy link
Author

mrrodriguez commented Jul 24, 2024

Hi Mike, awesome, I appreciate a lot the thorough effort.

Now it might be a matter of nailing down the issue to a specific Fig version.

Does it work correctly for you if you use the latest Fig version as of #3503 (comment)?

I reckon the variables that you can play with are

* Fig version

* cider version

* Lein version (some months ago misc plugins broke because of Lein changes)

From intuition, it should be a Fig thing, but let me know.

The example from https://github.com/reducecombine/fig-main uses [com.bhauman/figwheel-main "0.2.18"]
My problem I had in my real app was with that same version. This is the latest version too https://clojars.org/com.bhauman/figwheel-main

I don't suspect it is the cider version specifically since I had no changes to that when the problem begun to happen to me. I also had no change to figwheel-main version recently

What I did have change was:

  1. emacs version (but only a minor version) from 29.1 to 29.4
  2. lein version from 2.9.8 to 2.11.2 (latest)

At this point, perhaps it is looking like lein could be the culprit. I'm having issues with 2.11.2 (the latest that I recently updated to).

What I think is relevant here though is that these are all nearly the "latest" version of each dependency involved - so I'd think this is the main case we'd expect to not be broken.

@vemv
Copy link
Member

vemv commented Jul 24, 2024

In case it helps, on a unixy box you can try the older Lein by downloading https://github.com/technomancy/leiningen/blob/2.9.8/bin/lein to somewhere in your path.

Normaly I do curl https://raw.githubusercontent.com/technomancy/leiningen/2.9.8/bin/lein > lein298 so that I can lein298 repl without uninstalling other Leins.

@mrrodriguez
Copy link
Author

In case it helps, on a unixy box you can try the older Lein by downloading https://github.com/technomancy/leiningen/blob/2.9.8/bin/lein to somewhere in your path.

Normaly I do curl https://raw.githubusercontent.com/technomancy/leiningen/2.9.8/bin/lein > lein298 so that I can lein298 repl without uninstalling other Leins.

I need to gather more experimental details here, but I'll update that I did bring the lein version down and I still had the same problem. I tried 2.9.8 I believe, but will have to double check and show the steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants