Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Pilot Lvl 1
Message 1 of 9

Append PATH on Windows

Solved! Go to Solution.

I'm trying to install https://scoop.sh/, but I fail to add it to the PATH environment variable for subsequent steps. I tried:

 

set PATH=C:\Users\runneradmin\scoop\shims;%PATH%

 

 

and

 

[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)

(with a modified $env:Path).

 

When I print the PATH variable in the next step, it always remains unchanged. What's the correct way to do this?

8 Replies
Highlighted
Solution
GitHub Staff
Message 2 of 9

Re: Append PATH on Windows

Each step is run its own process space so environment changes do not automatically propgate.  If you want to update the path you can use the `add-path` command as documented https://help.github.com/en/articles/development-tools-for-github-actions#add-a-system-path-add-path.  

Highlighted
Pilot Lvl 1
Message 3 of 9

Re: Append PATH on Windows

Thanks a lot, this worked without problems!

 

I saw this page before but somehow thought that it only applied to the Node.js toolkit.

Highlighted
Copilot Lvl 2
Message 4 of 9

Re: Append PATH on Windows

The cited documentation suggests the modification is seen by all subsequent steps in the job.  So it would seem at odds with your assertion that each step is its own process.

 

I've not been able to get `::add-path::/path/to/dir` to augment PATH, either within the step or within the job.  Would appreciate sample yaml that augments the PATH variable, as the documentation offers none.

Highlighted
Copilot Lvl 2
Message 5 of 9

Re: Append PATH on Windows

It seems like the correct way on Windows is (contrary to the doc):

      - name: Add strawperryperl to the PATH to override the existing Perl installation so we can compile OpenSSL locally
        run: echo "##[add-path]C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin"
        if: matrix.os == 'windows'
Highlighted
Copilot Lvl 3
Message 6 of 9

Re: Append PATH on Windows

Hi, Is there any documentation about this windows add-path style? From the offical docs, I couldn't find it.

Highlighted
Copilot Lvl 3
Message 7 of 9

Re: Append PATH on Windows


@D4nte wrote:

It seems like the correct way on Windows is (contrary to the doc):

      - name: Add strawperryperl to the PATH to override the existing Perl installation so we can compile OpenSSL locally
        run: echo "##[add-path]C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin"
        if: matrix.os == 'windows'

Hi, Is there any documentation about this windows add-path style? From the offical docs, I couldn't find it.

Highlighted
Copilot Lvl 2
Message 8 of 9

Re: Append PATH on Windows

Ultimately had to monkey at the typescript level https://github.com/dickmao/setup-paths to change PATH.

Copilot Lvl 3
Message 9 of 9

Re: Append PATH on Windows

Each step is run its own process space so environment changes do not automatically propgate.  If you want to update the path you can use the `add-path` command as documented https://help.github.com/en/articles/development-tools-for-github-actions#add-a-system-path-add-path.  

 

Your link as countless others out there for the GitHub actions documentation are all dead.