Welcome! Please see the About page for a little more info on how this works.

+1 vote
in ClojureScript by

There's an old bug that got reports of other people seeing too, that I now hit again, this time with a deps.edn project and in a CI setup. The old bug: https://github.com/emezeske/lein-cljsbuild/issues/490 - note the other people reporting that renaming the source directory or cloning toa differently named directory was a work-around.

Here's a rerun of the code at https://github.com/clojure/clojurescript/blob/r1.10.520/src/main/clojure/cljs/closure.clj#L1851 with the actual values replaced in:

cljs.closure=> *lp
"cljsjs/openlayers/development/"
cljs.closure=> *p
"/codebuild/output/src923210442/src/github.com/solita/mnt-teet/app/frontend/target/public/cljs-out/tests/l/events/eventtype.js"
cljs.closure=> (subs *p (+ (inc (.lastIndexOf *p *lp)) (.length *lp)))
"/src/github.com/solita/mnt-teet/app/frontend/target/public/cljs-out/tests/l/events/eventtype.js"

What eventually throws the exception is the (io/file out-dir out-name) call here:
https://github.com/clojure/clojurescript/blob/r1.10.520/src/main/clojure/cljs/closure.clj#L2023

because it's getting a path as the second argument beginning with "/" in out-name, returned by the rel-output-path call.

The openlayers dependency came from this line in deps.edn:

cljsjs/openlayers {:mvn/version "4.4.1-1"}

1 Answer

0 votes
by

Is there a corresponding JIRA ticket open for this issue? Patch also welcome if you've gotten to the bottom of it.

by
Hello!

Thanks a lot for the response!

No JIRA ticket yet, I got referred here by folks on #clojurescript in Clojurians to triage the issue, and then someone in the know would open the JIRA issue if warranted.

IIRC it wasn't immediately obvious to me what relative part of the subpath the code was trying to get in that subs expression, and what significance the used path would have, so I didn't get as far as a fix.
by
I've started looking at this but the above not really a full repro case. Clearly we're getting unexpected values passed to `lib-rel-path`, we need to understand how that's happening. Can you reproduce this outside of CI? Thanks.
by
Hello again,

Thanks for looking at the bug. I made this repro that works in Docker so should be environment independent:
https://gist.github.com/erno/9abd8e928302503e932a61e5663eeeb5

To use, do

0. paste the above gist to a file called Dockerfile

1. docker build -t cljs-bug-repro .

2. docker run -it cljs-bug-repro

3. bash repro.sh

It might also reproduce on your dev environment outside docker if you recreate the same nested subdirectory for the build dir and do the git checkout and run clojure -A:test like in the Dockerfile.
by
A colleague just ran into this again.  It prompted me to recheck if the above repro still works. It does:

[Figwheel] Failed to compile build tests in 28.338 seconds.
[Figwheel:WARNING] Compile Exception: /src/github.com/solita/mnt-teet/app/frontend/target/public/cljs-out/tests/l/events/eventtype.js is not a relative path  
Execution error (IllegalArgumentException) at cljs.closure/write-javascript (closure.clj:2031).
/src/github.com/solita/mnt-teet/app/frontend/target/public/cljs-out/tests/l/events/eventtype.js is not a relative path

Full report at:
/tmp/clojure-594316621683314904.edn
...