lein-bin clojure plugin making executable jar/zip malloc error bug? - clojure

On Mac OS X 10.9.5 when I run 'lein bin' the binary is generated, but gives the following error when run:
paul$ target/event-hub-cli
-bash(64435,0x7fff7e177310) malloc: *** error for object 0x7fdd7d10f190: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
But when I run the uberjar it works.
paul$ java -jar target/event-hub-cli-0.1.0-SNAPSHOT-standalone.jar
Hello, World!
My project.clj is the following
(defproject event-hub-cli "0.1.0-SNAPSHOT"
:description "An event hub client"
:dependencies [[org.clojure/clojure "1.5.1"]
[edu.byu.eventhub/eventhub-client "1.0.0-SNAPSHOT"]]
:main event-hub-cli.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}}
:plugins [[lein-bin "0.3.4"]]
:bin {:name "event-hub-cli"
:bin-path "~/bin"}
)
Is this a bug or am I simply using the plugin incorrectly?

Try using version 0.3.5 of lein-bin, it should fix your issue:
:plugins [[lein-bin "0.3.5"]]
I tried to build your project on my Mac OS X 10.10.5 (and Java8). lein bin failed with plugin version 0.3.4, but worked with version 0.3.5.

Related

Getting started with datomic and clojure - Could not locate datomic/api__init.class on classpath

I am trying to run datomic's in-memory database with this tutorial https://clojureverse.org/t/a-quick-way-to-start-experimenting-with-datomic/5004 with the free version. I downloaded the .zip file and put it in program files. Then I created a project with leiningen and I did the other steps indicated in the tutorial, but when I want to evaluate the lines with the repl for creating the database and connection it throws:
"Error:
Syntax error compiling at (c:\Users\usuario\Desktop\clojure\datomic-shortcut\src\datomic_shortcut\core.clj:7:3).
No such namespace: d"
... and when I evaluate the entire file, the following:
Evaluating file: core.clj
Syntax error (FileNotFoundException) compiling at (c:\Users\usuario\Desktop\clojure\datomic-shortcut\src\datomic_shortcut\core.clj:1:1).
Could not locate datomic/api__init.class, datomic/api.clj or datomic/api.cljc on classpath.
Evaluation of file core.clj failed: class clojure.lang.Compiler$CompilerException
When checking the .m2 folder there is no datomic's dependency, even after trying 'lein deps'
I think it can be solved with lein pom/jar/install sequence but I dont find where or I dont know how to download the .jar file.
Any help or information is welcome.. thanks!
-------------EDIT--------------------
Im sorry, the .m2 folder contains the ...m2\repository\com\datomic\datomic-free\0.9.5697\datomic-free-0.9.5697.jar file indeed.
No errors with 'lein deps'
My project.clj:
(defproject datomic-shortcut "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.1"]
[com.datomic/datomic-free "0.9.5697"]]
:source-paths ["src"]
:repl-options {:init-ns datomic-shortcut.core})
My core.clj:
(ns datomic-shortcut.core
(:require [datomic.api :as d]))
(def db-uri "datomic:mem://foo")
(comment
(d/create-database db-uri)
(def conn (d/connect db-uri)))
I realized the classpath hasn't the .jar file in it.
C:\Users\usuario\Desktop\clojure\datomic-shortcut>lein classpath
=>
C:\Users\usuario\Desktop\clojure\datomic-shortcut\test;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\src;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\dev-resources;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\resources;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\target\classes;
C:\Users\usuario\.m2\repository\com\datomic\datomic-lucene-core\3.3.0\datomic-lucene-core-3.3.0.jar;
C:\Users\usuario\.m2\repository\com\google\guava\guava\18.0\guava-18.0.jar;
C:\Users\usuario\.m2\repository\com\h2database\h2\1.3.171\h2-1.3.171.jar;
C:\Users\usuario\.m2\repository\org\apache\activemq\artemis-commons\1.4.0\artemis-commons-1.4.0.jar;
C:\Users\usuario\.m2\repository\nrepl\nrepl\0.6.0\nrepl-0.6.0.jar;
C:\Users\usuario\.m2\repository\org\apache\tomcat\tomcat-juli\7.0.27\tomcat-juli-7.0.27.jar;
C:\Users\usuario\.m2\repository\clojure-complete\clojure-complete\0.2.5\clojure-complete-0.2.5.jar;
C:\Users\usuario\.m2\repository\org\slf4j\jul-to-slf4j\1.7.7\jul-to-slf4j-1.7.7.jar;
C:\Users\usuario\.m2\repository\leinjacker\leinjacker\0.4.1\leinjacker-0.4.1.jar;
C:\Users\usuario\.m2\repository\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;
C:\Users\usuario\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.7\jcl-over-slf4j-1.7.7.jar;
C:\Users\usuario\.m2\repository\org\clojure\core.contracts\0.0.1\core.contracts-0.0.1.jar;
C:\Users\usuario\.m2\repository\org\codehaus\janino\commons-compiler\2.6.1\commons-compiler-2.6.1.jar;
C:\Users\usuario\.m2\repository\com\datomic\datomic-free\0.9.5697\datomic-free-0.9.5697.jar;
C:\Users\usuario\.m2\repository\org\clojure\core.unify\0.5.3\core.unify-0.5.3.jar;
C:\Users\usuario\.m2\repository\org\apache\johnzon\johnzon-core\0.9.4\johnzon-core-0.9.4.jar;
C:\Users\usuario\.m2\repository\commons-beanutils\commons-beanutils\1.9.2\commons-beanutils-1.9.2.jar;
C:\Users\usuario\.m2\repository\org\slf4j\log4j-over-slf4j\1.7.7\log4j-over-slf4j-1.7.7.jar;
C:\Users\usuario\.m2\repository\useful\useful\0.8.5-alpha2\useful-0.8.5-alpha2.jar;
C:\Users\usuario\.m2\repository\org\slf4j\slf4j-nop\1.7.7\slf4j-nop-1.7.7.jar;
C:\Users\usuario\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;
C:\Users\usuario\.m2\repository\org\clojure\tools.cli\0.3.5\tools.cli-0.3.5.jar;
C:\Users\usuario\.m2\repository\lein-datomic\lein-datomic\0.2.0\lein-datomic-0.2.0.jar;
C:\Users\usuario\.m2\repository\org\fressian\fressian\0.6.5\fressian-0.6.5.jar;
C:\Users\usuario\.m2\repository\org\apache\geronimo\specs\geronimo-json_1.0_spec\1.0-alpha-1\geronimo-json_1.0_spec-1.0-alpha-1.jar;
C:\Users\usuario\.m2\repository\me\raynes\conch\0.4.0\conch-0.4.0.jar;
C:\Users\usuario\.m2\repository\org\apache\activemq\artemis-core-client\1.4.0\artemis-core-client-1.4.0.jar;
C:\Users\usuario\.m2\repository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;
C:\Users\usuario\.m2\repository\org\clojure\clojure\1.10.1\clojure-1.10.1.jar;
C:\Users\usuario\.m2\repository\io\netty\netty-all\4.0.39.Final\netty-all-4.0.39.Final.jar;
C:\Users\usuario\.m2\repository\org\clojure\core.specs.alpha\0.2.44\core.specs.alpha-0.2.44.jar;
C:\Users\usuario\.m2\repository\org\codehaus\janino\commons-compiler-jdk\2.6.1\commons-compiler-jdk-2.6.1.jar;
C:\Users\usuario\.m2\repository\org\clojure\tools.macro\0.1.1\tools.macro-0.1.1.jar;
C:\Users\usuario\.m2\repository\org\apache\tomcat\tomcat-jdbc\7.0.27\tomcat-jdbc-7.0.27.jar;
C:\Users\usuario\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;
C:\Users\usuario\.m2\repository\org\clojure\spec.alpha\0.2.176\spec.alpha-0.2.176.jar
So then I tried:
C:\Users\usuario\Desktop\clojure\datomic-shortcut>java -cp C:/Users/usuario/.m2/repository/com/datomic/datomic-free/0.9.5697/datomic-free-0.9.5697.jar clojure.main
Error: no se ha encontrado o cargado la clase principal clojure.main

