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

Boot and the data_readers.clj file #1462

Closed
Malabarba opened this issue Dec 10, 2015 · 39 comments
Closed

Boot and the data_readers.clj file #1462

Malabarba opened this issue Dec 10, 2015 · 39 comments

Comments

@Malabarba
Copy link
Member

@Naomarik reports here that the debugger isn't working in boot. The error indicates that boot doesn't see our data_readers.clj file at the root of the class path.

According to http://clojure.org/reader:

When Clojure starts, it searches for files named data_readers.clj at the root of the classpath. Each such file must contain a Clojure map of symbols, like this:

{foo/bar my.project.foo/bar
foo/baz my.project/baz}

Does anyone know if this might be a boot bug or if we're doing something wrong?

@bbatsov
Copy link
Member

bbatsov commented Dec 10, 2015

Pinging @micha.

@Naomarik
Copy link
Contributor

I've found that (boot.core/load-data-readers!) will work once the repl is going, but I'm not sure where to put this so it does it automatically.
Reference: boot-clj/boot#47

@Malabarba
Copy link
Member Author

Maybe cider-nrepl should do it? Though I'm not sure how.

@Malabarba
Copy link
Member Author

Although, considering that this is a general Clojure thing, it would be nice if Boot handled it by default.

@Malabarba Malabarba modified the milestone: v0.11 Dec 11, 2015
@camelpunch
Copy link

Bump. I've found that (boot.core/load-data-readers!) removes the error, but doesn't cause C-M-x to jump into the debugger when a #break is present.

@Malabarba
Copy link
Member Author

@camelpunch There are some places where a #break doesn't work, so that might be unrelated to boot. Could you see if it works for you by hitting C-M-x in the following snippet?

