Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
New linux (centos7), new lighttable, new lein, new project:
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: defproject in this context, compiling:(/home/zzz/nnn/lighttable/project.clj:1:1)
This is the project:
(defproject lighttable "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]])
After some years of trying clojure, with a project that is in prod. (not this one, of course): am I missing something?
Could you try it again from a clean directory? It seems to be working for me:
~/tmp9 > lein new app lighttable
Generating a project called lighttable based on the 'app' template.
~/tmp9 > cd lighttable
~/tmp9/lighttable > lein run
Hello, World!
~/tmp9/lighttable > cat project.clj
(defproject lighttable "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]]
:main ^:skip-aot lighttable.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
I noticed you have two :url entries and are missing some other stuff. Did you create it by using the command lein new app lighttable ?
If you're using IntelliJ + Cursive like I am, then this will occur if your run/debug configuration points to the project.clj file instead of core.clj for a Clojure Application configuration with How to run it set to Run with Leiningen
Related
I was trying to pick up Clojure again, but am stumbling right at the beginning. I downloaded lein, and copied the following project.clj and a hello.clj to be absolutely sure that I have a minimal working example.
project.clj:
(defproject hello "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]]
:uberjar {:aot :all}
:main hello.core
)
hello.clj:
(ns hello.core
(:gen-class)
)
(defn -main
"This should be pretty simple."
[]
(println "Hello, World!"))
When I run './lein uberjar' I get these warnings:
Warning: specified :main without including it in :aot.
Implicit AOT of :main will be removed in Leiningen 3.0.0.
If you only need AOT for your uberjar, consider adding :aot :all into your
:uberjar profile instead.
Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method.
Created .../target/hello-0.1.0-SNAPSHOT.jar
Created .../target/hello-0.1.0-SNAPSHOT-standalone.jar
Trying to run this either with ./lein run or with java -jar ./target/hello-0.1.0-SNAPSHOT-standalone.jar results in exceptions:
Can't find 'hello.core' as .class or .clj for lein run: please check the spelling.
Exception in thread "main" java.io.FileNotFoundException: Could not locate hello/core__init.class or hello/core.clj on classpath., compiling:(/private/var/folders/28/bk6d4xj123b0xvsvk91_1jg80009rn/T/form-init1007755193774766954.clj:1:125)
So what is my problem here?
:uberjar {:aot :all} -> :profiles {:uberjar {:aot :all}}
And move hello.clj into ./src/hello directory and rename it to core.clj
Leiningen downloaded nearly 1GB of jar index information from repo1.maven.org and clojars.org. Why does it need to download that huge amount of information? And is there any way to prevent that?
The directory in question is: ~/.lein/indeces
It contains the following folders:
https___clojars.org_repo_
https___repo1.maven.org_maven2_
The maven.org folder contains 849MB!
Here is my project definition:
(defproject test-project "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:main test-project.core
:dependencies [[org.clojure/clojure "1.6.0"]
[camel-snake-kebab "0.3.1" :exclusions [org.clojure/clojure]]])
Thanks
This content is maintained not by Leiningen itself, but the lein-search plugin. I'd suggest uninstalling it (the plugin, that is) unless you consider its benefits worth the cost in time and storage.
To do so, remove references to lein-search/lein-search or org.clojars.wuschel/lein-search from your ~/.lein/profiles.clj -- or, if this content was created while working in a different project, from the project.clj of that project.
How to add the necessary jar file for the classpath used by the project?
The project.clj is copied below:
1 (defproject hbase01 "0.1.0-SNAPSHOT"
2 :description "FIXME: write description"
3 :url "http://example.com/FIXME"
4 :license {:name "Eclipse Public License"
5 :url "http://www.eclipse.org/legal/epl-v10.html"}
6 :dependencies [[org.clojure/clojure "1.6.0"]
7 [clojure-hbase "0.92.4"]])
At the REPL I tried:
user=> (require '[clojure-hbase.core :as hb])
and it answered back:
CompilerException java.lang.NoClassDefFoundError:
org/apache/hadoop/conf/Configuration, compiling:(clojure_hbase/core.clj:1:1)
I found one jar file /usr/local/hbase/lib/hadoop-common-2.2.0.jar where the class is an inner class... but how to add this path to the project?
I have read and tried the lein-localrepo but it did not get installed in the right location, the jar file get installed into the $username/.m2/repository/hadoop-common folder.
You may have already figured this out, but in case anyone else comes looking for this error. You need to include a jar from the Hadoop project with the Configuration class, as HBase has a dependency on it from what I've found.
I had this error with Clojure 1.6.0 and HBase 94.26.
My project.clj includes:
[org.apache.hbase/hbase "0.94.26"]
[org.apache.hadoop/hadoop-core "1.2.1"]
Just run lein deps and you're off to the races.
First thing to note here is that you have conflicting versions of clojure. You specify 1.6.0 and clojure-hbase still requires 1.5.1. This could probably cause the issue you're seeing.
I'm using Leiningen and local repo, and here's my project.clj. Camelclojure is local jar.
(defproject mashup-dsl "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[enlive "1.1.1"]
[ring/ring-core "1.1.8"]
[ring/ring-jetty-adapter "1.1.8"]
[net.cgrand/moustache "1.0.0"]
[ring/ring-devel "1.1.8"]
[compojure "1.1.5"]
[org.clojure/data.zip "0.1.1"]
[org.apache.camel/camel-core "2.11.0"]
[org.apache.camel/camel-component "1.4.0"]
[org.clojure/data.xml "0.0.7"]
[camelclojure "0.0.1-SNAPSHOT"]
]
:repositories {"local" "C:/Users/pvmd/.m2/repository"}
:plugins [[lein-localrepo "0.5.2"]])
I've added a local jar to Maven's repository, but when I run
lein deps
Here's what I get as an error
C:\Users\pvmd\git\mashup-dsl\mashup-dsl>lein deps
Could not transfer artifact camelclojure:camelclojure:pom:0.0.1-SNAPSHOT from/to
local (C:/Users/pvmd/.m2/repository): No connector available to access reposito
ry local (C:/Users/pvmd/.m2/repository) of type default using the available factories FileRepositoryConnectorFactory, WagonRepositoryConnectorFactory
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
I don't use proxy, so its definately a dependency issue, I just can't find the reason why...
Where do you get camelclojure? I didn't find it in MVNRepositories, neither in Clojars. Maybe the project is renamed to something else?
Any way, you should include the groupId also:
[info.kovanovic/camelclojure "0.0.1-SNAPSHOT"]
But still, I would suggest to check the current status of the project. It looks to me that it is renamed.
I'm working on a library that works with both Clojure and ClojureScript.
Here's the project.clj for the library:
(defproject libtest "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]]
:plugins [[lein-cljsbuild "0.3.0"]]
:cljsbuild
{:crossovers [libtest],
:crossover-jar true
:jar true
:builds
[{:source-paths ["src/libtest"], :crossover-path "src/libtest"}]})
I'm including it as a dependency in another project. To get it to work from the ClojureScript side of my project, I had to add the exact namespace as a crossover under the cljsbuild key of my project.clj:
(defproject some-other-project
...
:dependencies [[org.clojure/clojure "1.5.0"]
[libtest "0.1.0-SNAPSHOT"]]
:cljsbuild {
:builds [{
...
:crossovers [libtest.core]
...
My question is, is this necessary? If it's on the classpath, why must I specifically tell it what namespaces I'm going to use? This can't scale well if I need to use dozens of namespaces, some of which will reference other namespaces and etc.
This is not a perfect solution, but works for me. When a namespace is specified as a crossover, its children are added recursively. So :crossovers [libtest] will add libtest.core too. If you specify a :crossover-path, you can see what files are generated into that directory.