Fork me on GitHub
#tools-deps
<
2024-02-26
>
Frank Kampe19:02:31

I created a ~/.clojure/deps.edn file and ran a clj command that relies on that file. Did not work. Next, I ran the same clj command, and I gave it the contents of the deps.edn file on the command line. That worked. What is going on? the details:

$ clj -version
Clojure CLI version 1.11.1.1435
$ cat ~/.clojure/deps.edn 
{:aliases
 {:new {:extra-deps {seancorfield/clj-new
                     {:mvn/version "1.1.243"}}
        :exec-fn clj-new/create
        :exec-args {}}}}
$ clj -X:new :template figwheel-main :name learn-cljs/weather :args '["+deps" "--reagent"]'
No function found on command line or in :exec-fn
;; second try
$ clj -Sdeps '{:aliases
 {:new {:extra-deps {seancorfield/clj-new
                     {:mvn/version "1.1.243"}}
        :exec-fn clj-new/create
        :exec-args {}}}}' -X:new :template figwheel-main :name learn-cljs/weather :args '["+deps" "--reagent"]'
;; => works :) but leaves me puzzled

1
dpsutton20:02:54

try clj -Sverbose

❯ clj -Sverbose
version      = 1.11.1.1413
install_dir  = /opt/homebrew/Cellar/clojure/1.11.1.1413
config_dir   = /Users/dan/.clojure
config_paths = /opt/homebrew/Cellar/clojure/1.11.1.1413/deps.edn /Users/dan/.clojure/deps.edn deps.edn
cache_dir    = .cpcache
cp_file      = .cpcache/2964136728.cp

Clojure 1.11.1
user=>
prints out some useful stuff about where it is looking for its config. Yours might be different?

dpsutton20:02:28

or -Sdescribe might be more useful

❯ clj -Sdescribe
{:version "1.11.1.1413"
 :config-files ["/opt/homebrew/Cellar/clojure/1.11.1.1413/deps.edn" "/Users/dan/.clojure/deps.edn" "deps.edn" ]
 :config-user "/Users/dan/.clojure/deps.edn"
 :config-project "deps.edn"
 :install-dir "/opt/homebrew/Cellar/clojure/1.11.1.1413"
 :config-dir "/Users/dan/.clojure"
 :cache-dir ".cpcache"
 :force false
 :repro false
 :main-aliases ""
 :repl-aliases ""}

seancorfield20:02:56

Also, that's an old version of clj-new using the old group ID. See https://github.com/seancorfield/clj-new?tab=readme-ov-file#installation-via-depsedn for updated alias usage. (and you could simply install clj-new as a "tool" so you wouldn't need it in your user deps.edn -- see https://github.com/seancorfield/clj-new?tab=readme-ov-file#installation-as-a-tool )

mattias21:02:08

I have some external jars (locally installed with mvn, e.g. at /Users/m/.m2/repository/org/graalvm/python/python-language/23.1.0/python-language-23.1.0.jar) because these are <type>pom</type> mvn deps. When I run clojure locally, these are found on the classpath (corresponding deps.edn entry org.graalvm.polyglot/python {:local/root "/Users/m/.m2/repository/org/graalvm/python/python-language/23.1.0/python-language-23.1.0.jar"}), but when I build an uberjar with tools.build, these don't get included in the final jar even if their contents is in the class-dir. What's the way to get these local jar deps included in the uberjar? Sorry if it's been answered before. If it's not supported, should I put these on the classpath when starting the uberjar, as a workaround?

seancorfield21:02:35

If they are on the classpath of the basis you use to build the uber jar, I think they should get added. Perhaps you can share more details of how you are building your JAR and what your deps.edn file contains?

seancorfield21:02:08

(although having :local/root pointing into your Maven repo cache is... strange...)

seancorfield21:02:34

It seems like you could specify org.graalvm.python/python-language {:mvn/version "23.1.0"} and that would work?

mattias03:02:11

Thanks.. I think i thought i needed a local mvn cache because <type>pom</type> are not supported, but i already copied the other deps of org.graalvm.python/python-language to deps.edn, so this should work. Having the following deps seems to put things in the uberjar:

org.graalvm.truffle/truffle-api {:mvn/version "23.1.0"}
  ; python
  org.graalvm.python/python-language {:mvn/version "23.1.0"}
  org.graalvm.tools/profiler-tool {:mvn/version "23.1.0"}
  org.graalvm.regex/regex {:mvn/version "23.1.0"}
  org.graalvm.polyglot/polyglot {:mvn/version "23.1.0"}
  org.graalvm.truffle/truffle-nfi {:mvn/version "23.1.0"}
  org.graalvm.truffle/truffle-nfi-libffi {:mvn/version "23.1.0"}
  org.graalvm.llvm/llvm-api {:mvn/version "23.1.0"}
  org.graalvm.shadowed/icu4j {:mvn/version "23.1.0"}
  org.bouncycastle/bcprov-jdk18on {:mvn/version "1.76"}
  org.bouncycastle/bcpkix-jdk18on {:mvn/version "1.76"}
  org.bouncycastle/bcutil-jdk18on {:mvn/version "1.76"}
  org.tukaani/xz {:mvn/version "1.9"}
  ; js
  org.graalvm.js/js-language {:mvn/version "23.1.0"}
But it's still giving me
Exception in thread "main" java.lang.IllegalStateException: No language and polyglot implementation was found on the class-path. Make sure at last one language is added on the class-path. If you put a language on the class-path and you encounter this error then there could be a problem with isolated class loading. Use -Dpolyglotimpl.TraceClassPathIsolation=true to debug class loader islation problems. For best performance it is recommended to use polyglot from the module-path instead of the class-path.
	at org.graalvm.polyglot.Engine$PolyglotInvalid.noPolyglotImplementationFound(Engine.java:2071)
So the issue is probably somewhere else. Perhaps sth about a https://github.com/oracle/graaljs/issues/182? Which is beyond me atm. Thanks Sean, sorry for the silly question 🙂

seancorfield03:02:02

Since you're now at a Graal issue, maybe ask in #CAJN79WNT and see if anyone recognizes this problem?