(let [x 1]
  (inc #break x))

@camelpunch
Copy link

Yes, that works. Thanks!

@Malabarba
Copy link
Member Author

If anyone here uses boot, I'd still like to know if there's any way to load forms on startup. Even if there's no way for cider to do it, we should add instructions to the Readme.

@alexander-yakushev You've been using boot lately, haven't you?

@alexander-yakushev
Copy link
Member

I can confirm that doing (boot.core/load-data-readers) fixes the problem and the debugger works. Boot has an option to provide :eval form but only for the client — it doesn't work if REPL is started in server mode.

@Malabarba RE: debugger. Holy maker of pepperoni, I just tried it for the first time and it's frigging amazing! I didn't know that I've been missing so much :).

@Malabarba
Copy link
Member Author

@alexander-yakushev Thanks ^^

I guess the best we can do then is load this form as part of cider-nrepl if the symbol boot.core/load-data-readers resolves to a var. @bbatsov what do you think?

@bbatsov
Copy link
Member

bbatsov commented Jan 11, 2016

I think it's a reasonable approach and I've heard no other suggestions, so let's get this done.

@alexander-yakushev
Copy link
Member

I object, your honor.

First, boot.core/load-data-readers does nothing more but reloading readers
and setting root of data-readers to it.

Second, that fails when evaluated at the same time as middleware init,
because apparently Boot runs those in a separate thread, and I get 'setting
from non-binder thread' exception.

On Mon, Jan 11, 2016, 19:41 Bozhidar Batsov notifications@github.com
wrote:

I think it's a reasonable approach and I've heard no other suggestions, so
let's get this done.


Reply to this email directly or view it on GitHub
#1462 (comment)
.

@bbatsov
Copy link
Member

bbatsov commented Jan 11, 2016

OK, I guess we're back to the drawing board then. :-)

@bbatsov
Copy link
Member

bbatsov commented Jan 11, 2016

@Malabarba Maybe we should at least document this problem somewhere?

@micha
Copy link

micha commented Jan 11, 2016

If there's anything I can do to help let me know. (I'm mostly a Vim user
though.)

Micha Niskin

On Mon, Jan 11, 2016 at 2:34 PM, Bozhidar Batsov notifications@github.com
wrote:

OK, I guess we're back to the drawing board then. :-)


Reply to this email directly or view it on GitHub
#1462 (comment)
.

@alexander-yakushev
Copy link
Member

@micha How about having a separate :eval option that is evaluated by server rather than the one invoked by REPL client?

@Malabarba
Copy link
Member Author

@micha It would be great if data_readers.clj was loaded by default when a boot REPL is started. The Clojure documentation states that this file is loaded automatically, so I think it makes sense for the REPL to behave the same way.

@bbatsov
Copy link
Member

bbatsov commented Jan 12, 2016

Yeah, that'd be a dream solution. :-)

@micha
Copy link

micha commented Jan 12, 2016

Sure, I can do that. Would you consider it a bugfix or feature? So I know
whether to land it in 2.6.0 or a patch release.

Micha Niskin

On Tue, Jan 12, 2016 at 1:57 AM, Bozhidar Batsov notifications@github.com
wrote:

Yeah, that'd be a dream solution. :-)


Reply to this email directly or view it on GitHub
#1462 (comment)
.

@Malabarba
Copy link
Member Author

I think I'd call it a bugfix, but it could definitely go either way.

@bbatsov
Copy link
Member

bbatsov commented Feb 7, 2016

Any progress with this?

@Malabarba
Copy link
Member Author

While we wait for an upstream fix, I think I have a workaround. the debug.clj middleware can call (boot.core/load-data-readers!) when it receives the debug-init message. That only happens after the repl is connected, so I think it avoids the previous problem, right?

(of course, it will check whether that function exists first, so it won't error on non-boot projects)

@alexander-yakushev
Copy link
Member

(of course, it will check whether that function exists first, so it won't error on non-boot projects)

There isn't much point in calling exactly Boot's function as it is nothing else but:

  (#'clojure.core/load-data-readers)
  (set! *data-readers* (.getRawRoot #'*data-readers*))

And calling that in Leiningen won't hurt either.

Malabarba added a commit to clojure-emacs/cider-nrepl that referenced this issue Feb 14, 2016
@Malabarba
Copy link
Member Author

Even better.

@Malabarba
Copy link
Member Author

Pushed Alex's snippet.

Malabarba added a commit to clojure-emacs/cider-nrepl that referenced this issue Feb 15, 2016
Apparently this causes an exception in boot (precisely the system this
fix was for).
clojure-emacs/cider#1462 remains open.

Exception message: https://clojurians.slack.com/archives/cider/p1455501034000003

    ERROR: Unhandled REPL handler exception processing message {:op init-debugger, :print-level 10, :print-length 10, :session f10681b1-e8f4-48c6-bbc9-869f5ec1d54a, :id 7}
    java.lang.IllegalStateException: Can't set!: *data-readers* from non-binding thread
@tmarble
Copy link

tmarble commented Feb 18, 2016

Clojars is still based on the version clojure-emacs/cider-nrepl@1723057

I just did a local lein install with clojure-emacs/cider-nrepl@ebf3526 and that avoids the ugly stack trace (Can't set!: *data-readers* from non-binding thread)

FWIW I don't think the debugger is actually working as I tried C-u C-M-x, but that provoked a stack trace.

@Malabarba
Copy link
Member Author

Sorry, I've redeployed now. If the debugger still doesn't work for you, please file a new issue.

@Malabarba Malabarba reopened this Feb 18, 2016
@Malabarba
Copy link
Member Author

Ignore the accidental close, the issue itself is very much still open.

@Malabarba
Copy link
Member Author

@micha Has this made into a boot stable release?

@arichiardi
Copy link
Contributor

@Malabarba It's been milestoned

@Malabarba
Copy link
Member Author

@arichiardi Thanks for the notice!

@micha
Copy link

micha commented Apr 9, 2016

Attempted a fix with boot-clj/boot#439...does it work?

@bbatsov
Copy link
Member

bbatsov commented Apr 10, 2016

Guess someone should try this out.

@tmarble
Copy link

tmarble commented Apr 10, 2016

@micha OMG that works!

@Malabarba is there a current "cheatsheet" for the debugger? I've seen your blog, but I'm wondering if there is a current list keybindings (functions) and overview of what's possible? Sorry if this is obvious and I've missed it (ENOTENOUGHCOFFEE).

@bbatsov I just have to say CIDER is amazing! I love the docstring on mouseover symbol thing!

@bbatsov
Copy link
Member

bbatsov commented Apr 10, 2016

@Malabarba is there a current "cheatsheet" for the debugger? I've seen your blog, but I'm wondering if there is a current list keybindings (functions) and overview of what's possible? Sorry if this is obvious and I've missed it (ENOTENOUGHCOFFEE).

See http://cider.readthedocs.org/en/latest/extended_workflow/#debugging :-)

@tmarble
Copy link

tmarble commented Apr 10, 2016

@bbatsov Благодаря!!!

@Malabarba
Copy link
Member Author

@tmarble indeed. The man page should always contain everything. And we try to keep the debugger features easily discoverable.

@Malabarba Malabarba modified the milestones: v0.11, v0.13.0 Apr 15, 2016
@Malabarba
Copy link
Member Author

Ok. Since the fixed has been merged into boot master, I'm closing this issue. We should have a definitive fix when 2.6.0 comes out.

@zalky
Copy link

zalky commented May 15, 2019

Hi all, is anyone still experiencing this issue?

I can load all the cider data readers:

boot.user> (load-data-readers!)
{db/id #'datomic.db/id-literal,
 db/fn #'datomic.function/construct,
 base64 #'datomic.codec/base-64-literal,
 ordered/set #'flatland.ordered.set/into-ordered-set,
 ordered/map #'flatland.ordered.map/ordered-map,
 dbg #'cider.nrepl.middleware.debug/debug-reader,     ; <- appears to be there
 break #'cider.nrepl.middleware.debug/breakpoint-reader,
 light #'cider.nrepl.middleware.enlighten/light-reader}

and I still get an error when the file is compiled:

clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: No reader function for tag dbg

Cider version: 0.18.0
Boot version: 2.8.1

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

9 participants