This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-08
Channels
- # announcements (1)
- # babashka (28)
- # beginners (13)
- # calva (10)
- # clerk (18)
- # clj-on-windows (39)
- # clj-otel (1)
- # cljdoc (17)
- # clojars (12)
- # clojure (40)
- # clojure-austin (11)
- # clojure-brasil (1)
- # clojure-europe (23)
- # clojure-nl (3)
- # clojure-norway (16)
- # clojure-uk (2)
- # clojurescript (28)
- # clr (4)
- # conjure (1)
- # emacs (14)
- # hoplon (6)
- # hyperfiddle (59)
- # interop (2)
- # leiningen (1)
- # off-topic (37)
- # pathom (1)
- # polylith (5)
- # portal (7)
- # reagent (9)
- # releases (3)
- # shadow-cljs (22)
- # spacemacs (6)
- # tools-build (12)
- # tools-deps (51)
- # web-security (6)
- # xtdb (7)
I'm trying to get an uberjar via windows clojure. I am getting this issue:
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
C:\Users\Paul Dumais\AppData\Local\Temp\uber10211030562887780850\LICENSE (Access is denied)
when compile-clj fails, it should leave the temp directory there for debugging
does that file exist? if so, can you read it?
oh sorry, that's the uber building dir, my previous comment was re compile-clj so is not relevant
you mentioned modifying the options of compile-clj, but you should be modifying the options of uber to affect behavior
ok tried that with same result:
(defn uber [_]
(b/copy-dir {:src-dirs ["src"]
:target-dir class-dir})
(b/compile-clj {:basis basis
:use-cp-file :never
:src-dirs ["src"]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:exclude [#"(?i)^META-INF/LICENSE/.*"
#"^LICENSE/.*"]
:basis basis
...
Thanks @U04V15CAJ.
This may be caused by Windows \\
instead of /
Perhaps tools build can normalize/unixify the paths before comparing or so
@U0FH1UL84 So it worked with :use-cp-file :never
?
Can you re-define what "the problem" is since that information is in #clj-on-windows in a thread over there, which was a different problem than the original post of this one
I tried adding this to options of compile-clj:
:exclude [#"(?i)^META-INF/LICENSE/.*"
#"^LICENSE/.*"]
Hi folks, I just wanted to repost this issue and solution here just in case it is helpful to others. I was having an issue with compile-clj failing:
λ clj -T:build uber
Error: Could not find or load main class Dumais\AppData\Local\Temp\compile-clj5675381223217921312\compile-clj;target.classes;src;C:\Users\Paul
Caused by: java.lang.ClassNotFoundException: Dumais\AppData\Local\Temp\compile-clj5675381223217921312\compile-clj;target/classes;src;C:\Users\Paul
Execution error (ExceptionInfo) at clojure.tools.build.tasks.compile-clj/compile-clj (compile_clj.clj:114).
Clojure compilation failed, working dir preserved: C:\Users\Paul Dumais\AppData\Local\Temp\compile-clj5675381223217921312
Full report at:
C:\Users\Paul Dumais\AppData\Local\Temp\clojure-12040712073046716600.edn
It looked like it was not dealing with the space correctly in my user name (home directory). Changing the :mvn/local-repo to outside that directory with a short non-space name did not help. I solved the issue by adding :use-cp-file :never to the build-clj options map.I suspect there are quite a few tools out there that will fail on directory paths that contain spaces. I've seen a lot of people recommend to have user names without spaces on Windows because of that (`Program Files` can also be problematic if folks install non-native-Windows tooling there).
my tools.build uberjarring script looks approximately like this:
(b/compile-clj {:bindings {#'clojure.core/*assert* false}})
...yet I still see assertions enabled in production. What are some possible reasons?
Maybe the main (that with :gen-class
) namespace isn't currently require
ing the ns that shows this behavior?
Although I'm using :src-dirs
so it should compile everything
do you have a user.clj?
have you looked in the output jar to see if the namespace you want to be compiled without assertions is present in the output?
off-hand, don't know. you can fork tools.build, add any print debugging you need, and point to the fork via either :local/root or to a commit sha in your fork, if that helps
the aot classes for the namespace are not present in the output, then when you load the code later it will be compiled then with whatever flags that are set then
I'm always surprised when I see folks turning assert off in production... Don't you want your app to "fail fast" rather than potentially continue on with bad data and cause havoc? I've always preferred to keep assert ON in production for that reason...
I've shared this link a few times over the years :) https://en.wikipedia.org/wiki/Design_by_contract#Performance_implications The liberating thing about disabling it is that you can go as creative and heavy-handed as desired with assertions, without worrying about performance. It also helps drawing a clear line between assertionerror and ex-info (things that aren't dev sanity checks should be the latter). Particularly when assertionerror does not inherit from Exception
Back to the topic, the expected .class
is there and (print *assert*)
during compile-time printed false, as expected
Will investigate some other day
Gotta go put kids to bed, but wild guess you are seeing spec asserts fail, and if I recall spec asserts don't respect assert
correct, they have their own assertion flags
> And how do you know asserts are being triggered
a vanilla assert
was.
for completeness, I ended up using the same solution I've used in past production deployments. It should be redundant given the build.clj, but this double setup leaves me more assured.
(ns my.app.launcher
"Please don't add any requires here."
(:gen-class))
(defn -main [& args]
(binding [*assert* false] ;; Bind *assert* before performing any requires
(let [f @(requiring-resolve ')]
(apply f args))))
(sadly I don't feel with the bandwidth for a full-blown investigation)