You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error loading pwsh when home directory is Read Only. #6675
NOTE: Only validated this on a Linux host, but suspect it would be the same on Windows.
- Logon to a Linux endpoint.
- Set the HOME env var to a RO location (Read or Read/Execute).
- Launch pwsh
Interestingly, this seems to be caused by the fact that the PSREADLINE history file cannot be written. However, if this is the case, the failure should be graceful and not halt the shell. Further, the exception thrown is not indicative of the reason why pwsh is not loading.
Expected behavior
pwsh should load as exected.
Actual behavior
Receive the following error:
The shell cannot be started. A failure occurred during initialization:
The static PrimaryRunspace property can only be set once, and has already been set.
Environment data
Name Value
---- -----
PSVersion 6.0.0
PSEdition Core
GitCommitId v6.0.0
OS Linux 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Dec 28 14:23:39 EST 2017
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I'm may be misunderstanding this. So, before using pwsh, you're setting the user home to read / read execute. Why not leaving it system default permission for the user(s)?
We are having the user's home locked down. Eg. not writable by the user - this is a common approach for enterprises. That is just to provide repro steps.
Sure thing. Another related problem (probably a separate issue in github) is the visibility of the files - both .cache and .local and all the files below has a filemask of 775/664 instead of 700/600. This opens a can of worms when comes to security.
Thank You for sharing! I'm getting to learn more about Linux after PowerShell became Open Source.
I'll be checking this post. I know some of the PowerShell Team will post something. They good in responding.
:)
cc: Steve Lee (@SteveL-MSFT)
I tried this on Ubuntu and macOS and although I get errors from PSReadline complaining it can't write to the history file, pwsh still works. Can you try 6.1.0-Preview1?
On a service account user (with no writeable home), running interactively works:
sudo -u svc_user -s pwsh
PowerShell v6.1.0-preview.1
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /root>exit
Error reading or writing history file '/root/.local/share/powershell/PSReadLine/ConsoleHost_history.txt': Access to the path '/root/.local/share/powershell/PSReadLine/ConsoleHost_history.txt' is denied.
That error message is about the not being able to write to the history file, but it doesn't prevent pwsh from being able to run.
Activity
MaximoTrinidad commentedon Apr 18, 2018
Hum!! Which Linux distro you're using? Redhat, Ubuntu, Kali..
Also, have you try it with the latest version available for download? 6.1.0-preview.1
:)
psmulovics commentedon Apr 18, 2018
This with RHEL7, using the official 6.0.0 package
MaximoTrinidad commentedon Apr 18, 2018
I'm may be misunderstanding this. So, before using pwsh, you're setting the user home to read / read execute. Why not leaving it system default permission for the user(s)?
:)
psmulovics commentedon Apr 18, 2018
We are having the user's home locked down. Eg. not writable by the user - this is a common approach for enterprises. That is just to provide repro steps.
MaximoTrinidad commentedon Apr 18, 2018
Ah! Gotcha!!
MaximoTrinidad commentedon Apr 18, 2018
I haven't try it at that level of security (yet). Interesting!
Thanks for providing this point of view.
:)
psmulovics commentedon Apr 18, 2018
Sure thing. Another related problem (probably a separate issue in github) is the visibility of the files - both .cache and .local and all the files below has a filemask of 775/664 instead of 700/600. This opens a can of worms when comes to security.
MaximoTrinidad commentedon Apr 18, 2018
Thank You for sharing! I'm getting to learn more about Linux after PowerShell became Open Source.
I'll be checking this post. I know some of the PowerShell Team will post something. They good in responding.
:)
cc: Steve Lee (@SteveL-MSFT)
SteveL-MSFT commentedon Apr 20, 2018
I tried this on Ubuntu and macOS and although I get errors from PSReadline complaining it can't write to the history file, pwsh still works. Can you try 6.1.0-Preview1?
leojonathanoh commentedon Apr 23, 2018
like Steve Lee (@SteveL-MSFT), I'm on Ubuntu 16.04 with 6.1.0-Preview.
On a service account user (with no writeable home), running interactively works:
That error message is about the not being able to write to the history file, but it doesn't prevent pwsh from being able to run.
SteveL-MSFT commentedon Apr 23, 2018
Ok, if the concern is just that error message, you should open an issue in the PSReadline repo: https://github.com/lzybkr/PSReadLine