Comments (9)
From @micha's response on Question about data readers with datomic and boot:
The data_readers.clj files that are used to set up the tag readers are only parsed by Clojure during its own bootstrap process. This means that only those data_readers.clj files that are on the classpath when the JVM starts will be parsed. Boot, however, allows you to add things to the classpath dynamically. We're going to add this code to boot in the next release, but the workaround for now is to call a private function from clojure.core that will re-scan the classpath and install any new reader files:
(#'clojure.core/load-data-readers)
Be sure to call this function after any calls to set-env! that pull new dependencies or directories into the classpath.
I'd propose one of two solutions:
- Document this in boot's already great docs.
- Modify
set-env!
to reload data readers when it is done adding dependencies.
from boot.
That said, adding (#'clojure.core/load-data-readers)
after set-env!
in my build.boot
does not seem to change the value of *data-readers*
from boot.
Repro case of load-data-readers
not persisting:
code/tmp ▸ boot -d com.datomic/datomic-free repl
nREPL server listening: 0.0.0.0:59826
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_20-b26
Exit: Control+D or (exit) or (quit)
Commands: (user/help)
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Find by Name: (find-name "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org: [clojuredocs or cdoc]
(user/clojuredocs name-here)
(user/clojuredocs "ns-here" "name-here")
boot.user=> *data-readers*
{}
boot.user=> (#'clojure.core/load-data-readers)
{base64 #'datomic.codec/base-64-literal, db/fn #'datomic.function/construct, db/id #'datomic.db/id-literal}
boot.user=> *data-readers*
{}
boot.user=> (alter-var-root #'clojure.core/*data-readers* (constantly {:foo :bar}))
{:foo :bar}
boot.user=> *data-readers*
{}
EDIT: It seems as if alter-var-root
does not take effect on *data-readers*
for some reason...
from boot.
Derp again, it seems like further down in the aforementioned thread the updated suggestion is to run:
(#'clojure.core/load-data-readers)
(set! *data-readers* (.getRawRoot #'*data-readers*))
Seems convoluted enough to wrap up nicely for end users. (Anyways, I've hope you've enjoyed watching me go through the learning process...)
from boot.
Tripped upon this very same thing and got to the same solution. Also via the Hoplon forum.
I tried using the REPLs init
option to run a file when the real starts but couldn't get it to work.
Probably that's not the right place place to fix this anyway.
from boot.
Closing, but interested parties may consider moving what they found useful from Discourse and this thread to the wiki.
from boot.
Tripped on this, too. The workaround works, but brings complexity to the table, since running the code snippet makes sense in development under boot, but not in production where it's deployed as an artefact.
from boot.
This is fixed in system
as of 0.2.1-SNAPSHOT
.
https://github.com/danielsz/system
For non-system users, you can try injecting the following task in your build pipeline.
(deftask data-readers []
(fn [next-task]
(fn [fileset]
(#'clojure.core/load-data-readers)
(with-bindings {#'*data-readers* (.getRawRoot #'*data-readers*)}
(next-task fileset)))))
from boot.
An update on anyone hitting this still, you can call: (boot.core/load-data-readers!)
in your build.boot
to force this to be loaded. You can see more discussion at https://hoplon.discoursehosting.net/t/question-about-data-readers-with-datomic-and-boot/99/9.
from boot.
Related Issues (20)
- Cut a new release HOT 1
- Respect nREPL's config file
- Cannot compile Boot on Java 10/11/12 HOT 1
- Lein to Boot HOT 1
- Pushing an artifact on 2.8.3 fails with java.lang.NoSuchMethodError: org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.getBufferCapacityForTransfer(J)I HOT 10
- List only project tasks instead of whole tasks and help message HOT 1
- Fails completely on MacOS 10.14.1 HOT 2
- Boot-generated uberjar zip file has corrupted content on Java 13 HOT 1
- Ubuntu 19.10 - 'an illegal reflective access operation has occurred' HOT 2
- Could not locate class HOT 2
- IPv6 support missing in boot
- NullPointerException when trying to run shebang boot script on macOS HOT 5
- Fails to start on NetBSD 9.0RC1
- Unable to install v2.8.2 on MacOS HOT 3
- Prefix string too short HOT 2
- Possibly out of date documentation about nrefactor repl
- java.lang.NullPointerException on boot repl -c HOT 1
- Boot doesn't work on macOS Big Sur HOT 20
- Boot executable refers to invalid web site boot-clj.com HOT 1
- Creating a binary executable from a Clojure script
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boot.