TransWikia.com

How to get the install path of ImageMagick using Chocolately on GitHub Actions/CI?

Super User Asked on December 20, 2021

So I have this error: Getting "Invalid Parameter – -fuzz" on ImageMagick convert command on Windows 10, because ImageMagick isn’t in the PATH properly on Windows.

The problem now is, how do I programmatically grab the installed executable path so I can run it directly? It turns out that chocolatey requires PAID SUBSCRIPTION to enable this feature, lame. So how else can I accomplish this?

I am doing this with GitHub CI / Actions, so I don’t have the ability to visually look at it and configure it, it needs to be found and used entirely programmatically. How can I do this?

2 Answers

I had the same problem on github actions. The solution turned out to be using refreshenv as you might expect, but with a small caveat: You have to call it within the same step where you want to use the installed program, and be sure to invoke it via call, e.g.:

  - run: choco install -y imagemagick
  - name: Build icons
    shell: cmd
    run: |
      call refreshenv
      magick ...
      magick ...

If you have multiple steps that want to reuse the PATH configuration, you can call refreshenv once and export it as follows:

  - run: choco install -y imagemagick
  - name: Set PATH
    shell: cmd
    run: |
      call refreshenv
      echo ::set-env name=PATH::%PATH%
  - run: magick
  - run: magick

Finally, if you're interested in the installation path itself, you can resort to trickery such as this:

  - run: choco install -y imagemagick

  - name: Extract path
    id: getpath
    shell: cmd
    run: |
      call refreshenv
      for /f "delims=" %%G in ('where magick') do (
          echo ::set-env name=MAGICKPATH::%%~fG
          echo ::set-output name=magick::%%~fG
      )

  - run: echo $env:MAGICKPATH
  - run: echo ${{ steps.getpath.outputs.magick }}

Answered by Thomas G. on December 20, 2021

Instead of getting the install directory you may be able to set it, even with the free version.

According to Chocolately's documentation you can change the installation directory ... even in Chocolatey open source.

Different installer types (eg. MSI, NSIS...) have different methods to receive what Chocolately refers to as "installation arguments". In the free version you need to specify these natively for each installer type (using the -ia option) whereas the paid version provides a streamlined "ubiquitous" method.

Answered by Mike Fitzpatrick on December 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP