This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-13
Channels
- # announcements (18)
- # babashka (52)
- # beginners (47)
- # calva (45)
- # clj-kondo (31)
- # clojure (18)
- # clojure-brasil (2)
- # clojure-europe (3)
- # clojure-sweden (25)
- # clojurescript (19)
- # cursive (15)
- # datalevin (11)
- # defnpodcast (2)
- # duct (1)
- # editors (1)
- # emacs (6)
- # gratitude (1)
- # introduce-yourself (6)
- # jobs-discuss (11)
- # leiningen (3)
- # lsp (10)
- # luminus (2)
- # off-topic (4)
- # podcasts-discuss (2)
- # reitit (2)
- # shadow-cljs (10)
- # sql (9)
- # xtdb (4)
Hello everyone, I am a beginner in Clojurescript and I am reading this book "Dmitri Sotnikov, Scot Brown - Web Development with Clojure_ Build Large, Maintainable Web Applications Interactively-Pragmatic Bookshelf". So I am making the Clojurescript project mentioned in it for practice but I am facing an error.
Caused by: java.io.FileNotFoundException: Could not locate guestbook/validation__init.class, guestbook/validation.clj or guestbook/validation.cljc on classpath.
I will explain the details in the reply section.The image of the source tree is attached. I also mentioned the source paths in the project.clj.
:cljsbuild
{:builds
{:app {:source-paths ["src/cljs" "src/cljc"]
:compiler {:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/out"
:main "guestbook.core"
:asset-path "/js/out"
:optimizations :none
:source-map true
:pretty-print true}}}}
Are you sure that when building CLJS, you're using a command that ends up using the :app
build specified in project.clj
and not something else?
I am using lein cljsbuild auto
No clue to be honest. I'd try to read the documentation of lein-cljsbuild
and see if it has some kind of verbose mode or anything like it that would output the full classpath to double check that it's correct.
I myself have moved away from anything lein
-related a few years ago, so unfortunately can't really help beyond that suggestion.
ohh, no problem. the error doesn't occur at the compile time. It occurs when I run the application using lein run.
Uhm... that's a completely different problem then.
When you run something using lein
, that's probably a CLJ project being run, not a CLJS one. Despite them being in the same directory tree, those two are different concepts, they work differently. Assuming we're talking about a regular web application, a CLJS app is first built from the sources, which ends up in a single JS file (multiple files in case of a development build). That JS file, assuming everything is setup up correctly, is run by your browser after the loaded HTML page has requested that JS file.
So by running something with lein
, you don't run your CLJS code but rather a CLJ one. If it needs to access that guestbook.validation
namespace, then that file must also be on the CLJ classpath as the CLJS classpath is completely separate.
What does your :source-paths
look like outside of the :cljsbuild
map?
ohh alright, this is another source path
:source-paths ["src/clj"]
so i have to include the other source paths here as well?
But the CLJS compiler of course must know about CLJS, CLJC, and CLJ files that it uses - usually for macros.
ok alright, thank you
it is working, thank you Eugene. your answers provide good insight and motivate me to learn more.
If I have the org.clojure/clojurescript
jar on classpath of a Clojure process, is there a more reliable way to get its version than to parse the (def *clojurescript-version* "1.10.914")
form in cljs/core.cljs
?
Update: ah, we have cljs/util.cljc
with the version as well, nice!
The jar itself is problematic - not a flexible solution given how e.g. CLJS quickstart talks about downloading cljs.jar
.
Nah, it's still right here: https://clojurescript.org/guides/quick-start Granted, it's for Windows only, even though I still have no clue why that would be a recommendation. In any case, classpaths are not set in stone and jars can easily omit versions. Given that there are at least two other solutions, I definitely prefer them. :)