actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.92k stars 969 forks source link

Self-Hosted Runner using Window's find.exe instead of unix-style find.exe in git bin #786

Open dskvr opened 4 years ago

dskvr commented 4 years ago

Describe the bug Receive the following error when trying to use find

"FIND: Parameter format not correct"

When opening Git Bash and running the same code, it executes as expected.

To Reproduce find . -type f -name *.tar.gz

Expected behavior For the unix style script to work.

Runner Version and Platform

Runner Version: 2.273.6 OS: Windows 10 (current)

What's not working?

find

I tried to look into how a runner sets up its environment variables but there was no documentation on the subject.

TingluoHuang commented 4 years ago

@dskvr can you try the following?

dskvr commented 4 years ago

Edit: Updated results from correct platform.

Explicitly Set (because other workflows are cmd, maintainer communications)

defaults:
  run:
    shell: bash

The following

    - shell: cmd
      run: ECHO %PATH%
    - run: |
       echo "Path: $PATH"
       echo "Where: $(where find)"
       echo "Which: $(which find)"

Produced

# bash shell in runnner
Run ECHO %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git LFS;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\Amazon\AWSCLI\bin\;C:\Program Files\7-Zip;C:\Users\***\AppData\Local\Programs\Python\Python38-32\Scripts\;C:\Users\***\AppData\Local\Programs\Python\Python38-32\;C:\Users\***\AppData\Local\Microsoft\WindowsApps;C:\Users\***\AppData\Local\GitHubDesktop\bin
0s
Run echo "Path: $PATH"
Path: /c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files/Git LFS:/cmd:/mingw64/bin:/usr/bin:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/Microsoft Windows Performance Toolkit:/c/Program Files/Amazon/AWSCLI/bin:/c/Program Files/7-Zip:/c/Users/***/AppData/Local/Programs/Python/Python38-32/Scripts:/c/Users/***/AppData/Local/Programs/Python/Python38-32:/c/Users/***/AppData/Local/Microsoft/WindowsApps:/c/Users/***/AppData/Local/GitHubDesktop/bin
Where: C:\Windows\System32\find.exe
C:\Program Files\Git\usr\bin\find.exe
Which: /c/Windows/system32/find
TingluoHuang commented 4 years ago

@dskvr what if you open the git-bash and print out $PATH? I assume it modifies the environment. Sorry, I don't have a windows machine around.

dskvr commented 4 years ago

Reminder: find works correctly when directly called from git bash on runner.

# git bash terminal on runner 
$ echo "Path: $PATH"
Path: /c/Users/***/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/***/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files/Git LFS:/cmd:/mingw64/bin:/usr/bin:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/Microsoft Windows Performance Toolkit:/c/Program Files/Amazon/AWSCLI/bin:/c/Program Files/7-Zip:/c/Users/***/AppData/Local/Programs/Python/Python38-32/Scripts:/c/Users/***/AppData/Local/Programs/Python/Python38-32:/c/Users/***/AppData/Local/Microsoft/WindowsApps:/c/Users/***/AppData/Local/GitHubDesktop/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

$ echo "Where: $(where find)"
Where: C:\Program Files\Git\usr\bin\find.exe
C:\Windows\System32\find.exe

$ echo "Which: $(which find)"
Which: /usr/bin/find

So it appears that the path is flipped around. Potentially similar to cygwin issue mentioned here?

Sorry, I don't have a windows machine around.

No worries

dskvr commented 3 years ago

@TingluoHuang Has there been any developments on this? Curious if it's replicable. I spun up a new runner and the same thing is happening. I'm calling the full path directly as a workaround (windows only), but it makes a mess of things in the multi-platform matrix.

virzak commented 1 year ago

I might have had a similar issue with act.

Act on windows picks up wsl bash instead of git bash.

I wrote to GITHUB_PATH and stuff worked for me.

- name: Set path for nektos/act
  if: ${{ runner.os  == 'Windows' && env.ACT }}
  run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
  shell: '"C:\Program Files\Git\bin\bash.exe" -c {0}'