Powershell: Startup crash because /proc/stat in inaccessible in Android (accessing boot time required?)

Created on 2 Aug 2019  路  3Comments  路  Source: PowerShell/PowerShell

Powershell currently crashes because it's trying to get the computer boot time, which can be unavailable (for example on Android). I don't see having access to the computer boot time being a requirement to launch powershell, this could either record the boot time as unavailable or crash when we actually need that value.

Steps to reproduce

  1. Setup a Linux distribution on Android (I used Debian 9 on Android 8 arm 64 using UserLAnd)
  2. Follow the instructions at https://docs.microsoft.com/en-us/powershell/scripting/install/powershell-core-on-arm?view=powershell-6 (I replaced arm32 by
  3. Run pwsh

Expected behavior

Get a powershell prompt

Actual behavior

FailFast:
Access to the path '/proc/stat' is denied. 
    at System.Environment.FailFast(System.String, System.Exception)                                 
    at Internal.Runtime.Augments.EnvironmentAugments.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[])

Exception details:
System.UnauthorizedAccessException: Access to the path '/proc/stat' is denied. ---> System.IO.IOException: Permission denied
    --- End of inner exception stack trace ---
    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) 
    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)    at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) 
    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) 
    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks) 
    at System.IO.File.InternalReadAllText(String path, Encoding encoding) 
    at System.IO.File.ReadAllText(String path) 
    at System.Diagnostics.Process.get_BootTime()
    at System.Diagnostics.Process.BootTimeToDateTime(TimeSpan timespanAfterBoot)
    at System.Diagnostics.Process.get_StartTimeCore()
    at System.Diagnostics.Process.get_StartTime()   
    at Microsoft.PowerShell.ConsoleHost.DoCreateRunspace(String initialCommand, Boolean skipProfiles, Boolean staMode, String configurationName, Collection`1 initialCommandArgs) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1618                             
    at Microsoft.PowerShell.ConsoleHost.CreateRunspace(Object runspaceCreationArgs) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1506                           
    at Microsoft.PowerShell.ConsoleHost.DoRunspaceLoop(String initialCommand, Boolean skipProfiles, Collection`1 initialCommandArgs, Boolean staMode, String configurationName) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1421                               
    at Microsoft.PowerShell.ConsoleHost.Run(CommandLineParameterParser cpp, Boolean isPrestartWarned) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1383         

    at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText, String[] args) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1
    at Microsoft.PowerShell.ConsoleShell.Start(String bannerText, String helpText, String[] args) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs:line 299
    at Microsoft.PowerShell.UnmanagedPSEntry.Start(String consoleFilePath, String[] args, Int32 argc) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs:line 72    
Aborted

Environment data

N/A

Issue-Question Resolution-Fixed

Most helpful comment

Hey, I just wanted to let you know that after this, I can the successfully launch PowerShell on arm64 using UserLAnd. Thanks!

All 3 comments

Looks like that call is unnecessary and that data isn't being used. Will make a fix.

:tada:This issue was addressed in #10294, which has now been successfully released as v7.0.0-preview.3.:tada:

Handy links:

Hey, I just wanted to let you know that after this, I can the successfully launch PowerShell on arm64 using UserLAnd. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SteveL-MSFT picture SteveL-MSFT  路  3Comments

pcgeek86 picture pcgeek86  路  3Comments

rudolfvesely picture rudolfvesely  路  3Comments

manofspirit picture manofspirit  路  3Comments

andschwa picture andschwa  路  3Comments