nasser / nostrand

Clojure on Mono
67 stars 11 forks source link

Cannot AOT with .NET Core REPL #25

Closed nasser closed 3 years ago

nasser commented 4 years ago

given mytasks.clj with the following content:

(defn build []
  (binding [*compile-path* "build"]
    (compile 'dummy)))

and the command

nos mytasks/build

where nos was built for .NET Core the following error results:

Unhandled exception. System.IO.FileNotFoundException: Could not locate any of ["mytasks.clj" "mytasks.cljc" "mytasks.clj.dll" "mytasks.cljc.dll"] on load path ["/home/nasser/projects/nostrand/bin/x64/Debug/netcoreapp3.0"]
   at <magic>clojure_core$-load__0.invokeTyped(String relative-path, Object fail-of-not-found)

Looks like the load path is not being set correctly on .NET Core.

Even when moving files into the load path, I still get

File name: 'Lokad.ILPack, Version=0.1.5.0, Culture=neutral, PublicKeyToken=null'

which indicates a packaging error.

skydread1 commented 4 years ago

In the Nostrand.core ns, the function resolve-assembly-load contains an error. We only want what's before the first , of the asm and append the ext to it. A fix :

(defn resolve-assembly-load [asm]
  (let [candidates (for [prefix @-assembly-path
                         ext ["" ".dll" ".exe"]]
                     (let [file-name (-> asm (string/split (re-pattern (str ","))) first)]
                       (Path/Combine prefix (str file-name ext))))
        full-asm-path (first (filter #(File/Exists %) candidates))]
    (when full-asm-path
      (assembly-load-from full-asm-path))))
nasser commented 4 years ago

strange, what comes after , on .NET Core?

skydread1 commented 4 years ago

The asm given looks like this 'Lokad.ILPack, Version=0.1.5.0, Culture=neutral, PublicKeyToken=null'

nasser commented 4 years ago

ah understood. that's the so-called fully qualified name.