nextjournal / clerk

⚡️ Moldable Live Programming for Clojure
https://clerk.vision
ISC License
1.82k stars 78 forks source link

"Could not find option with name js.esm-eval-returns-exports." when compiling clerk #296

Closed lvh closed 1 year ago

lvh commented 1 year ago

(I have already resolved this issue as I'm writing it; I'm filing and immediately closing this so that it's hopefully easy to find for the next person, since the error is not super obvious unless you're steeped pretty deep in GraalVM developments. Please let me know if you'd rather I do that some other way.)

clerk on  main [!?] via :coffee: v17.0.4 via  v17.4.0 took 5s 
❯ asdf local java graalvm-22.2.0+java11 

clerk on  main [!?] via :coffee: v11.0.16 via  v17.4.0 
❯ clj                                  
Clojure 1.10.3
user=> (require '[nextjournal.clerk :as clerk])
Execution error (IllegalArgumentException) at com.oracle.truffle.polyglot.PolyglotEngineException/illegalArgument (PolyglotEngineException.java:131).
Could not find option with name js.esm-eval-returns-exports.
user=> clerk on  main [!?] via :coffee: v17.0.4.1 via  v17.4.0 
❯ asdf local java   graalvm-22.2.0+java17

clerk on  main [!?] via :coffee: v17.0.4 via  v17.4.0 
❯ clj                                    
Clojure 1.10.3
user=> (require '[nextjournal.clerk :as clerk])
Execution error (IllegalArgumentException) at com.oracle.truffle.polyglot.PolyglotEngineException/illegalArgument (PolyglotEngineException.java:131).
Could not find option with name js.esm-eval-returns-exports.
user=> 

clerk on  main [!?] via :coffee: v17.0.4 via  v17.4.0 took 5s 
❯ asdf local java graalvm-22.2.0+java11 

clerk on  main [!?] via :coffee: v11.0.16 via  v17.4.0 
❯ clj                                  
Clojure 1.10.3
user=> (require '[nextjournal.clerk :as clerk])
Execution error (IllegalArgumentException) at com.oracle.truffle.polyglot.PolyglotEngineException/illegalArgument (PolyglotEngineException.java:131).
Could not find option with name js.esm-eval-returns-exports.
user=> 

Fix: upgrade to GraalVM 22.3.0, and install the js runtime again via gu. This experimental feature is new in 22.3.0 :)

mk commented 1 year ago

Hi @lvh, thanks for the issue. I've filed https://github.com/oracle/graal/issues/5499 but it looks like the problem will remain. We're considering an alternative markdown parser implementation that works without graaljs.

lvh commented 1 year ago

Awesome, thanks! Do we need Graal to fix this, by the way? Could we catch that exception and feature-detect our way out of this ourselves? That sounds easier than a new markdown impl :)

EDIT: oops: just saw the last part of your ticket. I'm as confused as you are as to why this works on temurin/adoptopenjdk and I'll watch that ticket :)