This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-05
Channels
- # bangalore-clj (1)
- # beginners (99)
- # boot (108)
- # cider (15)
- # clara (4)
- # cljs-dev (12)
- # cljsjs (37)
- # cljsrn (4)
- # clojure (110)
- # clojure-italy (2)
- # clojure-spec (12)
- # clojurescript (168)
- # cursive (1)
- # datomic (24)
- # graphql (6)
- # hoplon (5)
- # jobs-discuss (2)
- # keechma (21)
- # mount (5)
- # off-topic (140)
- # om (2)
- # parinfer (37)
- # planck (6)
- # re-frame (4)
- # reagent (9)
- # rum (2)
- # spacemacs (4)
Re "adding dependency to project," should there be something(s) for norsys in the :require
clause?
also, you can eliminate some uncertainty by just working in a normal repl without emacs until you can verify you can find the classes you expect to
no, you don’t require java classes, they are auto-loaded when referenced if found on the classpath
the path thing?
oh, it’s source, it’s not a jar you are using
try running lein javac
before starting a repl
I forget if starting a repl fixes that automatically…
source-paths is for things that are source code to compile
if it’s a jar, you need to add it to the classpath directly
the recommended thing with jars is to have a maven coordinate, then add to :dependencies
but you can also add a jar to eg. :resource-paths
I guess…
the advantage to using via maven is that anyone who checks out your source code can automatically get your deps
if that dir has a pom.xml near the jar, it should be possible to at least install it to your dep cache locally
with mvn clean install
at the top level probably
you put the jar itself on the path
not just the dir the jar is in
this is a bit of a hack though, :resource-paths is meant to indicate directories for static resources used at runtim (which a jar of classes technically is, but…)
lein doesn’t have a “just put this in classpath” directly, probably because they’d just say “don’t do it that way”
use maven, etc. etc.
edit-server.core> Environ
CompilerException java.lang.RuntimeException: Unable to resolve symbol: Environ in this context, compiling:(*cider-repl edit-server*:1:7209)
edit-server.core> norsys.netica.Environ
norsys.netica.Environ
edit-server.core>
Seems like I could get that much without importing, though. Import just affects compilation, not REPL?
import is a convenience
it works the same way in a file as the repl: it means you don’t need to type out the full name
you can call (import (norsys.netica Environ))
in the repl and it works
same thing the :import clause in ns does
:import is part of the ns syntax
it’s less often that you’d redefine your ns in the repl
(ns edit-server.core
(:require [clojure.data.json :as json]
[clojure.java.shell :only [sh]]
[clojure.pprint :refer :all]
[clojure.mathyes.numeric-tower :as math]
)
(:import [norsys.netica.Environ]
[]
[norsys.netica.Node]
[norsys.neticaEx.aliases.Node])
(:gen-class))
but in general everything that works in the file works in the repl, and visa-versa
it’s odd that you’ve tried to import two things called Node
I’d expect an error for that
that’s what I’d expect, for any clashes, yes
edit-server.core> (norsys.netica.Environ. nil)
UnsatisfiedLinkError no NeticaJ in java.library.path java.lang.ClassLoader.loadLibrary (ClassLoader.java:1867)
so there’s another jar you forgot
this is the thing that maven takes care of
oh, it’s a so - a binary thing you need on the library path
Another? I have :resource-paths ["c:/NeticaJ_Win/NeticaJ_504/bin/NeticaJ.jar"]
(NeticaJ)
right, but that’s not the shared object - your OS can’t load it from inside a jar even if there is an so in there
it’s a native code dep
you need to add -Djava.library.path=
to your :jvm-opts
with the path to the dir that has those
edit-server.core> (norsys.netica.Environ. nil)
UnsatisfiedLinkError C:\NeticaJ_Win\NeticaJ_504\bin\NeticaJ.dll: Can't find dependent libraries java.lang.ClassLoader$NativeLibrary.load (ClassLoader.java:-2)
@noisesmith Thanks for all your help! I'll dig into this more soon. So long for now.
you might need to escape that :
Which editor would you people recommend for Clojure these days? Emacs+CIDER? Cursive? Other?
I'm on Cursive and using Intellij for other languages as well. It's really good at renaming and supporting multiple coding styles. I need to learn a lighter editor though, for my clojure-only days. Check out Atom with proto-repl: https://github.com/jasongilman/proto-repl
I agree with dominicm, but I have to say that the balance of easy of use, and plugins like proto-repl, make Atom a great first choice.
What is the difference between boot-reload
and figwheel
?
does boot-reload provide a cljs repl?
it might be that figwheel is more prepackaged / start up and go compared to how you would do it with boot
Good point, There is a separate boot task for the cljs-repl called boot-cljs-repl
@hmaurer - if emacs seems daunting, I would suggest the braveclojure tutorial covers just the right amount to get started with clojure. https://www.braveclojure.com/basic-emacs/
@tkjone the modern-cljs tutorial does a pretty good job showing how to set up a cljs repl in boot, and actually, it layers in the boot steps incrementally and explains why.
I am going through it right now.
It does a fantastic job providing the overall context, but I am finding that there are some gaps when you want to build out your own project structure
To solve this problem, I am finding http://upgradingdave.com/blog/pages/006_boot_cljs.html#where_is_main.js?? and https://adambard.com/blog/clojurescript-boot-fireplace/ do an excellent job of shoring up those gaps
For me, the issue was understanding how boot is using the .cljs.edn
files
@gonewest818 thank you! that’s great, I’ll read through it
Speaking of, I am having an issue trying to use CIDER’s debugger. I can’t seem to be able to configure it: getting “no reader function for tag break” error
@noisesmith How to escape ":"? Tried "\:", got clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unsupported escape character: \:,
...
to use \ in a string you need \\
since there's two layers of escaping now - the string escape so lein can read it, then the env var's escape so we can differentiate foo:bar from c:\\foo
and now that I say all that I realize I should probably just look up how this is properly done...
oh - you do this by using ; instead of : to separate items in the cp, OK
the classpath
where what I really meant was "definition of paths" because we aren't talking about a classpath here, we are talking about the library path
I think I have only one path item in this defproject clause: :jvm-opts ["-Djava.library.path=c\\:/NeticaJ_Win/NeticaJ_504/bin"]
.
Above gets me UnsatisfiedLinkError no NeticaJ in java.library.path java.lang.ClassLoader.loadLibrary (ClassLoader.java:1867)
(again).
is having the \\ before : actually correct?
c:\NeticaJ_Win\NeticaJ_504\bin>dir
dir
Volume in drive C is OS
Volume Serial Number is 0894-B1E2
Directory of c:\NeticaJ_Win\NeticaJ_504\bin
08/03/2017 03:54 PM <DIR> .
08/03/2017 03:54 PM <DIR> ..
07/26/2017 09:18 AM 2,675,200 Netica.dll
07/26/2017 09:18 AM 105,472 NeticaJ.dll
07/26/2017 09:18 AM 89,017 NeticaJ.jar
07/26/2017 09:18 AM 74,640 NeticaJ.lib
08/03/2017 03:54 PM <DIR> x32_bin
08/03/2017 03:55 PM <DIR> x64_bin
4 File(s) 2,944,329 bytes
4 Dir(s) 51,155,099,648 bytes free
c:\NeticaJ_Win\NeticaJ_504\bin>
I guess I could move Netica under the project, get away from using the absolute path.
However, the following defproject clause seems to be working fine---so perhaps no escaping is really necessary. :resource-paths ["c:/NeticaJ_Win/NeticaJ_504/bin/NeticaJ.jar"]
fair enough - I'm not as informed about windows