Description
Reproduced in Lumo v1.8.0-beta
(which bundles ClojureScript 1.9.927 and Node.js v8.5.0), MacOS 10.11.6.
v1.7.0
is OK.
Original problem
Initially the issue was detected when I called Lumo from Jenkins pipeline:
// foo.cljs exists in current directory
sh """ lumo -e "(require 'foo)" """
Output:
+ lumo -e (require 'foo)
No such namespace: foo, could not locate foo.cljs, foo.cljc, or JavaScript source providing "foo"
(new)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1928:72)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2539:92)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2538:92)
(NO_SOURCE_FILE <embedded>:5847:162)
Object.lumo.repl.load_other (NO_SOURCE_FILE <embedded>:6363:378)
lumo.repl.load (NO_SOURCE_FILE <embedded>:6367:96)
Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5849:77)
Function.cljs.js.load_deps.cljs$core$IFn$_invoke$arity$7 (NO_SOURCE_FILE <embedded>:5859:507)
Function.cljs.js.ns_side_effects.cljs$core$IFn$_invoke$arity$6 (NO_SOURCE_FILE <embedded>:5917:287)
Minimal example 1
I believe that the same problem can be reproduced without Jenkins and is caused by output redirection. In MacOS Terminal (also reproduced in node:8.5.0-stretch
docker container):
echo '(ns foo.core)' > foo.cljs ; lumo -e "(require 'foo)" > out.txt ; cat out.txt
Expected: should work the same as without redirection (i.e. blank output):
ᐅ echo '(ns foo.core)' > foo.cljs ; lumo -e "(require 'foo)"
ᐅ
Actual:
No such namespace: foo, could not locate foo.cljs, foo.cljc, or JavaScript source providing "foo"
(new)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1928:72)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2539:92)
Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2538:92)
(NO_SOURCE_FILE <embedded>:5847:162)
Object.lumo.repl.load_other (NO_SOURCE_FILE <embedded>:6363:378)
lumo.repl.load (NO_SOURCE_FILE <embedded>:6367:96)
Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5849:77)
Function.cljs.js.load_deps.cljs$core$IFn$_invoke$arity$7 (NO_SOURCE_FILE <embedded>:5859:507)
Function.cljs.js.ns_side_effects.cljs$core$IFn$_invoke$arity$6 (NO_SOURCE_FILE <embedded>:5917:287)
Minimal example 2
Digging further, I found that the root of the problem is the exception in js/lumo.js:readSource when it tries to read foo.cljs
. This can be reproduced by using NodeJS fs
from Lumo:
ᐅ lumo -e '(def fs (js/require "fs")) (println (.readFileSync fs "any-name-here" "utf8"))' > out.txt ; cat out.txt
assertEncoding is not a function
getOptions (fs.cljs:81:5)
Object.fs.readFileSync (fs.cljs:552:13)
(evalmachine.<anonymous>:1:42)
ContextifyScript.Script.runInThisContext (vm.cljs:44:33)
Object.runInThisContext (vm.cljs:116:38)
(Object.lt)
(Object.lumo.repl.caching_node_eval)
(NO_SOURCE_FILE <embedded>:6020:273)
z (NO_SOURCE_FILE <embedded>:6021:263)
Object.cljs.js.eval_str_STAR_ (NO_SOURCE_FILE <embedded>:6022:328)
#'cljs.user/fs
Workaround
Rebuild Lumo with nodeVersion
8.4.0
or 8.6.0
instead of 8.5.0
.
Cause
This issue looks very similar to what is described in nodejs/node#11257 and is presumably caused by circular dependencies in Node's fs
lib.
It's still not fixed. Thus it's not really clear why changing NodeJS version in Lumo fixes the problem.