boot-clj / boot-new

Generate new projects based on Boot Templates and/or Leiningen Templates!
https://clojars.org/boot/new
Eclipse Public License 1.0
155 stars 42 forks source link

No implementation of method: :make-reader for leiningen-version #19

Closed arichiardi closed 8 years ago

arichiardi commented 8 years ago

Hello Sean, I know this might or might not be a boot-new concern but I am going to report it here for discussion.

Sometimes templates use Leiningen-specific functions, like: [leiningen.core.main :as main :refer [leiningen-version]]

This function is very useful and big templates like luminus take advantage or that. Maybe a solution could be to include Leiningen classes on the classpath in boot-new? Otherwise boot-new cannot generate those "popular" templates.

When I call it, I get:

        clojure.lang.ExceptionInfo: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
    data: {:file "/tmp/boot.user2705218119118993821.clj", :line 15}
java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
      clojure.core/-cache-protocol-fn  core_deftype.clj:  554
                 clojure.java.io/fn/G            io.clj:   69
               clojure.java.io/reader            io.clj:  102
                                  ...                        
leiningen.core.main/leiningen-version          main.clj:  321
leiningen.new.lambone/version-before?       lambone.clj:   34
        leiningen.new.lambone/lambone       lambone.clj:   59
                                  ...                        
                   clojure.core/apply          core.clj:  632
             boot.new-helpers/create*   new_helpers.clj:  105
              boot.new-helpers/create   new_helpers.clj:  118
                                  ...                        
             boot.new/eval74/fn/fn/fn           new.clj:   43
                  boot.core/run-tasks          core.clj:  943
                    boot.core/boot/fn          core.clj:  953
  clojure.core/binding-conveyor-fn/fn          core.clj: 1916
                                  ...                        

I was wondering if there is a way to identify that I am creating the template with boot-new and avoid the function call.

seancorfield commented 8 years ago

The Leiningen core library is on the classpath and several templates rely on that and work just fine.

The problem with leiningen-version and some others functions is that they reach out to environment variables (set by the lein shell script) or the project.clj file itself or the non-core Leiningen files -- which boot-new cannot provide.

Specifically leiningen-version checks an environment variable (which Java code cannot set) and reads the pom.properties file out of Leiningen's META-INF folder tree (which is not part of the Leiningen core).

seancorfield commented 8 years ago

See https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/main.clj#L330-L337

arichiardi commented 8 years ago

Oh that explains why I have this error:

        clojure.lang.ExceptionInfo: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
    data: {:file "/tmp/boot.user2705218119118993821.clj", :line 15}

The reader in is of course nil at that point...I wonder if I can detect if I am running boot-new and skip the call somehow.

arichiardi commented 8 years ago

I have updated the issue, can still be useful to know a workaround I guess.

seancorfield commented 8 years ago

As a hack, I could include a fake pom.properties for Leiningen in boot-new's JAR that should allow leiningen.core.main/leiningen-version to be satisfied.

arichiardi commented 8 years ago

Yes I was thinking about that, but are you going to return a real lein version or like boot-new as string? This poses the issue of which lein version boot-new support I guess.

seancorfield commented 8 years ago

Yes, boot-new would "lock" the version of Leiningen it supported so if templates started requiring new features in Leiningen, I'd have to review them anyway and see if boot-new needed to be updated to support them (and bump the "supported Leiningen version" either way).

arichiardi commented 8 years ago

Yeah definitely true, it would be great if you could be 100% lein compatible.

seancorfield commented 8 years ago

Fixed in release 0.4.3 which just dropped on Clojars. I tested that I can generate a Luminus template.

arichiardi commented 8 years ago

Great! Thanks super quick ;)