Fork me on GitHub

I have some code in a file that when I copy-paste into a fresh Planck, it works great. But when I run as planck script.cljs (or prepend the file with #!/usr/bin/env planck & chmod & run it), I get a warning, Use of undeclared Var cljs.user/slurp, and the infamous undefined is not an object (evaluating '')—feels like I'm doing something really stupid wrong but I can't find it


My namespace should import slurp (and does when I paste the code into Planck):

(ns build.core
  (:require [planck.core :refer [slurp spit]]
            [clojure.string :as string]
            [ :as reader]
            [planck.core :refer [eval]]))


Hmm… does the second planck.core :refer blow away the first? I’m actually not sure what that might do.


I just noticed that and fixed it—problem persists


Now the first two lines of the script are:

#!/usr/bin/env planck
(ns build.core
  (:require [planck.core :refer [slurp spit eval]]
            [clojure.string :as string]
            [ :as reader]))


Ok, so it's not something immediately obvious—that's what I wanted to verify, I'll continue poking it. I love planck's insta-startup (node spoiled me), so I'll make it work 🙂


I can’t reproduce what I think you are describing by putting (prn slurp) after the stuff below.


Perhaps a minimal repro would help


Sorry @mfikes false alarm. The slurp error was being caused by me trying to eval (slurp …) from a string. It was giving the error on line 1, which I thought was my ns, but no, it must be "line 1" of the eval


Ok, @mfikes, take a look at this minimum reproduction: if I paste this file exactly into planck, all is well & the println succeeds. If I run as a planck script, it errors (latest 1.13):


This is part of a function that replaces Clojure expressions in text files with their evaluated values. So I have a plain string "(slurp file)" which I read-string to get as a seq. I specify a binding vector which let will use to ascribe a value for file (in this example, it's script.cljs but could be anything), so when that '(slurp file) is evaluated, "file" has a binding.


In the Planck REPL, I see "PRINTING" followed by the contents of script.cljs. In the command line, I see

$ planck script.cljs
WARNING: Use of undeclared Var cljs.user/slurp
undefined is not an object (evaluating '')


I can try to verify that the code works in lein repl/JVM clojure. If it does work fine there, that may indicate something weird with planck script files?


@fasiha The problem is that Planck’s eval should be executing in the build.core namespace for your example, but it is evaluating in cljs.user. It’s a bug.


@fasiha: Partial fix pushed. (Works for your example, unless you employ -K or -k to cache.) If you are using brew, you can install it by following the “Install Master” section of The ticket is Great catch! You can also work around it by qualifying as planck.core/slurp in your eval call, or alternatively, by using planck.repl/eval and adding a second argument specifying the symbol ’build.core as the namespace to eval in.


@mfikes: you are too hardworking, I feel bad for asking questions like this on the weekend—thank you!!! 🙇🙏