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

Change command line quoting when calling clojure cli #2656

Closed
cark opened this issue Jun 23, 2019 · 2 comments
Closed

Change command line quoting when calling clojure cli #2656

cark opened this issue Jun 23, 2019 · 2 comments

Comments

@cark
Copy link

cark commented Jun 23, 2019

Is your feature request related to a problem? Please describe.

Cider does not start a deps.edn project under windows (using C-c M-j).

This is due to the lack of a clojure command, which in turn is due to the clojure team deciding to use a powershell command to run clojure. There is no file to run.

Even outside cider, the crux of the problem is that, under windows, we have to deal with no less than 3 competing escaping rules for the double quotes in the clojure command line (the shell we're using, powershell and java).

There are some tools to replace the command line provided by the clojure team. But even those have still to deal with 2 separate escaping rules.

Here is one of these : https://github.com/frericksm/clj-windows

I propose to change the way cider builds the command it uses to start clojure. By using double quote and backslash-double quote instead of single-quote, double-quote, we can make it compatible with windows in addition to unix.

I've done this in my local copy of cider and tested it under windows and ubuntu.
It works and i'll send a pull request for review.

Please note that this does not solve the windows problem. It only makes it more palatable. It is still necessary to use the command line tool linked above rather than the one provided by the clojure team. It is my belief that even if/when the clojure team changes its command line tool, we'll still need to have this change anyways.

Describe alternatives you've considered

I've been spending this day and several more hours considering any way to do it, tried so many tricks... Nothing worked but changing cider and using the command line tool listed above.

There is an alternative that wouldn't require an external tool : Directly executing the clojure launch command with powershell would be brittle and might require real parsing as we're back at dealing with 3 competing escaping rules. But cider could create a temp powershell file *.ps1 then execute powershell with this file as a parameter.

The change is very small, PR to follow.

@cark
Copy link
Author

cark commented Jul 29, 2019

This is not an issue to me anymore, I've written a binary wrapper to the powershell command line, and also a complete clojure powershell scripts replacement. Both are sporting command line compatibility with the Posix clojure command line.

I'll leave the issue open because these are in no way official, but solutions now exist outside of a cider change. Admins, feel free to close it, as well as the PR.

@scottdw
Copy link
Contributor

scottdw commented Jul 31, 2019

I have a solution which uses the powershell -encodedCommand option. If the user sets cider-clojure-cli-command to "powershell" the clojure command and arguments are base64 encoded and sent to the powershell executable. This does make the printed jack-in command rather opaque but it should be compatible with whatever shell the user is running.

Would a PR be useful?

scottdw added a commit to scottdw/cider that referenced this issue Aug 1, 2019
To avoid multiple layers of escaping when using tools.deps with
PowerShell, base64 encode the clojure command and arguments when
calling jack-in with `cider-clojure-cli-command` as `"powershell"`.
scottdw added a commit to scottdw/cider that referenced this issue Aug 10, 2019
To avoid multiple layers of escaping when using tools.deps with
PowerShell, base64 encode the clojure command and arguments when
calling jack-in with `cider-clojure-cli-command` as `"powershell"`.

If no clojure command is found on a Windows system use "powershell"
for `cider-clojure-cli-command` by default.
scottdw added a commit to scottdw/cider that referenced this issue Aug 10, 2019
To avoid multiple layers of escaping when using tools.deps with
PowerShell, base64 encode the clojure command and arguments when
calling jack-in with `cider-clojure-cli-command` as `"powershell"`.

If no clojure command is found on a Windows system use "powershell"
for `cider-clojure-cli-command` by default.
scottdw added a commit to scottdw/cider that referenced this issue Aug 10, 2019
scottdw added a commit to scottdw/cider that referenced this issue Aug 13, 2019
To avoid multiple layers of escaping when using tools.deps with
PowerShell, base64 encode the clojure command and arguments when
calling jack-in with `cider-clojure-cli-command` as `"powershell"`.

If no clojure command is found on a Windows system use "powershell"
for `cider-clojure-cli-command` by default.
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

2 participants