microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.5k stars 2.61k forks source link

[BUG]: AzureStaticWebApp@0 throws "Unable to locate executable file: 'bash' " on self-hosted agent on windows #19447

Open MichaelPruefer opened 9 months ago

MichaelPruefer commented 9 months ago

New issue checklist

Task name

AzureStaticWebApp@0

Task version

0.228.0

Issue Description

When running this task it throws:

Unable to locate executable file: 'bash'. 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.

This running inside a release-pipeline and not inside a build-pipeline

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows 10

Relevant log output

2024-01-16T07:24:33.3949780Z ##[section]Starting: Deploy to Static Web App:
2024-01-16T07:24:33.4125550Z ==============================================================================
2024-01-16T07:24:33.4126107Z Task         : Deploy Azure Static Web App
2024-01-16T07:24:33.4126484Z Description  : [PREVIEW] Build and deploy an Azure Static Web App
2024-01-16T07:24:33.4126822Z Version      : 0.228.0
2024-01-16T07:24:33.4127132Z Author       : Microsoft Corporation
2024-01-16T07:24:33.4127476Z Help         : https://aka.ms/swadocs
2024-01-16T07:24:33.4127874Z ==============================================================================
2024-01-16T07:24:36.2903179Z ##[error]Error: Unable to locate executable file: 'bash'. 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.
2024-01-16T07:24:36.2920285Z ##[warning]Unable to delete env file
2024-01-16T07:24:36.3007707Z ##[section]Finishing: Deploy to Static Web App:

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

steps:
- task: AzureStaticWebApp@0
  displayName: 'Deploy to Static Web App:'
  inputs:
    app_location: '$(System.DefaultWorkingDirectory)/web'
    output_location: wwwroot
    skip_app_build: true
    skip_api_build: true
    is_static_export: true
    verbose: true
    azure_static_web_apps_api_token: '...'
Cadey commented 2 months ago

Im still getting this error on 0.243.1

Starting: AzureStaticWebApp

Task : Deploy Azure Static Web App Description : [PREVIEW] Build and deploy an Azure Static Web App Version : 0.243.1 Author : Microsoft Corporation Help : https://aka.ms/swadocs

[error]Error: Unable to locate executable file: 'bash'. 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.

[warning]Unable to delete env file

Finishing: AzureStaticWebApp

RutgerRauws commented 1 month ago

I'm experiencing the same issue.

For future readers: I have worked around this issue by creating a new build agent running in Windows Subsystem for Linux (WSL) and then running the task there.

First install WSL by running PowerShell as administrator:

wsl --install

Now reboot your system and continue:

wsl --install -d Ubuntu
wsl --set-default Ubuntu
wsl
mkdir agent ; cd agent
wget https://vstsagentpackage.azureedge.net/agent/3.245.0/vsts-agent-linux-x64-3.245.0.tar.gz
tar zxvf ./vsts-agent-linux-x64-3.245.0.tar.gz && rm ./vsts-agent-linux-x64-3.245.0.tar.gz
./config.sh
./run.sh

Then, add in your azure-pipelines.yml under the relevant job where you call AzureStaticWebApp@0:

  pool:
    name: Default
    demands:
    - Agent.Name -equals AGENT_NAME

where AGENT_NAME is the name you provided when running ./config.sh

Cadey commented 1 month ago

Well, thats one way i guess, but this really needs to be fixed properly sonit just works with a basic install of the agent in windows.

Its not a lot to ask

Cadey commented 1 week ago

How is this still an issue?

Starting: AzureStaticWebApp
==============================================================================
Task         : Deploy Azure Static Web App
Description  : [PREVIEW] Build and deploy an Azure Static Web App
Version      : 0.247.1
Author       : Microsoft Corporation
Help         : https://aka.ms/swadocs
==============================================================================
##[error]Error: Unable to locate executable file: 'bash'. 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.
##[warning]Unable to delete env file
Finishing: AzureStaticWebApp
lzandman commented 6 days ago

Besides the requirement for Bash it also seems to require Docker. Why is that? We don't want the Docker client on our self-hosted Windows agents.