Problem seeing a locally developed library

I’ve just started a clojurescript app (full background Starting a new ClojureScript project in 2022. Setup suggestions) which is meant to use a local library that I’m working on in parallel.

This library was originally created in Leiningen, but my new app uses CLI tools.

The library was written in Clojure but all the files have been adapted to cljc files. The library is already on Clojars, but I now want to work on a new version in parallel with the project that uses it.

So I’ve added to the old library directory the following deps.edn file :

{:deps
 {org.clojure/clojure {:mvn/version "1.10.0"}
  org.clojure/clojurescript {:mvn/version "1.7.28"}
  orchestra/orchestra {:mvn/version "2021.01.01-1"}
}}

Those are the library’s own dependencies as defined in the project.clj file.

In my new app’s deps.edn I started with

com.myname/mylib {:mvn/version "VERSION"} 

where VERSION was the latest Clojars version number of the library. And this works fine. The library from Clojars downloads and works as part of my new app.

However, I then change it to :

com.myname/mylib
    {:local/root "/media/phil/path/to/mylib"
     :deps/manifest :deps}

Where /media/phil/path/to/mylib is correct.

And when I tried to run my new app now, I see that it’s found the library project and read the deps.edn file, because it downloaded the new version of orchestra (I bumped up the version number)

However it then throws an error:

Downloading: orchestra/orchestra/2021.01.01-1/orchestra-2021.01.01-1.pom from clojars
Downloading: orchestra/orchestra/2021.01.01-1/orchestra-2021.01.01-1.jar from clojars
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build dev to "target/public/cljs-out/dev-main.js"
[Figwheel] Failed to compile build dev in 3.635 seconds.
[Figwheel:WARNING] Compile Exception: No such namespace: mylib.foo, could not locate mylib/foo.cljs, mylib/foo.cljc, or JavaScript source providing "mylib.foo" in file /media/phil/path/to/new/project/src/newapp/bar.cljs  target/public/cljs-out/dev/generated-input-files/gen_test_runner.cljs   
[Figwheel:SEVERE] failed compiling file:target/public/cljs-out/dev/generated-input-files/gen_test_runner.cljs
[Figwheel] Starting Server at http://localhost:9500

So what’s going on?

The app goes on to run, but only because it seems to have a copy of the code derived from the Clojars version of the library hanging around somewhere. It’s not able to compile or use the new code in the local copy of the library.

Have I just missed something else I need? Or is this some other kind of bug?

It will automatically add:

:paths ["src"]

to your deps.edn for you. But if you have code in some other non standard place, you might have to specify one explicitly. Do you have your code in some non-standard place? Like, not in src/mylib?

To which deps.edn? The one in the library or the one in the app?

AFAICT nothing’s been automatically added to deps.edn in the library. There’s no :paths

In the library, code is in src/cljc/libname/*cljc (with some subfolders eg. src/cljc/libname/library/*cljc)

In the app, the code is in src/myname/*cljs

In the app’s deps.edn there is a :paths [“src” “resources”,“target”]

In the source lib. You’ll need a :paths key that defines what folders things can be found in.

1 Like

OK.

So I added “src” which didn’t work. But when I also added “src/cljc” and now it seems to have moved on. Now it’s throwing an error to do with code in the tests directory of the project.

But given that I don’t have “tests” in the deps.edn file, why would the app that uses the library be trying to compile the tests directory of the library?

The problem is something to do with orchestra spec tests.

Is it possible to get the app to ignore these when it’s pulling in the code from the library?

OK.

I removed all references to orchestra from my code-base and it seems to be working.

cheers @John_Newman

1 Like