figwheel build can't find my core cljs namespace - clojure

I'm trying to use figwheel build for my project. I use the latest versions of libs and my leiningen version is 2.5.1. My build file looks like this:
(defproject figwheel-issue "1.2.3"
:plugins [[lein-cljsbuild "1.0.6"]
[lein-figwheel "0.3.3"]]
:dependencies [[org.clojure/clojurescript "0.0-3269"]
[org.clojure/clojure "1.7.0-beta3"]]
:cljsbuild {
:builds [{ :id "dev"
:source-paths ["src"]
:figwheel true
:compiler {
:main myproject/core
:hashbang false
:asset-path "js/out"
:output-to "resources/public/js/example.js"
:output-dir "resources/public/js/out"
:optimizations :none}}]})
Normal build works ok. So when I run:
lein cljsbuild once
I get:
Successfully compiled "resources/public/js/example.js" in 0.873 seconds.
But when I try to run:
lein figwheel
Figwheel build can't seem to find my core namespace:
Compiling "resources/public/js/example.js" failed.
clojure.lang.ExceptionInfo: failed compiling file:target/figwheel_temp/dev/figwheel/connect.cljs
at clojure.core$ex_info.invoke (core.clj:4591)
Caused by: clojure.lang.ExceptionInfo: No such namespace: core, could not locate core.cljs, core.cljc, or Closure namespace "core" at line 1 target/figwheel_temp/dev/figwheel/connect.cljs
at clojure.core$ex_info.invoke (core.clj:4591)
Any ideas what could be wrong? I created a minimal github project which demonstrates the issue here:
https://github.com/auramo/figwheel-build-issue

Problem was the namespace, it should be:
:main myproject.core

Related

cannot run ring with lein

I am trying my first run with ring and lein, and I am facing problems in getting it to run. I have taken this example from the book "Web development with Clojure", chapter 1, and also from https://quickleft.com/blog/your-first-clojure-web-app/ . The code from both these sites give me the same error - Class Not Found.
I have the following project.clj
(defproject myfirstwebapp "0.1.1"
:description "A hello world for a Ring based web app"
:dependencies [[org.clojure/clojure "1.8.0"]
[ring "1.4.0"]]
:plugins [[lein-ring "0.9.7"]]
:dev-dependencies [[lein-ring "0.9.7"]]
:ring {:handler myfirstwebapp.core/app})
And the following core.clj
(ns myfirstwebapp.core)
(defn app [req]
{:status 200
:headers {"content-Type" "text/html"}
:body "Hello World!"})
And the commands I ran were these:
lein new myfirstwebapp
edit project.clj as above
cd myfirstwebapp
lein deps
edit src/myfirstwebapp/core.clj as above
lein ring server
And now I am getting errors like:
Exception in thread "main" java.lang.ClassNotFoundException: leiningen.core.project$reduce_repo_step, compiling:(C:\Users\ROG\form-init7789757414629005682.clj:1:17608)
Is there some mismatch between the versions of different components that I am using? Or something else?
It is a bug in lein 2.6.0. Fixed in 2.6.1

How to do a release/deploy build of a clojurescript app?

I'm ready to release my clojurescript app. Currently i do lein ring uberjar to create my jar, which does build cljs, but i dont see any documentation on how to do a release build-- do i need to do any concat-ing/minifying/bla bla bla? Are there special release options?
Here is my cljsbuild setup in my project.clj->
{
:builds [{:id "dev"
:source-paths ["src/analyticsjs"]
:figwheel false
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"]
:compiler {:main "analyticsjs.core"
:asset-path "/js"
:output-to "resources/public/js/cljs.js"
:output-dir "resources/public/js"}}
]
}
All help is appreciated. Thanks!
I was directed in the clojurians slack channel to add :optimizations :advanced inside my :compiler map, which worked.

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")

Dependencies in a clojurescript with leiningen

