clj-commons/virgil

Windows file separators causing URISyntaxException

SOberhoff opened this issue · 8 comments

I have a Java file called abc.java located at src/misc/abc.java and src is added to my :java-source-paths. When starting the REPL I receive:

Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in path at index 10: string:///\misc\abc.java, compiling: ...
...
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 10: string:///\misc\abc.java
	at java.net.URI.create(URI.java:852)
	at virgil.compile$source_object.invokeStatic(compile.clj:33)
	at virgil.compile$source_object.invoke(compile.clj:30)
	at virgil.compile$source__GT_bytecode$fn__1816.invoke(compile.clj:68)```
...
Caused by: java.net.URISyntaxException: Illegal character in path at index 10: string:///\misc\abc.java
	at java.net.URI$Parser.fail(URI.java:2848)
	at java.net.URI$Parser.checkChars(URI.java:3021)
	at java.net.URI$Parser.parseHierarchical(URI.java:3105)
	at java.net.URI$Parser.parse(URI.java:3053)
	at java.net.URI.<init>(URI.java:588)
	at java.net.URI.create(URI.java:850)

The \ appears to be the issue. When I remove Virgil from the plugins the error disappears. I'm running Windows 10 and using Virgil 0.1.6.

Okay, I think I'm using a hardcoded backslash when I should be using File/separator. I don't have a Windows box to test this on, would you mind being used as a tester for a potential fix?

I've pushed a potential fix. Can you clone the repo, run lein install, and try it again?

Now I have Illegal character in path at index 14: string:///misc\abc.java

I've pushed the second update, let me know if it does the trick. If not, I'll look into getting some sort of virtual environment I can do my own tests in.

Now it's saying Illegal character in authority at index 9: string://\misc\abc.java

I've messed around with the code myself a little and all Windows issues are solved by replacing every occurrence of File/separator with "/" (lines 33, 34, 43, 44). I don't know whether that raises issues on Linux/Mac.

This should be fixed in 0.1.7 and the issue can be closed.