Fork me on GitHub
#boot
<
2016-11-18
>
roelofw16:11:30

someone who can help me with my boot problem I have asked on the clojure channel

roelofw17:11:32

I want to work with boot and cursive

roelofw17:11:55

but now I see this error message :

C:\Users\rwobb\Desktop\myfw1app>boot run
clojure.lang.ExceptionInfo: No such namespace: io
    data: {:file
           "C:\\Users\\rwobb\\AppData\\Local\\Temp\\boot.user7408732611522524514.clj",
           :line 15}
java.lang.RuntimeException: No such namespace: io
               ...
boot.main/-main/fn   main.clj: 196
   boot.main/-main   main.clj: 196
               ...
  boot.App.runBoot   App.java: 399
     boot.App.main   App.java: 488
               ...
         Boot.main  Boot.java: 258  

micha17:11:45

looks like you need to do (require '[ :as io]) somewhere?

micha17:11:14

can you paste your build.boot file please?

roelofw17:11:31

@micha : here it is :

(def version "0.1.0-SNAPSHOT")

(task-options!
 aot {:namespace   #{'myfw1app.main}}
 pom {:project     'myfw1app
      :version     version
      :description "FIXME: write this!"}
 jar {:main        'myfw1app.main
      :file        (str "myfw1app-" version "-standalone.jar")})

(set-env! :resource-paths #{"src" "resources"}
          ;; the org.clojure/clojure dependency here only affects
          ;; what is bundled in the uberjar via the build task so
          ;; be careful if it is different to the version you have
          ;; configured for Boot!
          :dependencies   '[[org.clojure/clojure "RELEASE"]
                            [framework-one       "RELEASE"]
                                        ; comment this out if you don't want
                                        ; to use http-kit at all:
                            [http-kit            "RELEASE"]])

(deftask build []
  (comp (aot) (pom) (uber) (jar) (target :dir #{"target"})))

(deftask run
  [p port    PORT    int      "the port on which to run the application."
   c config  ARG=VAL {kw str} "the config map for the application."]
  (require '[myfw1app.main :as app])
  ((resolve 'app/start) port config))

(defn- generate-lein-project-file!

  [& {:keys [keep-project] :or {:keep-project true}}]

  (let [pfile (io/file "project.clj")

        pname (or (get-env :project) 'boot-project)

        pvers (or (get-env :version) "0.1.0-SNAPSHOT")

        prop #(when-let [x (get-env %2)] [%1 x])

        head (list* 'defproject pname pvers

               (concat

                 (prop :url :url)

                 (prop :license :license)

                 (prop :description :description)

                 [:dependencies (get-env :dependencies)

                  :source-paths (vec (get-env :source-paths))]))

        proj (pp-str (concat head (mapcat identity (get-env :lein))))]

    (if-not keep-project (.deleteOnExit pfile))

    (spit pfile proj)))



(deftask lein-generate

  "Generate a leiningen `project.clj` file.

  This task generates a leiningen `project.clj` file based on the boot

  environment configuration, including project name and version (generated

  if not present), dependencies, and source paths. Additional keys may be added

  to the generated `project.clj` file by specifying a `:lein` key in the boot

  environment whose value is a map of keys-value pairs to add to `project.clj`."

  [] (generate-lein-project-file! :keep-project true))

micha17:11:18

yeah i don't see you requiring the io alias anywhere

roelofw17:11:24

I never found I had to do

roelofw17:11:33

where and how do I do this ?

micha17:11:50

in clojure if you do (io/foop "barp") it will look for the io namespace

micha17:11:03

which must have already been required

micha17:11:10

require is how you compile a namespace

micha17:11:15

in clojure

micha17:11:27

in your case the io is an alias

micha17:11:48

(io/file "foop")

micha17:11:03

io is an alias for the namespace

micha17:11:16

so you don't have to type so many characters

micha17:11:27

without the alias you'd need to type ( "foop")

micha17:11:06

and the namespace must have already been compiled by the time the clojure compiler tries to compile the ( "foop") expression

micha17:11:19

or it will say "no such namespace" like you saw

micha17:11:39

the way you compile a namespace is (require '[ :as io])

roelofw17:11:21

and I have to place that in the build.boot file on the top ?

micha17:11:33

the build.boot file is just a clojure program

micha17:11:53

like any other clojure code, your build.boot will be evaluated

roelofw17:11:56

the only thing I have done is make a template and did the changes so I can work in Cursive with it

micha17:11:20

what i mean is that this is not boot specific

micha17:11:31

this is a general property of clojure the language

roelofw17:11:47

So I hope that a project.cli is being made

micha17:11:47

if you are going to use a name in a namespace in your program, you must require that namespace first

micha17:11:08

in your program you use

micha17:11:37

and you get a "no such namespace" error when evaluating that code because you have not require that namespace

micha17:11:57

you will get the same error in any clojure program if you use a name in a namespace that has not been required

micha17:11:13

does that make sense?

roelofw17:11:41

yes. next error message : clojure.lang.ExceptionInfo: No such var: str/ends-with?

roelofw17:11:57

so I need to require str also ?

micha17:11:22

clojure.string probably

roelofw17:11:33

so '(clojure.java.str :as str) `

micha17:11:58

so think about that expression ^^

roelofw17:11:06

o, I have not read what you already have written sorry

micha17:11:26

are you new to lisp?

roelofw17:11:07

I only did the clojure koans and some chapters of clojure programming so im new

micha17:11:23

awesome! welcome to the great unknown!

micha17:11:47

so the expression you typed above, (clojure.java.str :as str)

micha17:11:56

that's a lisp expression

micha17:11:13

the first item in the list is the operation that will be done

roelofw17:11:16

also this one is wrong : '(require '[clojure.string :as str]) `

micha17:11:48

boot.user=> (require '[clojure.string :as string])
nil

roelofw17:11:53

time for dinner

micha17:11:56

i just did that in a repl

roelofw17:11:20

so I still doing something wrong 😞

micha17:11:44

(require '[clojure.string :as str]) is correct

micha17:11:01

the first thing is the operation, in this case the clojure.core/require function

roelofw18:11:53

oke, but I still get the same error message 😞

roelofw18:11:35

maybe I can better stick with leiningen

roelofw18:11:43

@micha any idea left ?

micha18:11:55

sure, try this first:

micha18:11:01

boot -BP repl

micha18:11:50

you will end up at the boot.user=> prompt

roelofw18:11:09

that part worked

micha18:11:13

boot.user=> (require '[clojure.string :as str])

micha18:11:37

you should get nil as the result with no exception

roelofw18:11:46

that is correct

roelofw18:11:06

so it seems that there is something wrong with my build.boot file

micha18:11:10

and you can now type this

micha18:11:22

boot.user=> str/ends-with?

micha18:11:29

and you will not get an exception

micha18:11:35

you will see a procedure

roelofw18:11:08

nope, I see this :

boot.user=> (require '[clojure.string :as str])
nil
boot.user=> str/ends-with?

CompilerException java.lang.RuntimeException: No such var: str/ends-with?, compiling:(C:\Users\rwobb\AppData\Local\Temp\boot.user3676501736451595417.clj:7:1) 

micha18:11:35

ah so that means that that var does not exist

micha18:11:49

so you must use something else

micha18:11:04

you can just use the java method on the String object

micha18:11:47

boot.user=> (.endsWith "foop" "oop")
true

micha18:11:44

looks like clojure.string/ends-with? was added in clojure 1.8

micha18:11:53

so if you're using an earlier version of clojure that var won't exist

roelofw18:11:13

At my box I use clojure 1.8

roelofw18:11:28

maybe the template has pulled out a older version

micha18:11:29

this definitely isn't a boot issue though

micha18:11:37

that's just clojure

micha18:11:38

try boot -V

micha18:11:48

it will show you the version of clojure it's configured to use

roelofw18:11:26

aha, there is the culprit : BOOT_CLOJURE_VERSION=1.7.0

roelofw18:11:37

now I have to find out how to change that

roelofw18:11:08

Thanks, now find out what file is meant

roelofw18:11:30

and it works

roelofw18:11:39

I see a FW/1 begin page

roelofw18:11:28

but still not a project.cli file is being made 😞

roelofw18:11:42

oke, there is now a task lein-generate which does the job

roelofw18:11:23

oke, everything works

roelofw18:11:39

Now I hope I can find out how my framework works

roelofw18:11:53

but that is not a boot problem

micha18:11:31

sweet, have fun 👍

roelofw18:11:01

but unfortanly no examples how to make views/controllers and so on

roelofw19:11:41

@micha Can the tutorials work with the fw/1 framework ?

micha19:11:49

i don't think so

micha19:11:33

i wasn't aware that fw/1 was still being maintained, dunno why i thought it wasn't

roelofw19:11:37

maybe I can better use the luminus framework. The only thing that keep me away from it , is that it seems that luminus is not for beginners in clojure

micha19:11:10

if you're a beginner i recommend hoplon 🙂

micha19:11:33

i believe it is the simplest one (i'm prejudiced though)

roelofw19:11:02

oke, and are there tutorials for hoplon ?

micha19:11:31

yes, it is very simple

micha19:11:49

the #hoplon channel has people in it