megha
megha

Reputation: 833

bash task in Azure Devops not working on self hosted windows agent

Bash task is giving below error when running on self hosted windows agent -

Windows Subsystem for Linux has no installed distributions.

##[error]The process 'C:\Windows\system32\bash.exe' failed with exit code 1

Windows subsystem is installed and I can execute bask scripts by logging into agent but bash task does not work.

Happy to provide more information if required

Upvotes: 1

Views: 2685

Answers (1)

Leo Liu
Leo Liu

Reputation: 76920

bash task in Azure Devops not working on self hosted windows agent

That is because the WSL installed per a specific user, but if we run the self-hosted agent as service, it will using the NETWORK SERVICE/SYSTEM account instead of local user account.

You could try to set Log On As with the specific user (It should be the same user as you installed WSL. Then restart your server.

Detailed step for setting the Log On As with the specific user:

  1. Press the Win + R keys on your keyboard, to open the Run window. Then, type “services.msc” and hit Enter or press OK.
  2. Find the service for the self-hosted agent and right click it, select Properties, switch to Log On tab.
  3. Change the account to the specific user.

For example, I use xxxxxx\leoliu account to login the server 2019:

enter image description here

Then install WSL with that account. After that, I open the services.msc and change the Log On As with that user:

enter image description here

Last but not least, restart your server, just restart the services is not enough.

Now, I could use my self-hosted agent to run the bask task:

enter image description here

Upvotes: 1

Related Questions