Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps.edn: Can't read resource from paths entry #2010

Closed
mfikes opened this issue Jul 19, 2018 · 4 comments
Closed

deps.edn: Can't read resource from paths entry #2010

mfikes opened this issue Jul 19, 2018 · 4 comments
Labels
bug Marks issues describing bugs released Marks issues which have had the fixes released in a stable build
Milestone

Comments

@mfikes
Copy link

mfikes commented Jul 19, 2018

Built on: 2018-07-19 15:12
Built from: 1.8.0-eap2-18-g1e56086

deps.edn:

{:paths ["src" "resources"]}

resources/foo.txt:

Hi

Reading this resource in regular REPL:

$ clj
Clojure 1.9.0
user=> (require '[clojure.java.io :as io])
nil
user=> (slurp (io/resource "foo.txt"))
"Hi\n"
user=>

Import this project into Cursive and set up a REPL

Starting nREPL server...
/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=53024:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Users/mfikes/.m2/repository/org/clojure/clojure/1.9.0/clojure-1.9.0.jar:/Users/mfikes/.m2/repository/org/clojure/core.specs.alpha/0.1.24/core.specs.alpha-0.1.24.jar:/Users/mfikes/.m2/repository/org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.jar:/Users/mfikes/Library/Application Support/IntelliJIdea2018.1/clojure-plugin/lib/tools.nrepl-0.2.12.jar" clojure.main -i /private/var/folders/gx/nymj3l7x4zq3gxb97v2zwzb40000gn/T/form-init6203402383268419739.clj
Connecting to local nREPL server...
Clojure 1.9.0
nREPL server started on port 53026 on host 127.0.0.1
(require '[clojure.java.io :as io])
=> nil
(slurp (io/resource "foo.txt"))
IllegalArgumentException Cannot open <nil> as a Reader.  clojure.java.io/fn--10992 (io.clj:288)

Note that there is no evidence that resources is in the classpath above.

If instead you check via clj:

$ clj -Spath
src:resources:/Users/mfikes/.m2/repository/org/clojure/clojure/1.9.0/clojure-1.9.0.jar:/Users/mfikes/.m2/repository/org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.jar:/Users/mfikes/.m2/repository/org/clojure/core.specs.alpha/0.1.24/core.specs.alpha-0.1.24.jar
@MageMasher
Copy link

I rolled intellij back to 2018.1.4 with cursive 1.8.0-eap3-2018.1 and I am now able to load files from my resources directory.

@MageMasher
Copy link

In case anybody was stuck on this, a workaround for the latest intellij and latest cursive plugin was to put the resources directory inside the src directory. Its gross, but hopefully will be unnecessary soon.

@kennyjwilli
Copy link

Running (System/getProperty "java.class.path") shows that the resources directory is not on the classpath.

(System/getProperty "java.class.path")
=>
"/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/icedtea-sound.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar:/home/kenny/compute_software/config/src:/home/kenny/compute_software/config/test:/home/kenny/.m2/repository/org/clojure/clojure/1.9.0/clojure-1.9.0.jar:/home/kenny/.m2/repository/org/clojure/core.specs.alpha/0.1.24/core.specs.alpha-0.1.24.jar:/home/kenny/.m2/repository/org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.jar:/home/kenny/.IntelliJIdea2018.2/config/plugins/clojure-plugin/lib/tools.nrepl-0.2.12.jar:/home/kenny/Applications/idea-IU/lib/idea_rt.jar"

@MageMasher
Copy link

All I had to do was mark the resources directory as a resource root in cursive and everything works great!
screen shot 2018-08-03 at 12 17 17 pm

@cursive-ide cursive-ide added this to the 1.8.0-eap5 milestone Aug 8, 2018
@cursive-ide cursive-ide added the bug Marks issues describing bugs label Sep 22, 2020
@cursive-ide cursive-ide added the released Marks issues which have had the fixes released in a stable build label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Marks issues describing bugs released Marks issues which have had the fixes released in a stable build
Projects
None yet
Development

No branches or pull requests

4 participants