Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to locate executable file: powershell #552

Open
2 of 5 tasks
dwisiswant0 opened this issue Feb 10, 2025 · 4 comments
Open
2 of 5 tasks

Unable to locate executable file: powershell #552

dwisiswant0 opened this issue Feb 10, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@dwisiswant0
Copy link

Description:

Failed to download version 1.18.10: Error: Unable to locate executable file: powershell.

Action version:
Specify the action version

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

go1.18.x

Repro steps:

      - uses: actions/setup-go@v5
        with:
          go-version-file: 'go.mod'
          check-latest: true
          cache: true

Expected behavior:

Successfully set up Go.

Actual behavior:

Setup go version spec 1.18
Attempting to resolve the latest version from the manifest...
matching 1.18...
Resolved as '1.18.10'
Attempting to download 1.18.10...
matching 1.18.10...
Acquiring 1.18.10 from https://github.com/actions/go-versions/releases/download/1.18.10-3890634278/go-1.18.10-win32-x64.zip
Extracting Go...
Unable to locate executable file: powershell. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
Falling back to download directly from Go
Install from dist
Acquiring go1.18.10 from https://storage.googleapis.com/golang/go1.18.10.windows-amd64.zip
Extracting Go...
Error: Failed to download version 1.18.10: Error: Unable to locate executable file: powershell. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
@dwisiswant0 dwisiswant0 added bug Something isn't working needs triage labels Feb 10, 2025
@suyashgaonkar
Copy link

Hi @dwisiswant0, Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.

@gowridurgad
Copy link

Hi @dwisiswant0, After trying to replicate the issue based on provided workflow, it appears that everything is functioning correctly and were able to install Go version 1.18.10 successfully without encountering any errors on our end. Here's a screenshot for your reference.
To assist further, could you please share a link to the build or public repository where the issue can be reproduced? This will help us investigate the problem in detail.

Image

@dwisiswant0
Copy link
Author

@gowridurgad
Copy link

Hi @dwisiswant0, The issue you're encountering is related to how environment variables, particularly the PATH, are handled during the workflow execution. In the Build PCRE2 on Windows step, you modify the PATH environment variable within PowerShell (pwsh) to include the build directory. However, this change may not propagate correctly to subsequent steps, such as the setup-go action, which relies on PowerShell being correctly set in the environment.
Specifically, the setup-go action failed to locate PowerShell because it wasn't properly included in the PATH after the PCRE2 build step. This is often due to differences in how environment variables are set in different shells and how they propagate across steps.
To resolve this issue, please ensure that PowerShell is added to the PATH before running any steps that might depend on it. This can be done by adding a step that modifies the PATH to include the directory where PowerShell is installed.
The following step ensures that PowerShell is available to all subsequent steps, including the setup-go action:

- name: Add PowerShell to PATH
  if: runner.os == 'Windows'
  run: |
    $env:PATH = "$env:ProgramFiles\PowerShell\7;" + $env:PATH
    Write-Output "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8

Attached is a screenshot of the workflow successfully completing the setup-go action after implementing the fix:
If any further clarification is needed or additional issues arise, feel free to reach out.

Image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants