thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.27k stars 180 forks source link

starting shadow-cljs fails on M1 Mac #1049

Closed juxt-jp closed 2 years ago

juxt-jp commented 2 years ago

I have faced the following error and currently I am not able to find a way fixing the problem.

% npx shadow-cljs browser-repl
shadow-cljs - config: /Users/makoto/clojure/learn-reagent-course-files/my-store/shadow-cljs.edn  cli version: 2.3.30  node: v16.14.0
shadow-cljs - starting ...
shadow-cljs - Using IP "192.168.11.4" from Interface "en0"
Exception in thread "main" java.lang.UnsatisfiedLinkError: /private/var/folders/q9/hjtxkzvd5yd3ql4lqbq_14cw0000gn/T/jna13873871448409781026.tmp: dlopen(/private/var/folders/q9/hjtxkzvd5yd3ql4lqbq_14cw0000gn/T/jna13873871448409781026.tmp, 0x0001): tried: '/private/var/folders/q9/hjtxkzvd5yd3ql4lqbq_14cw0000gn/T/jna13873871448409781026.tmp' (fat file, but missing compatible architecture (have (unknown,i386,x86_64), need (arm64e)))
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:384)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:228)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:170)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
    at java.base/java.lang.Runtime.load0(Runtime.java:755)
    at java.base/java.lang.System.load(System.java:1953)
    at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:744)
    at com.sun.jna.Native.loadNativeLibrary(Native.java:678)
    at com.sun.jna.Native.<clinit>(Native.java:106)
    at com.barbarysoftware.jna.CarbonAPI.<clinit>(CarbonAPI.java:6)
    at com.barbarysoftware.jna.CFStringRef.toCFString(CFStringRef.java:10)
    at com.barbarysoftware.watchservice.MacOSXListeningWatchService.register(MacOSXListeningWatchService.java:30)
    at com.barbarysoftware.watchservice.WatchableFile.register(WatchableFile.java:30)
    at com.barbarysoftware.watchservice.WatchableFile.register(WatchableFile.java:39)
    at hawk.watcher$fn__133.invokeStatic(watcher.clj:102)
    at hawk.watcher$fn__133.invoke(watcher.clj:99)
    at hawk.watcher$fn__38$G__29__47.invoke(watcher.clj:24)
    at hawk.core$watch_BANG_.invokeStatic(core.clj:83)
    at hawk.core$watch_BANG_.doInvoke(core.clj:59)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at shadow.cljs.devtools.server.fs_watch_hawk$start_STAR_.invokeStatic(fs_watch_hawk.clj:41)
    at shadow.cljs.devtools.server.fs_watch_hawk$start_STAR_.invoke(fs_watch_hawk.clj:29)
    at shadow.cljs.devtools.server.fs_watch_hawk$start.invokeStatic(fs_watch_hawk.clj:102)
    at shadow.cljs.devtools.server.fs_watch_hawk$start.invoke(fs_watch_hawk.clj:100)
    at clojure.lang.Var.invoke(Var.java:396)
    at shadow.cljs.devtools.server.fs_watch$start.invokeStatic(fs_watch.clj:26)
    at shadow.cljs.devtools.server.fs_watch$start.invoke(fs_watch.clj:11)
    at shadow.cljs.devtools.server$start_BANG_$fn__23034.invoke(server.clj:345)
    at clojure.lang.AFn.applyToHelper(AFn.java:160)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:657)
    at clojure.core$apply.invoke(core.clj:652)
    at shadow.runtime.services$start_one.invokeStatic(services.clj:98)
    at shadow.runtime.services$start_one.invoke(services.clj:87)
    at shadow.runtime.services$start_many$fn__9779.invoke(services.clj:127)
    at shadow.runtime.services$start_many.invokeStatic(services.clj:126)
    at shadow.runtime.services$start_many.invoke(services.clj:105)
    at shadow.runtime.services$start_all.invokeStatic(services.clj:144)
    at shadow.runtime.services$start_all.invoke(services.clj:139)
    at shadow.cljs.devtools.server$start_system.invokeStatic(server.clj:278)
    at shadow.cljs.devtools.server$start_system.invoke(server.clj:189)
    at shadow.cljs.devtools.server$start_BANG_.invokeStatic(server.clj:389)
    at shadow.cljs.devtools.server$start_BANG_.invoke(server.clj:323)
    at shadow.cljs.devtools.server$start_BANG_.invokeStatic(server.clj:326)
    at shadow.cljs.devtools.server$start_BANG_.invoke(server.clj:323)
    at shadow.cljs.devtools.server$from_cli.invokeStatic(server.clj:512)
    at shadow.cljs.devtools.server$from_cli.invoke(server.clj:488)
    at shadow.cljs.devtools.cli$blocking_action.invokeStatic(cli.clj:143)
    at shadow.cljs.devtools.cli$blocking_action.invoke(cli.clj:130)
    at shadow.cljs.devtools.cli$main.invokeStatic(cli.clj:191)
    at shadow.cljs.devtools.cli$main.doInvoke(cli.clj:146)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:661)
    at clojure.core$apply.invoke(core.clj:652)
    at shadow.cljs.devtools.cli$_main.invokeStatic(cli.clj:233)
    at shadow.cljs.devtools.cli$_main.doInvoke(cli.clj:231)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:702)
    at clojure.core$apply.invokeStatic(core.clj:657)
    at clojure.main$main_opt.invokeStatic(main.clj:317)
    at clojure.main$main_opt.invoke(main.clj:313)
    at clojure.main$main.invokeStatic(main.clj:424)
    at clojure.main$main.doInvoke(main.clj:387)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:702)
    at clojure.main.main(main.java:37)

