Question: hello, does anyone know how to use cljs preloads in boot? I'm trying to add re-frisk in my dev task.

Asked By
Asked At
2017-11-06 11:15:46

Found 15 possible answers.

User Answered At Possible Answer
dominicm 2017-11-06 13:22:37 @poernahi example in saapas
dave 2017-11-06 14:54:33 I read your convo below with @seancorfield and I think there's an important point worth considering -- boot is more flexible than leiningen with its notion of dependencies. i think the closest you could get to that would be to run a particular boot task and, while the task is running, inspect the dependencies in the env programmatically. that may or may not be insanit, though boot, on the other hand, gives you set-env! and merge-env! , which allow you to mutate the dependencies you're working with ad hoc as you need them. it's common to see individual boot tasks with their own ad hoc dependencies, source paths, resource paths, etc. so in that sense, i don't think it actually makes sense to "extract the dependencies" from a boot project a leiningen project has a canonical list of dependencies, i.e. it makes sense to refer to "the project's dependencies" as a single entity
poernahi 2017-11-06 16:11:18 @dominicm thanks!
gonewest818 2017-11-06 19:29:10 Yes, I considered that, but I’m really reluctant to run arbitrary user code in my service. If I were doing this for commercial gain, I would look for a suitable way to sandbox the execution and prevent malicious behavior. As this is just a side project, I’m not sure I can justify the effort.
seancorfield 2017-11-06 19:31:55 I think you'll get a good percentage of Boot projects, just with the basic act of looking for set-env! and merge-env! and :dependencies . There will just be some that you trip up on.
gonewest818 2017-11-06 19:35:00 Thanks Sean, exactly my thought. If I had a product manager I would have her/him go assess what that percentage is :slightly_smiling_face: (Right now, however, I’m fidding with joplin and dynamodb.)
kanwei 2017-11-07 06:37:05 So I built tensorflow JNI and now have a directory with the tensorflow JAR file and dylib files. I can't for the life of me figure out how to add this directory as part of the classpath with boot. I can't build a POM (long story, but pretty much impossible). Anyone know how to add a one-off jar to the -cp with boot?
java -cp libtensorflow.jar:clojure-1.8.0.jar clojure.main
works, but have no idea how to translate that into a boot config
alandipert 2017-11-07 15:32:13 kanwei boot.pod/add-classpath should do it ( ), you can do that in your build.boot note that if you're producing a jar or something from your build, the jar won't be in there unless you mvn install it and then make it a proper dependency
kanwei 2017-11-07 17:23:05 @alandipert
(set-env! :resource-paths #{"/Users/kanwei/Src/tensorflow-java/libtensorflow.jar"})
    line: 5
clojure.lang.ExceptionInfo: Context classloader is not a DynamicClassLoader changing it to file:///Users gives
java.lang.IllegalAccessError: Context classloader is not a DynamicClassLoader
    line: 6
clojure.lang.ExceptionInfo: no protocol: /Users/kanwei/src/tensorflow-java/libtensorflow.jar no protocol: /Users/kanwei/src/tensorflow-java/libtensorflow.jar
(add-classpath "/Users/kanwei/src/tensorflow-java/libtensorflow.jar")
alandipert 2017-11-07 17:25:46 kanwei no need for the set-env! piece, just: (require '[boot.pod :as pod]) (pod/add-classpath "/Users/kanwei/Src/tensorflow-java/libtensorflow.jar")
kanwei 2017-11-07 17:26:54 nice, that worked they seem to have totally different behavior despite the same name any reason why there's add-classpath and pod/add-classpath?
alandipert 2017-11-07 17:33:09 one is in clojure.core, one is in boot.pod the boot one isn't deprecated and does boot stuff
kanwei 2017-11-07 17:34:43 ah, had no idea clojure had that as core. Thanks for the help! how do I setProperty on the new pod? @alandipert another issue: I need to add
(System/setProperty "java.library.path" "/Users/kanwei/src/tensorflow-java")
as a parameter for the dylibs to load, but it doesn't work in the boot version, whereas the
method works on the CLI
mateusz.fiolka 2017-11-07 17:50:40 Hi, is there a way to spawn a repl in cider for a single file boot script to execute it without a context of a project? Ah, ok, I can just do boot repl and jack-in :picard-facepalm: Can't find the info in the wiki
alandipert 2017-11-07 17:59:47 kanwei you can set BOOT_JVM_OPTIONS, eg BOOT_JVM_OPTIONS="-Djava.library.path=/Users/kanwei/src/tensorflow-java boot ... setting it from clj is trickier, and i'm not sure works in java 9. but might still:

Related Questions