Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Exception when creating new project on windows #25

Merged
merged 1 commit into from about 2 years ago

2 participants

Tim King Phil Hagelberg
Tim King

Documentation for ClassLoader.getResource() says it expects the name of a resource to be a '/'-separated path, so lets give it one.

The following exception is thrown when trying to create a new project on windows.

C:\Users\tking\Workspace\clj>lein2 new foo
Generating a project called foo based on the 'default' template.
Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil (NO_SOURCE_FILE:0)
        at clojure.lang.Compiler.eval(Compiler.java:5440)
        at clojure.lang.Compiler.eval(Compiler.java:5391)
        at clojure.core$eval.invoke(core.clj:2382)
        at clojure.main$eval_opt.invoke(main.clj:235)
        at clojure.main$initialize.invoke(main.clj:254)
        at clojure.main$script_opt.invoke(main.clj:270)
        at clojure.main$main.doInvoke(main.clj:354)
        at clojure.lang.RestFn.invoke(RestFn.java:482)
        at clojure.lang.Var.invoke(Var.java:381)
        at clojure.lang.AFn.applyToHelper(AFn.java:178)
        at clojure.lang.Var.applyTo(Var.java:482)
        at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
        at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:471)
        at clojure.java.io$fn__7389$G__7384__7396.invoke(io.clj:63)
        at clojure.java.io$reader.doInvoke(io.clj:96)
        at clojure.lang.RestFn.invoke(RestFn.java:410)
        at leiningen.new.templates$slurp_resource.invoke(templates.clj:29)
        at leiningen.new.templates$renderer$fn__711.doInvoke(templates.clj:79)
        at clojure.lang.RestFn.invoke(RestFn.java:423)
        at leiningen.new.default$default.invoke(default.clj:15)
        at clojure.lang.Var.invoke(Var.java:365)
        at clojure.lang.AFn.applyToHelper(AFn.java:161)
        at clojure.lang.Var.applyTo(Var.java:482)
        at clojure.core$apply.invoke(core.clj:542)
        at leiningen.new$create.doInvoke(new.clj:54)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at leiningen.new$create.invoke(new.clj:47)
        at clojure.lang.AFn.applyToHelper(AFn.java:161)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at clojure.core$apply.invoke(core.clj:540)
        at leiningen.new$new.doInvoke(new.clj:101)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:365)
        at clojure.lang.AFn.applyToHelper(AFn.java:161)
        at clojure.lang.Var.applyTo(Var.java:482)
        at clojure.core$apply.invoke(core.clj:540)
        at leiningen.core$apply_task.invoke(core.clj:265)
        at leiningen.core$_main.doInvoke(core.clj:331)
        at clojure.lang.RestFn.applyTo(RestFn.java:139)
        at clojure.core$apply.invoke(core.clj:542)
        at leiningen.core$_main.invoke(core.clj:334)
        at user$eval42.invoke(NO_SOURCE_FILE:1)
        at clojure.lang.Compiler.eval(Compiler.java:5424)
        ... 11 more

C:\Users\tking\Workspace\clj>lein repl
REPL started; server listening on localhost port 52965
user=> (use 'leiningen.new.templates)
nil
user=> (in-ns 'leiningen.new.templates)
#<Namespace leiningen.new.templates>
leiningen.new.templates=> (def file (io/file "leiningen" "new" "default" "project.clj"))
#'leiningen.new.templates/file
leiningen.new.templates=> (.getPath file)
"leiningen\\new\\default\\project.clj"
leiningen.new.templates=> (io/resource (.getPath file))
nil
leiningen.new.templates=> (io/resource "leiningen/new/default/project.clj")
#<URL jar:file:/C:/Users/tking/.lein/plugins/lein-newnew-0.2.6.jar!/leiningen/new/default/project.clj>
leiningen.new.templates=>
Phil Hagelberg technomancy merged commit 922d587 into from
Phil Hagelberg
Collaborator

Ironic considering I try to use io/file for better portability. Thanks for the patch. =)

Tim King

:) Thanks Phil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 17, 2012
Tim King kingtim fix renderer on windows 24d5c16
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. +5 5 src/leiningen/new/templates.clj
10 src/leiningen/new/templates.clj
@@ -25,8 +25,8 @@
25 25 ;; these days.
26 26 (defn slurp-resource
27 27 "Reads the contents of a file on the classpath."
28   - [file]
29   - (-> file .getPath io/resource io/reader slurp))
  28 + [resource-path]
  29 + (-> resource-path io/resource io/reader slurp))
30 30
31 31 ;; This is so common that it really is necessary to provide a way to do it
32 32 ;; easily.
@@ -74,10 +74,10 @@
74 74 file is simply slurped and the content returned unchanged."
75 75 [name]
76 76 (fn [template & [data]]
77   - (let [file (io/file "leiningen" "new" name (sanitize template))]
  77 + (let [path (string/join "/" ["leiningen" "new" name (sanitize template)])]
78 78 (if data
79   - (render-text (slurp-resource file) data)
80   - (io/resource (.getPath file))))))
  79 + (render-text (slurp-resource path) data)
  80 + (io/resource path)))))
81 81
82 82 ;; Our file-generating function, `->files` is very simple. We'd like
83 83 ;; to keep it that way. Sometimes you need your file paths to be

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.