I am seriously pulling my hair right now! I am a total noob at clojure: I can't seem to be able to get a simple clojurescript compilation done without this error:
ERROR: JSC_MISSING_PROVIDE_ERROR. required "clojure.core.async" namespace never provided at /home/jldupont/workspace/$someproject/target/cljsbuild-compiler-0/domain2/main.js line 4 : 0
I've got the following project.clj file:
(defproject $someproject "0.1"
:description "some project..."
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/clojurescript "0.0-2030"]
[org.clojure/core.async "0.1.267.0-0d7780-alpha"]
]
:plugins [[lein-cljsbuild "0.3.2"]]
:cljsbuild {
:builds [{:id "domain2"
:source-paths ["src/cljs/model2/domain"]
:compiler {:output-to "src/assets/js/model2/domain/domain2.js"
:optimizations :advanced
:pretty-print true}
}
]
}
)
Everytime I use lein cljsbuild auto I get the error quoted above.
Please help!
Update
I've looked in my ~/.m2 directory and the dependencies ( in this case core.async ) are present.
Update 2
It would appear that it is the Google Closure Compiler that spews out this error message. Not sure how to provide it a path to the dependencies...
As mentioned in my comment above: if you want to use core.async with ClojureScript you have to require the namespace cljs.core.async (instead of Clojure's clojure.core.async).

How can I deploy a Leiningen template to Clojars?

I have created a Leiningen project on my local machine which I then turn into a template by doing:
lein create-template webdb
: Then I install the template:
cd webdb
lein install
: which allows me to create projects based on the template locally:
lein new webdb anewproject
: Everything works fine up to here. However if I try to deploy the template to clojars using:
cd webdb
lein deploy clojars
: then whenever I try to use the clojars profile to create a template I get an error:
lein new org.clojars.zubairq2/webdb anothernewproject
: gives the error:
Could not find metadata org.clojars.zubairq2/webdb:lein-template/maven-metadata.xml in local (/Users/faroukzquraishi/.m2/repository)
Failure to find org.clojars.zubairq2/webdb:lein-template/maven-metadata.xml in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
Failure to find org.clojars.zubairq2/webdb:lein-template/maven-metadata.xml in http://clojars.org/repo/ was cached in the local repository, resolution will not be reattempted until the update interval of clojars has elapsed or updates are forced
This could be due to a typo in :dependencies or network issues.
Could not find template org.clojars.zubairq2/webdb on the classpath.
: does anyone know what I am doing wrong here?
Update - project.clj
(defproject cljstemplate "org.clojars.zubairq2/webdb"
:dependencies [
[org.clojure/clojure "1.5.1"]
[org.clojure/google-closure-library-third-party "0.0-2029"]
[domina "1.0.1"]
[crate "0.2.4"]
[prismatic/dommy "0.1.1"]
[korma "0.3.0-RC5"]
[org.postgresql/postgresql "9.2-1002-jdbc4"]
[compojure "1.1.5"]
[shoreleave "0.3.0"]
[shoreleave/shoreleave-remote-ring "0.3.0"]
[ring-middleware-format "0.3.0"]
[ring/ring-json "0.2.0"]
[jayq "2.3.0"]
]
:url "http://org.clojars.zubair2/webdb"
:plugins [
[lein-cljsbuild "0.3.0"]
[lein-httpd "1.0.0"]
[lein-ring "0.8.5"]
]
:source-paths ["src"]
:ring {:handler webapp.framework.server.core/app}
:cljsbuild
{
:builds
[
{
:source-paths ["src"]
:compiler {
:output-to "resources/public/main.js"
:optimizations :simple
:externs ["resources/public/jquery.js" "resources/public/google_maps_api_v3_3.js"]
:pretty-print false
}
}
]
}
)
your upload seems to have worked and the result is here:
https://clojars.org/webdb/lein-template
you can make a project like this:
arthur#a:~$ lein new webdb newproject
Retrieving webdb/lein-template/0.1.0-SNAPSHOT/lein-template-0.1.0-20130618.143034-5.pom from clojars
Retrieving webdb/lein-template/0.1.0-SNAPSHOT/lein-template-0.1.0-20130618.143034-5.jar from clojars
To use a lein plugin, you must make it a dependency it in your .lein/profiles.clj
Since you project is on clojars, if you add its dependency it should be available to you.