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

Consider using the new officially sanctioned clj-msi when installing clojure on Windows #65

Closed
lread opened this issue Jul 29, 2022 · 27 comments

Comments

@lread
Copy link

lread commented Jul 29, 2022

Hiya!

I am excited to see support for deps.exe (as clojure.exe) on Windows.
Thanks so much for adding that as a feature!

The current README suggests selecting via:

  cmd-exe-workaround: 'latest' # Replaces `clojure` with `deps.clj` on Windows

But the source code sez cmd-exe-workaround is deprecated

setup-clojure/action.yml

Lines 17 to 24 in 3199aaa

cmd-exe-workaround:
description: >+
[DEPRECATED]
On Windows platform, it will replace official Clojure CLI
with the `deps.clj` of its specific version, `latest` can be used.
Useful for running `clojure` command from `cmd.exe`.
deprecationMessage: 'No longer needed. Please remove and use unified `cli` input instead'

But I don't know what a "unified cli input" is.

Let's say I have a matrix build for macOS, Windows, and Linux, how should I select deps.exe (as clojure.exe) for windows?

@DeLaGuardo
Copy link
Owner

The latest version got a fix to run clojure tools deps on windows the same way as on other platforms. https://github.com/DeLaGuardo/setup-clojure/blob/main/.github/workflows/smoke-tests.yml#L31-L52

@lread
Copy link
Author

lread commented Jul 30, 2022

Thanks for the reply!

By cli, you mean the Clojure official Windows PowerShell module, right?

Can I still use borkdude's deps.exe (renamed to clojure) on Windows?

Or are you saying that cli automatically uses deps.exe on Windows?