`lein repl` failed with AssertionError

I was trying out on a project generated by lein new. But I couldn't get lein repl working and the output was not very helpful in terms of trouble-shooting. Here's the stack trace:
Exception in thread "main" java.lang.AssertionError: Assert failed: transport-fn, compiling:(/private/var/folders/02/rhhhdqmd3sn969wx0v68v3440b2221/T/form-init8538067533760352114.clj:1:125)
at clojure.lang.Compiler.load(Compiler.java:7526)
at clojure.lang.Compiler.loadFile(Compiler.java:7452)
at clojure.main$load_script.invokeStatic(main.clj:278)
at clojure.main$init_opt.invokeStatic(main.clj:280)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invokeStatic(main.clj:311)
at clojure.main$null_opt.invokeStatic(main.clj:345)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
Caused by: java.lang.AssertionError: Assert failed: transport-fn
at nrepl.core$connect.invokeStatic(core.clj:168)
at nrepl.core$connect.doInvoke(core.clj:168)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at nrepl.ack$send_ack.invokeStatic(ack.clj:45)
at nrepl.ack$send_ack.invoke(ack.clj:41)
at nrepl.server$start_server.invokeStatic(server.clj:146)
at nrepl.server$start_server.doInvoke(server.clj:105)
at clojure.lang.RestFn.invoke(RestFn.java:1096)
at logical.core$eval1421.invokeStatic(form-init8538067533760352114.clj:1)
at logical.core$eval1421.invoke(form-init8538067533760352114.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:7062)
at clojure.lang.Compiler.eval(Compiler.java:7052)
at clojure.lang.Compiler.eval(Compiler.java:7052)
at clojure.lang.Compiler.load(Compiler.java:7514)
... 12 more
Here's the version of leiningen from lein version:
Leiningen 2.8.2 on Java 11.0.1 OpenJDK 64-Bit Server VM
And here's the project.clj:
(defproject logical "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.9.0"]]
:main logical.core
:repl-options {:init-ns logical.core})
There's also nothing in ~/.lein but content generated by leiningen itself. This is run on a MacOS Mojave version 10.14.2.
This is a known issue with the latest 2.8.2 release of leiningen
Easiest solution is probably to downgrade to 2.8.1 until the next release.

Prevent 'lein repl' in SublimeREPL from echoing the previous command

I'm running Sublime Text 3 Build 3117 on both OS X 10.10.5 and Ubuntu 16.04. I just installed Leiningen 2.6.1 on both, and I'm starting to play around in SublimeREPL. I'm following the lein tutorial. Here is my project.clj, in case it matters:
(defproject my-stuff "0.1.0"
:description "Leiningen Tutorial Project"
:url "http://example.com/FIXME"
:license {:name "MIT"
:url "http://opensource.org/licenses/MIT"}
:dependencies [[org.clojure/clojure "1.8.0"]]
:main ^:skip-aot my-stuff.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}}
:repl-options {
;; custom prompt
prompt (fn [ns] (str "> " ))
}
)
Now, when I run lein repl in the my-stuff directory from the command line and run an arbitrary command (I've been using (+ 1 2 3)), it prints out the answer nicely:
However, if I run lein repl from SublimeREPL with project.clj focused, and run the same command, it echoes the command before printing the return value:
I've also created a lein trampoline run -m clojure.main command for SublimeREPL, and it doesn't have the echoing problem:
Basically, what I would like to do is be able to run a REPL using project.clj, but not have every command echoed before the output is printed. I can't seem to figure out how to run a trampoline REPL in Sublime using project.clj, if that's the best option. If there's a different way, i.e., using lein repl, I just want to get rid of the command echo, and make it look similar to what appears when I run it from the command line.
Thanks to some help at the Sublime Text Forum, I got an answer: you simply need to put "suppress_echo": true in the Main.sublime-menu file where the Clojure menu options are defined. In this case, open Packages/SublimeREPL/config/Clojure/Main.sublime-menu, put a comma , after "extend_env": {"INSIDE_EMACS": "1"}, then on the next line put "suppress_echo": true and you're all set.

Leiningen Bug In Producing Uberjars Or Misunderstanding?

What can cause lein uberjar to fail with "Caused by: java.lang.ClassNotFoundException" errors when lein run runs my app successfully? I'm using leiningen 2.5.1.
It looks like leiningen provides profiles as a way to make custom environments for certain tasks. However, I don't believe a profile difference between what is happening with lein run and lein uberjar is responsible because ...
1) I tried producing the uberjar with every possible profile, via lein with-profile <profile> for every <profile> named in the output of lein show-profiles.
2) I ran lein with-profile uberjar run, and no errors arose.
In case the answer to this problem and similar problems might be specific to the classes and dependencies involved, it is classes related to Overtone that produce the ClassNoteFoundException errors.
My project.clj file looks like:
(defproject cochlea "0.1.0-SNAPSHOT"
:description "An interactive ear training GUI application"
:url "http://github.com/seewalker/cochlea"
:license {:name "GPL v3"
:url "http://www.gnu.org/copyleft/gpl.html"}
:repositories {"conjars" "http://conjars.org/repo"}
:dependencies [[org.clojure/clojure "1.5.1"]
[overtone "0.9.1"]
[org.clojure/tools.trace "0.7.5"]
[org.clojure/java.jdbc "0.3.7"]
[postgresql "9.1-901.jdbc4"]
[environ "0.5.0"]
[incanter "1.9.0"]
[clj-time "0.9.0"]
[me.raynes/conch "0.8.0"]
[seesaw "1.4.2" :exclusions [org.clojure/clojure]]]
:profiles { :uberjar {:aot :all} }
:repl-options { :timeout 120000}
:main cochlea.core
:target-path "target/%s")

Leiningen Crash with Autodoc (sh does not exist)

I am trying to use Clojure autodoc in my project. My project.clj looks like this:
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]]
:plugins [[lein-autodoc "0.9.0"]])
When I do lein autodoc I get this error
clojure.lang.Compiler$CompilerException: java.lang.IllegalAccessError: sh does not exist, compiling:(leiningen/autodoc.clj:1:1)
I do have the binary sh
$ which sh
/bin/sh
How do I fix this?
lein-autodoc does not work with leiningen 2.X. The error message you see comes from this line:
[leiningen.compile :only [sh]] ; in 2.0 this moves to leiningen.eval
Obviously this has nothing to do with /bin/sh.
You may want to check out Codox.