Giter Club home page Giter Club logo

Comments (23)

borkdude avatar borkdude commented on May 28, 2024 1

This environment variable might also be interesting:

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

from setup-clojure.

lread avatar lread commented on May 28, 2024 1

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.

from setup-clojure.

borkdude avatar borkdude commented on May 28, 2024 1

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

from setup-clojure.

DeLaGuardo avatar DeLaGuardo commented on May 28, 2024

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

from setup-clojure.

lread avatar lread commented on May 28, 2024

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! 🙂)

from setup-clojure.

lread avatar lread commented on May 28, 2024

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

from setup-clojure.

DeLaGuardo avatar DeLaGuardo commented on May 28, 2024

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)"

from setup-clojure.

lread avatar lread commented on May 28, 2024

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.

from setup-clojure.

DeLaGuardo avatar DeLaGuardo commented on May 28, 2024

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.

from setup-clojure.

borkdude avatar borkdude commented on May 28, 2024

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).

from setup-clojure.

DeLaGuardo avatar DeLaGuardo commented on May 28, 2024

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]

from setup-clojure.

borkdude avatar borkdude commented on May 28, 2024

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

from setup-clojure.

DeLaGuardo avatar DeLaGuardo commented on May 28, 2024

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

from setup-clojure.

lread avatar lread commented on May 28, 2024

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:?

from setup-clojure.

DeLaGuardo avatar DeLaGuardo commented on May 28, 2024

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

from setup-clojure.

DeLaGuardo avatar DeLaGuardo commented on May 28, 2024

thanks!

from setup-clojure.

lread avatar lread commented on May 28, 2024

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?

from setup-clojure.

borkdude avatar borkdude commented on May 28, 2024

or deps.clj?

from setup-clojure.

lread avatar lread commented on May 28, 2024

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?

from setup-clojure.

lread avatar lread commented on May 28, 2024

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

from setup-clojure.

borkdude avatar borkdude commented on May 28, 2024

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

from setup-clojure.

lread avatar lread commented on May 28, 2024

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

from setup-clojure.

borkdude avatar borkdude commented on May 28, 2024

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.

from setup-clojure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.