Does anybody give me suggestions to avoid this error ?

Thanks

thheller commented 2 years ago

Upgrade. You have an absolute ancient version it seems cli version: 2.3.30. hawk was removed a very long time ago.

jacekschae commented 2 years ago

I just bumped shadow-cljs and react deps in the project. There is also information in the episode notes to always use latests version of shadow-cljs. Additionally if you are using M1 Pro or Ultra you will also need a newer version of Java.

nsaritzky commented 2 years ago

I'm seeing the same error on my M1 machine. shadow-cljs --cli-info shows that I'm on version 2.10.22 of the cli and have openjdk 11. Here's the edn output.

jacekschae commented 2 years ago

Are you using hawk for anything? Could you paste your shadow-cljs.edn?

nsaritzky commented 2 years ago

Here you go, but this is happening on an untouched create-cljs-app project.

{:builds
 {:app {:asset-path "/js"
        :modules {:main {:init-fn app.core/main}}
        :output-dir "public/js"
        :target :browser}
  :cards {:asset-path "/js"
          :modules {:main {:init-fn app.cards/main}}
          :compiler-options {:devcards true}
          :output-dir "public/js"
          :target :browser}
  :test {:ns-regexp "app.cards"
         :output-to "out/test.js"
         :target :node-test}
  :e2e {:ns-regexp "e2e.*"
        :output-to "out/e2e.js"
        :target :node-test}}
 :dependencies [[reagent "0.8.1"]
                [devcards "0.2.6"]]
 :dev-http {3000 "public"}
 :nrepl {:port 3333}
 :source-paths ["src"]}
jacekschae commented 2 years ago

I wasn't aware of create-cljs-app project. The official way is to use

npx create-cljs-project acme-app

Maybe it would be worth to create an issue on the cretae-cljs-app repo. I see that this project is using shadow-cljs in version 2.11.4.

thheller commented 2 years ago

create-cljs-app is unfortunately even more outdated. Seems dead.

juxt-jp commented 2 years ago

It worked with the new version.

% ncu -u
Upgrading /Users/makoto/clojure/learn-reagent-course-files/my-store/package.json
[====================] 4/4 100%

 react        ^16.14.0  →  ^18.2.0
 react-dom    ^16.14.0  →  ^18.2.0
 shadow-cljs    2.3.30  →   2.20.2

Run npm install to install new versions.

% npm update

added 3 packages, removed 107 packages, changed 7 packages, and audited 100 packages in 1s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

 % npx shadow-cljs browser-repl
shadow-cljs - config: /Users/makoto/clojure/learn-reagent-course-files/my-store/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - HTTP server available at http://localhost:3000
shadow-cljs - server version: 2.20.2 running at http://localhost:9630
shadow-cljs - nREPL server started on port 3333
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (150 files, 149 compiled, 0 warnings, 8.13s)
cljs.user=> 

It works fine with the latest version of shadow-cljs(2.20.2).