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

clj Jack-in on Windows uses legacy power shell #1000

Closed
PEZ opened this issue Jan 31, 2021 · 14 comments
Closed

clj Jack-in on Windows uses legacy power shell #1000

PEZ opened this issue Jan 31, 2021 · 14 comments
Labels

Comments

@PEZ
Copy link
Collaborator

PEZ commented Jan 31, 2021

From #387 (comment)

I eventually realised Calva is using legacy Windows Powershell (powershell.exe) rather than the newer multi-platform Powershell (pwsh.exe). Once I had installed Clojure CLI tools using the clj on Windows instructions in Windows Powershell (previously they were installed in multi-platform Powershell only) then Calva jack-in worked as expected.

Calva should by default use the current pwsh.exe, but also offer a legacy option.

@PEZ PEZ added the jack-in label Jan 31, 2021
@bpringe
Copy link
Member

bpringe commented Jan 31, 2021

With this I'd want to verify what powershell version (powershell.exe or pwsh.exe) works with clj-on-windows as well as clojure installed via Chocolatey or scoop. I suppose this might be worth looking into for lein too. I'm not sure which one would work in the majority of situations at this point, but if we must default to one, I think it should be the one that works in most cases.

Also, if there's any way we can figure out which one should be used, then we should do that, but there may not be a simple solution to this.

@bpringe
Copy link
Member

bpringe commented Jan 31, 2021

Also, clojure-lsp was recently changed to use powershell.exe by default for the classpath lookup if the OS is Windows (and no classpath command was specified in the config). So @ericdallo may want to follow developments on this issue.

@ericdallo
Copy link
Contributor

Yeah, we would need to know when to use pwsh or powershell.exe, it seems emacs lsp-mode checks for one then fallback to other: https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-pwsh.el#L228

@bpringe
Copy link
Member

bpringe commented Jan 31, 2021

Interesting, I think though from the quoted comment in this issue that it's not enough to check which exists. From what that person said, it seems you can have both, but it depends on how Clojure was installed as to which one will be able to see/run it.

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 31, 2021

It is quite a mess. 😄 I'm trying a different path in a local dev branch right now. Bundling and using babashka to launch the repl. It works, and I'll push the branch so that more people can try it, but I'm not sure it is the way to go. Partly because it is quite a huge bundle, adding 70mb to Calva's current 35mb. Not sure if we should care much about that. Yeah, generally, ”not sure” sums up a lot of where I am right now...

However, babashka uses deps.clj, which @borkdude suggests could be ported to deps.cljc and then we could use it in Calva directly for a more straightforward way to launch deps.edn projects. Maybe we can use bb.exe in the interim.

Then, also, clojure-lsp should be able to consume deps.clj as is, right? Maybe that is a better option for its need for classpath lookup, than navigating correctly between all the ways the Clojure CLI stuff could be installed. I don't really know what I am talking about here, but anyway.

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 31, 2021

If clojure-lsp can use deps.clj for the classpath lookup, then maybe it can also help launch deps.edn projects? We're already bundling clojure-lsp, after all.

@ericdallo
Copy link
Contributor

Yeah, it looks a alternative way indeed, not sure how hard is to implement that, we would need to parse a deps file and get all classpath, not sure there is any way to do that using babashka via JVM or something like that

@borkdude
Copy link

@ericdallo

No need to read deps.edn files, etc. This is what tools.deps already does. deps.clj is basically a tool and library which you can invoke as a script, but also as a JVM library, which replaces the clojure "front-end" bash/powershell script, but works identically to it.

So from the JVM you could do:

(require '[borkdude.deps :as deps])
(def classpath (with-out-str (deps/-main "-Spath")))

@ericdallo
Copy link
Contributor

TIL, really cool!
so, deps.clj would replace these classpath scan tools?
Does deps.clj replace all classpath scans?

@borkdude
Copy link

@ericdallo No, deps.clj is only for deps.edn-based projects.

@ericdallo
Copy link
Contributor

I see, it'd work for deps projects, but we still need to scan other kinds of projects so @PEZ

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 31, 2021

Yeah, Calva and clojure-lsp have different needs here.

But deps.edn is special since the CLI tools are tied to powershell and there are several powershells and the tools get installed in different ways. I'm happy that I might have found a way to avoid the powershell mess for Calva's needs. At least as a temporary way.

@bpringe
Copy link
Member

bpringe commented Feb 1, 2021

Does this mess spill over into lein installs / projects too? Or does powershell.exe seem to work for all lein projects?

@PEZ
Copy link
Collaborator Author

PEZ commented Feb 1, 2021

For lein we use cmd.exe, so it isn't affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants