Skip to content

Failure when being run with no PATH variable #5019

Closed

Description

CentOS 7.2, Powershell Core 6 Beta 8.

I'm attempting to call just a basic Powershell command (/usr/bin/powershell -Command "& {Write-Output 'Hello, world'}") in a script that is run by a software agent. No matter how the simple command (or PS1) file is passed, the error results similarly:

FailFast: Object reference not set to an instance of an object.

at System.Environment.FailFast(System.String, System.Exception)
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String, System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
/tmp/f1cbae6e-1431-4ae9-b63c-d40c007de59e/task.sh: line 3: 2366 Aborted /usr/bin/powershell -Command "& {Write-Output 'Hello, world'}"
Error while executing script: Process exited with an error: 134 (Exit value: 134)

Prepending this command with strace -v yields the following output.
https://www.dropbox.com/s/4upjmfrf6x2zn8h/ps-coretask.stdlog?dl=0

After getting some help on the powershell-help channel on Slack, a review of the output as linked above showed no environmental variables being passed (HOME, USER, or PATH). This script is executed as root via an agent. Even passing the command as HOME=/root /usr/bin/powershell -Command "& {Write-Output 'Hello, world'}" still produces failure with the same message as shown above.

However, when manually logging into the system as root and executing either a PS1 script or this simple command, the result is always successful. An example of a successful strace -v dump from such an attempt can be found here. (Both of the strace dumps are too large for Pastebin and would flood this thread.)
https://www.dropbox.com/s/bfsxqfrndrd0yvp/strace-good-dump.txt?dl=0

Please let me know what other forensics I can provide that would be of assistance in isolating this issue and possibly determining a viable workaround.

Activity

  1. added this to the milestone on Oct 5, 2017
  2. SteveL-MSFT commented on Oct 5, 2017

    @SteveL-MSFT
    Member

    Not having HOME defined is explicitly handled, but the problem looks like PATH is causing the problem.

    unset PATH
    powershell

    I'll work on a fix.

  3. chipzoller commented on Oct 5, 2017

    @chipzoller
    Author

    Thanks very much. By setting PATH preceding the command, it does execute successfully. Thanks to Mark Kraus (@markekraus) especially for steps to produce the verbose output.

  4. changed the title [-]Failure when being run with no HOME variable[/-] [+]Failure when being run with no PATH variable[/+] on Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Resolution-Fixed

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions