Can't build ClojureScript quickstart with optimizations
Asked Answered
T

1

6

I'm having trouble with the Production Builds section the ClojureScript quickstart. Specifically, when I run: java -cp "cljs.jar;src" clojure.main release.clj I get a java exception:

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/dev2/Experiments/cljscript/hello_world/out/cljs/core.js, compiling:(C:\dev2\Experiments\cljscript\hello_world\release.clj:3:1)

I'm doing this on Windows, and I suspect that the google closure compiler doesn't like the windows-style path, specifically the colon. My release.clj is:

(require 'cljs.build.api)

(cljs.build.api/build "src"
{
    :output-to "out/main.js"
    :optimizations :advanced
})

(System/exit 0)

and I'm invoking it with: java -cp "cljs.jar;src" clojure.main release.clj. If I comment out the :optimizations line then the build succeeds.

My exact setup is here: https://github.com/PaulRobson/cljs-quickstart

Trimmer answered 15/11, 2017 at 6:21 Comment(7)
Hey! It's not impossible that there are issues with ClojureScript on Windows, especially when using optimization modes other than :none or :advanced (which are most commonly used). Is there any chance you could create a minimal reproduction of your problem? Then someone could take a look and maybe identify an issue in your setup or reproduce a bug, should there be one.Discrepant
Also, the code in the example are not windows-style paths. Windows-style would use the backslash, ie out\main.js.Masuria
@MartinKlepsch - I've added a git repo to the question.Trimmer
@Masuria Thanks for that suggestion. I tried it and it didn't help. I think it's actually choking on the : when it builds the full path like /C:/dev2/etcTrimmer
I hit this too. And I found that it is an open issue with Google's Clousure compiler https://github.com/google/closure-compiler/issues/2611Shiver
@MartinKlepsch I just ran into this issue, and it is indeed just using the :advanced optimization option, which I would expect would be the most often or second-most often used. It is pretty insane that this brick wall would be left in place for all Windows users out there.Seventy
@AlvinSim The open issue you linked to seems not quite on point, just related (maybe). How could a person open a new 'issue' (problem report) that really highlights that the thing is just choking on the colon (:) character (and that that means leaving all Windows users high and dry)? And how could a person help? I would give it a try if I could. Maybe it would just mean splitting the paths strings by semicolons and splicing them together, with whatever extra would be needed to make them look Unix paths...and then reverting the paths after whatever part of the code is balking at the colons.Seventy
S
5

This is a known issue https://dev.clojure.org/jira/browse/CLJS-2401

A workaround involves using an output directory with a hyphen, as in

(require 'cljs.build.api)

(cljs.build.api/build "src"
{
    :output-to "out-foo/main.js"
    :optimizations :advanced
})

(System/exit 0)
Sartorius answered 11/4, 2018 at 16:11 Comment(1)
This fixed it for me. I did have to delete my out directory before it worked, though. Thanks!Trimmer

© 2022 - 2024 — McMap. All rights reserved.