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

(Windows 10 Pro) read-string fails when reading the environment map returned by calling the clojure executable with -Sdescribe #85

Open
cjbarre opened this issue Mar 19, 2019 · 3 comments

Comments

@cjbarre
Copy link

cjbarre commented Mar 19, 2019

Error Input: Just running lein deps

Error Output: Unsupported escape character: \W

The clojure tools are delivered as a powershell module on windows.

To use lein-tools-deps I created a batch file to wrap the powershell command named windows.clojure.bat

@Echo off
powershell clojure %1

This produces the following when calling from a command line and passing -Sdescribe

{:version "1.10.0.442"
 :config-files ["C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ClojureTools\deps.edn" "C:\Users\my-user\.clojure\deps.edn" "deps.edn"]
 :install-dir "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ClojureTools"
 :config-dir "C:\Users\my-user\.clojure"
 :cache-dir ".cpcache"
 :force False
 :repro False
 :resolve-aliases ""
 :classpath-aliases ""
 :jvm-aliases ""
 :main-aliases ""
 :all-aliases ""}

When lein-tools-deps calls the executable and receives raw string output, the following happens:

read-string here receives the following from (shell/sh exe "-Sdescribe")

{:version \"1.10.0.442\"\n :config-files [\"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\ClojureTools\\deps.edn\" \"C:\\Users\\my-user\\.clojure\\deps.edn\" \"deps.edn\"]\n :install-dir \"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\ClojureTools\"\n :config-dir \"C:\\Users\\my-user\\.clojure\"\n :cache-dir \".cpcache\"\n :force False\n :repro False\n :resolve-aliases \"\"\n :classpath-aliases \"\"\n :jvm-aliases \"\"\n :main-aliases \"\"\n :all-aliases \"\"}\r\n

read-string breaks on the escaped slashes \\

As a workaround, I installed the clojure tools on my ubuntu WSL and changed my batch script to the following:

@Echo off
wsl clojure %1

This returns the file paths in unix form. This works, but I can't speak to how brittle it may turn out to be yet. It would be great if we can add whatever processing is required here to properly interpret windows file conventions, instead of the barebones read-string.

I hope this is helpful, thank you for your work.

😃

@cjbarre
Copy link
Author

cjbarre commented Mar 19, 2019

If I'm not wrong about the above, and not just doing something silly, then I think we should also figure out how to avoid forcing users on windows to create a powershell wrapper to call the clojure command.

@zhanghuabin
Copy link

+1, I have same issue (Win 8.1).

This is my workaround(no ubuntu wsl) as below:

  1. To solve the path-separator issue of -Sdescribe command, I modify ClojureTools.psm1, replace all \ in path to / with replace() function.
  2. Create clojure.bat with script:
@ECHO OFF
call pwsh.exe -c "clj %*"
  1. Add :clojure-executables to project.clj.

Actually, I think step #3 is not nessary if we do a tweak like this:
(shell/sh "cmd" "/c" "clojure" "-Sdescribe")

Please notice that The above approach can find both clojure.bat and clojure.cmd in PATH, but (shell/sh "clojure" "-Sdescribe") can not.

I have submitted a PR for process creating issue on Windows.

@hlolli
Copy link

hlolli commented Jun 28, 2019

I think this may be related, this stacktrace is from a powershell on Windows10

lein deps
java.io.IOException: Cannot run program "clojure" (in directory "C:\Users\User\Documents\panaeolus"): CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048)
    java.lang.Runtime.exec (Runtime.java:620)
    clojure.java.shell$sh.invokeStatic (shell.clj:113)
    clojure.java.shell$sh.doInvoke (shell.clj:79)
    clojure.lang.RestFn.invoke (RestFn.java:421)
    lein_tools_deps.env$scrape_clojure_env.invokeStatic (env.clj:32)
    lein_tools_deps.env$scrape_clojure_env.invoke (env.clj:27)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invokeStatic (core.clj:665)
    clojure.core$memoize$fn__6862.doInvoke (core.clj:6353)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    lein_tools_deps.plugin$apply_middleware.invokeStatic (plugin.clj:25)
    lein_tools_deps.plugin$apply_middleware.invoke (plugin.clj:17)
    lein_tools_deps.plugin$resolve_dependencies_with_deps_edn.invokeStatic (plugin.clj:47)
    lein_tools_deps.plugin$resolve_dependencies_with_deps_edn.invoke (plugin.clj:34)
    clojure.lang.Var.invoke (Var.java:384)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:817)
    leiningen.core.project$apply_middleware.invoke (project.clj:810)
    clojure.lang.ArrayChunk.reduce (ArrayChunk.java:58)
    clojure.core.protocols$fn__8139.invokeStatic (protocols.clj:136)
    clojure.core.protocols/fn (protocols.clj:124)
    clojure.core.protocols$fn__8099$G__8094__8108.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
    clojure.core.protocols$fn__8131.invokeStatic (protocols.clj:75)
    clojure.core.protocols/fn (protocols.clj:75)
    clojure.core.protocols$fn__8073$G__8068__8086.invoke (protocols.clj:13)
    clojure.core$reduce.invokeStatic (core.clj:6828)
    clojure.core$reduce.invoke (core.clj:6810)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:812)
    leiningen.core.project$apply_middleware.invoke (project.clj:810)
    leiningen.core.project$activate_middleware.invokeStatic (project.clj:844)
    leiningen.core.project$activate_middleware.invoke (project.clj:840)
    leiningen.core.project$init_project.invokeStatic (project.clj:986)
    leiningen.core.project$init_project.invoke (project.clj:974)
    leiningen.core.project$read.invokeStatic (project.clj:1057)
    leiningen.core.project$read.invoke (project.clj:1054)
    leiningen.core.project$read.invokeStatic (project.clj:1058)
    leiningen.core.project$read.invoke (project.clj:1054)
    leiningen.core.main$_main$fn__6681.invoke (main.clj:447)
    leiningen.core.main$_main.invokeStatic (main.clj:442)
    leiningen.core.main$_main.doInvoke (main.clj:439)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:665)
    clojure.main$main_opt.invokeStatic (main.clj:491)
    clojure.main$main_opt.invoke (main.clj:487)
    clojure.main$main.invokeStatic (main.clj:598)
    clojure.main$main.doInvoke (main.clj:561)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:37)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessImpl.create (ProcessImpl.java:-2)
    java.lang.ProcessImpl.<init> (ProcessImpl.java:386)
    java.lang.ProcessImpl.start (ProcessImpl.java:137)
    java.lang.ProcessBuilder.start (ProcessBuilder.java:1029)
    java.lang.Runtime.exec (Runtime.java:620)
    clojure.java.shell$sh.invokeStatic (shell.clj:113)
    clojure.java.shell$sh.doInvoke (shell.clj:79)
    clojure.lang.RestFn.invoke (RestFn.java:421)
    lein_tools_deps.env$scrape_clojure_env.invokeStatic (env.clj:32)
    lein_tools_deps.env$scrape_clojure_env.invoke (env.clj:27)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invokeStatic (core.clj:665)
    clojure.core$memoize$fn__6862.doInvoke (core.clj:6353)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    lein_tools_deps.plugin$apply_middleware.invokeStatic (plugin.clj:25)
    lein_tools_deps.plugin$apply_middleware.invoke (plugin.clj:17)
    lein_tools_deps.plugin$resolve_dependencies_with_deps_edn.invokeStatic (plugin.clj:47)
    lein_tools_deps.plugin$resolve_dependencies_with_deps_edn.invoke (plugin.clj:34)
    clojure.lang.Var.invoke (Var.java:384)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:817)
    leiningen.core.project$apply_middleware.invoke (project.clj:810)
    clojure.lang.ArrayChunk.reduce (ArrayChunk.java:58)
    clojure.core.protocols$fn__8139.invokeStatic (protocols.clj:136)
    clojure.core.protocols/fn (protocols.clj:124)
    clojure.core.protocols$fn__8099$G__8094__8108.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
    clojure.core.protocols$fn__8131.invokeStatic (protocols.clj:75)
    clojure.core.protocols/fn (protocols.clj:75)
    clojure.core.protocols$fn__8073$G__8068__8086.invoke (protocols.clj:13)
    clojure.core$reduce.invokeStatic (core.clj:6828)
    clojure.core$reduce.invoke (core.clj:6810)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:812)
    leiningen.core.project$apply_middleware.invoke (project.clj:810)
    leiningen.core.project$activate_middleware.invokeStatic (project.clj:844)
    leiningen.core.project$activate_middleware.invoke (project.clj:840)
    leiningen.core.project$init_project.invokeStatic (project.clj:986)
    leiningen.core.project$init_project.invoke (project.clj:974)
    leiningen.core.project$read.invokeStatic (project.clj:1057)
    leiningen.core.project$read.invoke (project.clj:1054)
    leiningen.core.project$read.invokeStatic (project.clj:1058)
    leiningen.core.project$read.invoke (project.clj:1054)
    leiningen.core.main$_main$fn__6681.invoke (main.clj:447)
    leiningen.core.main$_main.invokeStatic (main.clj:442)
    leiningen.core.main$_main.doInvoke (main.clj:439)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:665)
    clojure.main$main_opt.invokeStatic (main.clj:491)
    clojure.main$main_opt.invoke (main.clj:487)
    clojure.main$main.invokeStatic (main.clj:598)
    clojure.main$main.doInvoke (main.clj:561)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:37)

clojure and clj work fine.

filipesilva added a commit to filipesilva/athens that referenced this issue Oct 8, 2021
Lein with deps.edn does not work on Windows, so we're moving to clj+deps.edn.

See RickMoynihan/lein-tools-deps#85
filipesilva added a commit to filipesilva/athens that referenced this issue Oct 8, 2021
Lein with deps.edn does not work on Windows, so we're moving to clj+deps.edn.

See RickMoynihan/lein-tools-deps#85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants