tools-deps

2023-05-08T16:50:34.262479Z

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)

Alex Miller (Clojure team) 2023-05-08T17:02:38.063359Z

when compile-clj fails, it should leave the temp directory there for debugging

Alex Miller (Clojure team) 2023-05-08T17:02:56.972079Z

does that file exist? if so, can you read it?

2023-05-08T17:09:30.015249Z

That directory "uber..." does not exist.

2023-05-08T17:09:48.083849Z

oops one sec.

2023-05-08T17:11:02.071899Z

yeah that directory does not exist.

2023-05-08T17:11:26.538539Z

no directories starting with that name exist.

2023-05-08T17:12:03.011699Z

I switched to :use-cp-file :always

2023-05-08T17:12:32.668689Z

Sorry 🌄 ":never"

Alex Miller (Clojure team) 2023-05-08T17:13:07.556569Z

oh sorry, that's the uber building dir, my previous comment was re compile-clj so is not relevant

Alex Miller (Clojure team) 2023-05-08T17:14:29.886899Z

you mentioned modifying the options of compile-clj, but you should be modifying the options of uber to affect behavior

2023-05-08T17:15:36.099009Z

ahhh

2023-05-08T17:21:37.625589Z

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
           ...

2023-05-08T17:34:06.391909Z

I solved the issue by adding ".*LICENSE.*" to :exclude in above.

2023-05-08T17:35:01.708239Z

Thanks @borkdude.

borkdude 2023-05-08T17:35:45.489069Z

This may be caused by Windows \\ instead of / Perhaps tools build can normalize/unixify the paths before comparing or so

borkdude 2023-05-08T17:36:37.868889Z

@pauld So it worked with :use-cp-file :never?

2023-05-08T17:37:01.397279Z

yeah

borkdude 2023-05-08T17:37:27.563989Z

ah ok then

2023-05-08T17:37:37.706639Z

The space in my user name (home dir) was probably an issue.

2023-05-08T17:37:58.479199Z

Not sure why it worked since I was likely over the 8k character limit.

borkdude 2023-05-08T17:38:11.858219Z

spaces in paths should be handled imo

2023-05-08T17:38:39.593459Z

could be a problem with scoop clojure via bash.

borkdude 2023-05-08T17:38:50.297629Z

bash?

2023-05-08T17:39:00.185179Z

windows git bash

borkdude 2023-05-08T17:39:17.229329Z

ok, maybe also try in cmd.exe and pwsh.exe then

2023-05-08T17:39:49.598489Z

ok will try

2023-05-08T17:41:48.074959Z

No, problem exists in powershell too.

borkdude 2023-05-08T17:42:46.370419Z

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

borkdude 2023-05-08T17:43:17.430209Z

Or start a new thread over here about that one

2023-05-08T17:44:37.767459Z

Sure I'll post here again to make it clear.

2023-05-08T16:51:25.498609Z

I tried adding this to options of compile-clj:

:exclude [#"(?i)^META-INF/LICENSE/.*"
                            #"^LICENSE/.*"]

2023-05-08T17:50:45.689029Z

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.

seancorfield 2023-05-08T17:55:14.849189Z

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).

2023-05-08T18:02:13.162819Z

I'm using the clojure installed by scoop on windows.

2023-05-08T17:52:00.347829Z

I'm using the clojure installed by scoop on windows.

borkdude 2023-05-08T17:52:42.000249Z

Let's use a thread for multiple messages about the same problem

vemv 2023-05-08T20:17:25.222869Z

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?

vemv 2023-05-08T20:24:29.949029Z

Maybe the main (that with :gen-class) namespace isn't currently requireing the ns that shows this behavior? Although I'm using :src-dirs so it should compile everything

Alex Miller (Clojure team) 2023-05-08T20:25:01.242969Z

do you have a user.clj?

vemv 2023-05-08T20:25:52.322549Z

no

2023-05-08T20:26:47.635119Z

have you looked in the output jar to see if the namespace you want to be compiled without assertions is present in the output?

👀 1
Alex Miller (Clojure team) 2023-05-08T20:27:07.729499Z

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

👍 1
2023-05-08T20:27:56.289819Z

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

seancorfield 2023-05-08T20:50:48.914449Z

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...

vemv 2023-05-08T20:55:37.201699Z

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

vemv 2023-05-08T20:56:40.945589Z

Back to the topic, the expected .classis there and (print *assert*) during compile-time printed false, as expected Will investigate some other day

2023-05-09T02:08:12.100589Z

And how do you know asserts are being triggered(

2023-05-09T02:09:11.780469Z

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

Alex Miller (Clojure team) 2023-05-09T02:22:40.298189Z

correct, they have their own assertion flags

vemv 2023-05-10T09:23:07.428619Z

> 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)