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 #3503

Closed
mrrodriguez opened this issue Oct 8, 2023 · 5 comments

Comments

@mrrodriguez
Copy link

Expected behavior

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).

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.8.0-snapshot (package: 20231007.628), nREPL 1.0.0
;; Clojure 1.10.0, Java 1.8.0_282

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

Lein / Clojure CLI version

Leiningen 2.9.8

Emacs version

GNU Emacs 29.1 (build 1, x86_64-apple-darwin22.6.0, NS appkit-2299.70 Version 13.6 (Build 22G120)) of 2023-10-05

Spacemacs/emacs using emacs-plus this

(emacs v28 gave me the same results)

Operating system

OS X 13.6 "Ventura"

JDK distribution

OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.282-b08, mixed mode)
@mrrodriguez
Copy link
Author

mrrodriguez commented Oct 8, 2023

As requested on slack concerning this here. I have some extra diagnostic info from my buffers when this issue occurs.

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         "34"
  op         "eval"
  session    "22e456e6-b206-40d1-9ca2-3898a9247ca0"
  time-stamp "2023-10-07 22:05:58.350191000"
  code       "(in-ns 'vemv.fig-main)"
)
(<--
  id         "34"
  session    "22e456e6-b206-40d1-9ca2-3898a9247ca0"
  time-stamp "2023-10-07 22:05:58.380896000"
  ns         "vemv.fig-main"
  value      "#namespace[vemv.fig-main]"
)
(<--
  id         "34"
  session    "22e456e6-b206-40d1-9ca2-3898a9247ca0"
  time-stamp "2023-10-07 22:05:58.381450000"
  status     ("done")
)
(<--
  id                 "34"
  session            "22e456e6-b206-40d1-9ca2-3898a9247ca0"
  time-stamp         "2023-10-07 22:05:58.382159000"
  changed-namespaces (dict)
  repl-type          "clj"
  status             ("state")
)
(-->
  id                                 "35"
  op                                 "eval"
  session                            "b15b6546-8e98-49c5-935e-cd73e0d0520e"
  time-stamp                         "2023-10-07 22:05:59.406730000"
  code                               "(multiply 1 2)"
  column                             16
  file                               "*cider-repl cider-issues/fig-main:localhost:64551(cljs:figwh..."
  line                               96
  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         "35"
  session    "b15b6546-8e98-49c5-935e-cd73e0d0520e"
  time-stamp "2023-10-07 22:05:59.436118000"
  value      "2"
)
(<--
  id         "35"
  session    "b15b6546-8e98-49c5-935e-cd73e0d0520e"
  time-stamp "2023-10-07 22:05:59.436913000"
  ns         "cljs.user"
)
(<--
  id         "35"
  session    "b15b6546-8e98-49c5-935e-cd73e0d0520e"
  time-stamp "2023-10-07 22:05:59.437307000"
  status     ("done")
)
(<--
  id                 "35"
  session            "b15b6546-8e98-49c5-935e-cd73e0d0520e"
  time-stamp         "2023-10-07 22:05:59.437958000"
  changed-namespaces (dict)
  repl-type          "cljs"
  status             ("state")
)

@vemv vemv closed this as completed in 47d9a95 Oct 8, 2023
@vemv
Copy link
Member

vemv commented Oct 8, 2023

I could repro!

The bug was introduced in 5f705b0 which matches with your description (I had no issues until yesterday when I bumped cider versions up (I was like a year old).)

A new MELPA snapshot will be available within a couple hours.

Thanks much for persevering with an accurate report.

@mrrodriguez
Copy link
Author

I could repro!

The bug was introduced in 5f705b0 which matches with your description (I had no issues until yesterday when I bumped cider versions up (I was like a year old).)

A new MELPA snapshot will be available within a couple hours.

Thanks much for persevering with an accurate report.

Thanks! I’ll try it out soon then. I looked at the changes and they seem to make sense to me. I don’t know exactly why piggieback changes the ns, but at least there is a way to avoid it.

@mrrodriguez
Copy link
Author

As a follow-up. I tried the new snapshot and the issue has been resolved for me. 🎉

@vemv
Copy link
Member

vemv commented Oct 10, 2023

Happy to hear!

@clojure-emacs clojure-emacs locked as resolved and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants