Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Agent unable to find location of pwsh for PowerShell task - works in Hosted build #1862

Closed
TylerLeonhardt opened this issue Oct 2, 2018 · 16 comments
Assignees

Comments

@TylerLeonhardt
Copy link
Member

Have you tried trouble shooting?

Trouble shooting doc

Yes.

Agent Version and Platform

Version of your agent? v2.141.0

OS of the machine running the agent? Raspbian Linux ARM

VSTS Type and Version

VisualStudio.com or On-Prem TFS? VisualStudio.com

If VisualStudio.com, what is your account name? http://mtntop.visualstudio.com

What's not working?

Given the following yml definition:

queue:
  name: RaspberryPis
steps:
- script: 'pwsh -c "Write-Host 'Hello World'"' 
  displayName: 'Command Line Script'

- powershell: 'Write-Host "Hello World"' 
  displayName: 'PowerShell Script'

Running on a Raspberry Pi that has PowerShell installed and symlinked to /usr/bin.

The first step passes - it's able to resolve the pwsh and run it. No problem.

The second step fails with:

Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

From the logs below it looks like an issue with reading for which.

NOTE: This build passes completely in the hosted vsts linux preview.

Agent and Worker's Diagnostic Logs

Logs are located in the agent's _diag folder. The agent logs are prefixed with Agent_ and the worker logs are prefixed with Worker_. All sensitive information should already be masked out, please double check before pasting here.

Diagnostic from Azure Pipelines build run:

2018-10-02T18:46:42.8780796Z ##[debug]Evaluating condition for step: 'PowerShell Script'
2018-10-02T18:46:42.8783690Z ##[debug]Evaluating: succeeded()
2018-10-02T18:46:42.8784925Z ##[debug]Evaluating succeeded:
2018-10-02T18:46:42.8786658Z ##[debug]=> True
2018-10-02T18:46:42.8788476Z ##[debug]Result: True
2018-10-02T18:46:42.8790132Z ##[section]Starting: PowerShell Script
2018-10-02T18:46:42.8808019Z ==============================================================================
2018-10-02T18:46:42.8808922Z Task         : PowerShell
2018-10-02T18:46:42.8809609Z Description  : Run a PowerShell script on Windows, macOS, or Linux.
2018-10-02T18:46:42.8810360Z Version      : 2.136.0
2018-10-02T18:46:42.8811010Z Author       : Microsoft Corporation
2018-10-02T18:46:42.8811721Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2018-10-02T18:46:42.8812464Z ==============================================================================
2018-10-02T18:46:43.4858352Z ##[debug]agent.workFolder=/home/pi/myagent/_work
2018-10-02T18:46:43.4987737Z ##[debug]loading inputs and endpoints
2018-10-02T18:46:43.5017033Z ##[debug]loading INPUT_TARGETTYPE
2018-10-02T18:46:43.5066356Z ##[debug]loading INPUT_FILEPATH
2018-10-02T18:46:43.5081637Z ##[debug]loading INPUT_SCRIPT
2018-10-02T18:46:43.5090290Z ##[debug]loading INPUT_ERRORACTIONPREFERENCE
2018-10-02T18:46:43.5098646Z ##[debug]loading INPUT_FAILONSTDERR
2018-10-02T18:46:43.5106858Z ##[debug]loading INPUT_IGNORELASTEXITCODE
2018-10-02T18:46:43.5114897Z ##[debug]loading INPUT_WORKINGDIRECTORY
2018-10-02T18:46:43.5123657Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-10-02T18:46:43.5134411Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-10-02T18:46:43.5142618Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-10-02T18:46:43.5157994Z ##[debug]loaded 10
2018-10-02T18:46:43.5270675Z ##[debug]check path : /home/pi/myagent/_work/_tasks/PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1/2.136.0/task.json
2018-10-02T18:46:43.5281605Z ##[debug]set resource file to: /home/pi/myagent/_work/_tasks/PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1/2.136.0/task.json
2018-10-02T18:46:43.5285605Z ##[debug]system.culture=en-US
2018-10-02T18:46:43.5383307Z ##[debug]errorActionPreference=stop
2018-10-02T18:46:43.5406967Z ##[debug]failOnStderr=false
2018-10-02T18:46:43.5414964Z ##[debug]ignoreLASTEXITCODE=false
2018-10-02T18:46:43.5428785Z ##[debug]workingDirectory=/home/pi/myagent/_work/1/s
2018-10-02T18:46:43.5431933Z ##[debug]check path : /home/pi/myagent/_work/1/s
2018-10-02T18:46:43.5444314Z ##[debug]targetType=inline
2018-10-02T18:46:43.5455525Z ##[debug]script=Write-Host "Hello World"
2018-10-02T18:46:43.5591033Z Generating script.
2018-10-02T18:46:43.5604411Z ##[debug]Agent.Version=2.141.0
2018-10-02T18:46:43.5606348Z ##[debug]agent.tempDirectory=/home/pi/myagent/_work/_temp
2018-10-02T18:46:43.5609542Z ##[debug]check path : /home/pi/myagent/_work/_temp
2018-10-02T18:46:43.5723544Z ##[debug]which 'pwsh'
2018-10-02T18:46:43.5760756Z ##[debug]not found
2018-10-02T18:46:43.5767110Z ##[debug]which 'powershell'
2018-10-02T18:46:43.5773661Z ##[debug]not found
2018-10-02T18:46:43.5778974Z ##[debug]which 'pwsh'
2018-10-02T18:46:43.5788269Z ##[debug]not found
2018-10-02T18:46:43.5807700Z ##[debug]task result: Failed
2018-10-02T18:46:43.6116303Z ##[error]Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2018-10-02T18:46:43.6171838Z ##[debug]Processed: ##vso[task.issue type=error;]Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2018-10-02T18:46:43.6243846Z ##[debug]Processed: ##vso[task.complete result=Failed;]Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2018-10-02T18:46:43.6251017Z ##[section]Finishing: PowerShell Script

Related Repositories

Please ensure you are logging issues to the correct repository in order to get the best support.

  • Tasks Repository - contains all of the inbox tasks we ship with VSTS/TFS. If you are having issues with tasks in Build/Release jobs (e.g. unreasonable task failure) please log an issue here.
  • Hosted Agent Image Repository - contains the VM image used in the VSTS Hosted Agent Pool. If you are having Build/Release failures that seems like they are related to software installed on the Hosted Agent (e.g. the DotnetSDK is missing or the AzureSDK is not on the latest version) please log an issue here.

If you are hitting a generic issue about VSTS/TFS, please report it to the Developer Community

@TylerLeonhardt
Copy link
Member Author

p.s. here are the logs
logs.log

@ericsciple
Copy link
Contributor

what is the value of your PATH environment variable?

@ericsciple ericsciple self-assigned this Oct 2, 2018
@TylerLeonhardt
Copy link
Member Author

It's this:
/home/pi/powershell:/usr/local/bin:/usr/bin:/bin:/usr/games

and

/usr/bin/pwsh exists

@ericsciple
Copy link
Contributor

is the executable bit set?

@ericsciple
Copy link
Contributor

...on /usr/bin/pwsh?

@TylerLeonhardt
Copy link
Member Author

TylerLeonhardt commented Oct 2, 2018

It is:

> ls -l /usr/bin/pwsh
lrwxrwxrwx 1 root root 24 Sep 20 15:24 /usr/bin/pwsh -> /home/pi/powershell/pwsh

@TingluoHuang
Copy link
Contributor

i guess this is because of the symlink you have.
https://github.com/Microsoft/vsts-task-lib/blob/master/node/internal.ts#L431

@ericsciple
Copy link
Contributor

is the executable set on /home/pi/powershell/pwsh ?

@TylerLeonhardt
Copy link
Member Author

@ericsciple ah... it wasn't. Good catch. Setting the permissions of that file to 777 worked. Do you have a recommendation of allowing just enough access to pwsh? So I don't have to give everything permission to do anything? 😄

@TingluoHuang
Copy link
Contributor

@tylerl0706 i guess 755 is better than 777, everyone can use powershell, but they can't modify the file.

@ericsciple
Copy link
Contributor

@tylerl0706 thanks for reporting this. It's interesting that from your script, bash resolves and runs pwsh, but our task fail's to. I'll log a bug in the task repo.

Regarding permissions, what Ting said makes sense to me.

@TylerLeonhardt
Copy link
Member Author

Sounds good! I'll leave it to you to close this issue when you see fit - now or after opening an issue in task repo

@ericsciple
Copy link
Contributor

@damccorm @stephenmichaelf this sounds like a bug in the task lib which function

@ericsciple
Copy link
Contributor

@damccorm fyi you may want to update the release notes doc in the task lib to mention the bug fix

@damccorm
Copy link

damccorm commented Feb 6, 2019

Sounds good. I'm going to close here since the work for this is done and tracked in the task-lib. Please reopen if appropriate.

@damccorm damccorm closed this as completed Feb 6, 2019
@aminya
Copy link

aminya commented Jul 14, 2020

I get this error too on vmimage: ubuntu-16.04, container: ubuntu:trusty. Is there a solution for this?

  - pwsh: |
      echo $env:BUILD_ARCH

https://dev.azure.com/atomcommunity/atomcommunity/_build/results?buildId=215&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb&t=22a6417f-f1f1-569d-79c7-25fb0b9a3098&l=11

How did it solve?

Edit: it was a container issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants