Deprecated add-path

I’m trying to replace the deprecated add-path. However, while the first fragment works, the new one does not (checkout action doesn’t find git executable). What am I doing wrong here?

==== > original

- name: Setup environment (Windows)
       if: runner.os == 'Windows'
       shell: powershell
       run: |
            echo "::add-path::c:\git\bin"
            echo "::add-path::c:\git\cmd"

- uses: actions/checkout@v2
  with:
        lfs: true
        submodules: false
        fetch-depth: 0

==== > new

     - name: Setup environment (Windows)
       if: runner.os == 'Windows'
       run: |
              echo "c:\git\bin" >> $GITHUB_PATH
              echo "c:\git\cmd" >> $GITHUB_PATH

     - uses: actions/checkout@v2
       with:
          lfs: true
          submodules: false
          fetch-depth: 0
1 Like

Hey @w3sip,

Can you please try

run: |
  echo "c:\git\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
  echo "c:\git\cmd" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8

You may also choose to checkout our docs which list how to do this in powershell

There was a similar topic recently which may be helpful, see Migration from deprecated add-path on windows

That does not seem to work.

EDIT: got it going with
echo "c:\cmake-3.18\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8

Two suggestions:

  1. In both forum posts, the solution doesn’t include -Append. At the same time, Unix shell examples and docs are shown with >>. For those of us not familiar with Powershell, making a note of that may be useful.
  2. The docs suggest the Powershell way only in context of UTF8 encoding. In fact, this form seems to be the only way to get things going on Windows. May want to make a note of that, too.
1 Like

Hey @w3sip, I apologize I forgot to add the -Append flag, if you add that it should work.

Take a look at the following workflow

name: CI
on:
  push
jobs:
  test:
    runs-on: windows-latest 
    steps:
     - run: |
         echo "c:\git\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
         echo "c:\git\cmd" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
     - run: $env:PATH

You can see it gets added to the path.

I’ll get our docs updated so others don’t run into this issue!

1 Like

Ha, you beat me to it! Thanks!