File-encoding problem while checking NS

Description

When I tried to check a namespace in a directory with a non-ascii character (/home/ctford/Código/traversy), I got the following exception:

traversy.lens=> (clojure.core.typed/check-ns)
Start collecting traversy.lens

FileNotFoundException /home/ctford/Código/traversy/src/traversy/lens.clj (No existe el archivo o el directorio) java.io.FileInputStream.open (FileInputStream.java:-2)
traversy.lens=> (pst)
FileNotFoundException /home/ctford/Código/traversy/src/traversy/lens.clj (No existe el archivo o el directorio)
java.io.FileInputStream.open (FileInputStream.java:-2)
java.io.FileInputStream.<init> (FileInputStream.java:146)
clojure.java.io/fn--8642 (io.clj:242)
clojure.java.io/fn--8577/G--8542--8584 (io.clj:73)
clojure.java.io/fn--8612 (io.clj:169)
clojure.java.io/fn--8551/G--8546--8558 (io.clj:73)
clojure.java.io/reader (io.clj:106)
clojure.tools.namespace.file/read-file-ns-decl (file.clj:22)
clojure.core.typed.ns-deps-utils/ns-form-for-file (ns_deps_utils.clj:19)
clojure.core.typed.ns-deps-utils/ns-form-for-ns (ns_deps_utils.clj:29)
clojure.core.typed.ns-deps-utils/deps-for-ns (ns_deps_utils.clj:46)
clojure.core.typed.collect-utils/collect-ns* (collect_utils.clj:74)

Environment

Linux Mint Petra

Activity

Show:
import
December 23, 2014, 7:14 PM

Comment made by: ctford

I hardcoded .clj to avoid the impl macro problem.

After the first call I get:
"file_encoding/core.clj"

But after the second I get:
#<URL file:/home/ctford/C%c3%b3digo/file-encoding/src/file_encoding/core.clj>

That looks like the resulting URL has problems - it's encoded the accented o with two characters.

The third call throws the FileNotFoundException.

import
December 23, 2014, 9:08 PM

Comment made by: ctford

Looks like the problem is in the URL coding and decoding. This works:

(-> "file_encoding/core.clj" resource str java.net.URLDecoder/decode file/read-file-ns-decl)

I've hacked a quick fix for the issue. I'll test it and let you know.

https://github.com/ctford/core.typed/commit/4e68628b0e0a0c60a8e1ee60fadbb524684810d7

import
December 23, 2014, 10:28 PM

Comment made by: ctford

I had to push a second commit addressing other uses of io/reader - this probably should be centralised if a fix is shown to work.

When I tested the fix, I ran across two problems that are probably not related to the fix itself. Firstly, something odd happened that seemed to be related to ClojureScript:

And then once I'd disabled .cljs by attacking the when clause that checks for analyzer.clj in module-check/src/main/clojure/clojure/core/typed/init.clj:

Could these errors be related to other things in HEAD? Or have I broken stuff I didn't understand?

import
December 24, 2014, 12:33 PM

Comment made by: ctford

Avoiding file URLs altogether might be a more robust fix. This works:

import
December 24, 2014, 4:26 PM

Comment made by: ctford

This appears to have been fixed in Clojure 1.6 - http://dev.clojure.org/jira/browse/CLJ-1177

Completed

Assignee

Ambrose Bonnaire-Sergeant

Reporter

import

Labels

None

Approval

None

Patch

None

Affects versions

Priority

Major
Configure