(Sorry if the answer is obvious, I'm feeling a little not-so-bright here! 🙂)

@lread
Copy link
Author

lread commented Aug 1, 2022

I've never written a GitHub Action, so I am probably missing something, but I don't see anything calling getLatestDepsClj.

@DeLaGuardo
Copy link
Owner

Right, getLatestDepsClj is not used anymore. Instead, when you use input cli: %version% for windows platform, it will install official Windows PowerShell Module into the directory visible for powershell and pwsh (default shell for github action runner on windows). That means previously required option shell: powershell is not needed anymore. Run step using clojure command line will recognise correctly where binary is installed without additional options.

jobs:
  run-clojure-cli:
    strategy:
      matrix:
        # note all three available platforms
        os: [ubuntu-latest, macOS-latest, windows-latest]

    runs-on: ${{ matrix.os }}

    steps:
      - name: Prepare java
        uses: actions/setup-java@v3
        with:
          distribution: 'zulu'
          java-version: '8'

      - name: Install Clojure CLI
        uses: DeLaGuardo/[email protected]
        with:
          cli: 1.10.1.693

      # step uses clojure command is the same across all platforms
      - name: Execute clojure code
        run: clojure -e "(+ 1 1)"

@lread
Copy link
Author

lread commented Aug 8, 2022

Ah, thanks for the clarification!

I use @borkdude's deps.exe as clojure.exe to avoid many headaches on Windows.
I think the setup-clojure action was briefly offering this as an option?

Anyway, these days I can always use bb clojure on Windows instead.

@DeLaGuardo
Copy link
Owner

deps.exe was there as a workaround, yes. But the code to install it is here, so it would be easy to reintroduce it. Do you know some place where I can read about the headaches you mention? I would like to evaluate them and bring back an option to install deps.exe or find a way to avoid most problems.

@borkdude
Copy link

borkdude commented Aug 9, 2022

Another reason you might want to use deps.exe as clojure.exe is shelling out: when shelling out with ProcessBuilder or babashka.process for that matter, it just works whereas with the Powershell installation you have to write pwsh.exe -c 'clojure ...' or equivalent (not exactly sure what the command is, but you get the idea).

@DeLaGuardo
Copy link
Owner

interesting, thanks! Btw. pwsh.exe is the default shell for windows based runners, so adding pwsh.exe -c '...' should not be necessary with [email protected]

@borkdude
Copy link

borkdude commented Aug 9, 2022

Yes, I'm talking about shelling out from e.g. a clojure program or bb script, not in the Github Actions "code".

@DeLaGuardo
Copy link
Owner

got it. That sounds like a good reason to add deps.exe to the set of tools available to install. thanks!

@borkdude
Copy link

borkdude commented Aug 9, 2022

This environment variable might also be interesting:

https://github.com/borkdude/deps.clj#deps_clj_tools_version

@lread
Copy link
Author

lread commented Aug 9, 2022

Yes, what @borkdude said 🙂.
Figuring out argument escaping on Windows is difficult and made more painful when shelling out with Powershell. Capturing the exit code in these cases is also non-obvious for those who aren't Powershell experts.

If/when you do re-add deps.exe as clojure.exe on Windows, it would be extra convenient if I could express I'd like to use this on Windows without repeating a setup-clojure with a GitHub Actions if for Windows. I think your cmd-exe-workaround: would allow this if it were understood that it overrides cli:?

@DeLaGuardo
Copy link
Owner

yes, it will install clojure command overtaking the cli: input.

Btw. could you share an example of the process that is hard to grok on windows with "official powershell cli"? Then I can add it to the test suite to capture regressions, if any

@lread
Copy link
Author

lread commented Aug 9, 2022

The exit code for PowerShell launches directly from GitHub Actions is handled properly, but if you call clojure yourself from a script you have to be aware of this:

TIL, (I am powershell naive, so maybe obvious to most of you):
If you run powershell -command my-command the exit code from my-command is not returned to the caller.
For that you need tag on an exit $LASTEXITCODE, like:
powershell -command "my-command;exit $LASTEXITCODE"
Kind of important if you are wanting to know about little things like test failures.

I don't have specific examples of escaping woes, but I've felt them.

I do see an old slack post from me about me about trying to install clojure core team cli:

For what it is worth, I had a pleasant experience experimenting with @borkdude’s deps.clj (using its deps.exe) when setting up testing of rewrite-cljc on GitHub Actions on Windows. I was even bold enough to rename deps.exe to clojure.exe. I did initially try installing the official alpha Clojure PowerShell module, but GitHub Actions did not see the module, so I gave up, admittedly, rather quickly. Using a renamed deps.clj allowed me the luxury of calling clojure easily from any shell.

I think you've solved the installation part of this problem with your setup-clojure Action, but not the easily "runnable from any shell" part.

If you want a blurb for the README, maybe something like?:

cmd-exe-workaround

Some people bump into challenges using the clojure core team alpha cli on Windows because it is runnable only from Powershell. Launching a Powershell module from a script can make such things as argument escaping and exit code capturing extra tricky. For these people, we offer cmd-exe-workaround to instead install borkdude/deps.clj's deps.exe as clojure.exe when on Windows.

@DeLaGuardo
Copy link
Owner

thanks!

@lread
Copy link
Author

lread commented Aug 10, 2022

Afterthought: cmd-exe-workaround might be a bit of an odd name with the direction we seem to be going in?

Maybe: deps-exe-cli instead?

@borkdude
Copy link

or deps.clj?

@lread
Copy link
Author

lread commented Aug 10, 2022

I was thinking exe to hint it would be only active on Windows.
And cli to hint that it overrides any cli specification.
But if this holds true, maybe there is a clearer way to represent this.

Is it shortsighted of me to assume deps.clj only on Windows? Would someone find a case where they wanted to use a deps.clj binary on another OS?

@lread
Copy link
Author

lread commented Oct 13, 2022

Is it shortsighted of me to assume deps.clj only on Windows? Would someone find a case where they wanted to use a deps.clj binary on another OS?

On Slack @borkdude mentioned:

FWIW I never had anyone ask me to provide a deps.exe for a different architecture

@borkdude
Copy link

In that context, I meant Windows: not ever has someone request e.g. an aarch64 binary for deps.exe on Windows.

@lread
Copy link
Author

lread commented Oct 13, 2022

Ah, thanks! I wrongly assumed you meant that folks only used the deps binary on Windows.

@borkdude
Copy link

Well, I think that is mostly the case since deps.clj as a binary it solves a problem on Windows mostly.

@borkdude
Copy link

borkdude commented Nov 6, 2022

I think you could now try clj-msi as the workaround on Windows:

https://github.com/casselc/clj-msi/releases

This packages deps.clj as clj.exe and clojure.exe and installs it on your PATH. This might become the official installer for Clojure on Windows in the future.

@lread
Copy link
Author

lread commented Jul 28, 2024

Update: clj-msi has become the official way to install Clojure on Windows. There should be no need to install the old PowerShell modules anymore.

I'll rename this issue accordingly.

@lread lread changed the title question: what is unified cli input? Consider using the new officially sanctioned clj-msi when installing clojure on Windows Jul 28, 2024
@lread
Copy link
Author

lread commented Jul 30, 2024

@DeLaGuardo I could attempt a PR to move to the new official clojure on Windows - if you are agreeable to that.

@DeLaGuardo
Copy link
Owner

Fixed in #114

@borkdude
Copy link

Thank you!

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