Opening a pwsh session on Linux can fail while using su

オープン
#5,231 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp, linux
領域
cli

調査の方向性

The exception is raised from Mutex creation inside PSConsoleReadLine.DelayedOneTimeInitialize(), which names the mutex after the history file. Start there and check how the history path is derived from the environment, including XDG_RUNTIME_DIR. To reproduce, set XDG_RUNTIME_DIR to a directory the current user cannot read and start pwsh. Done when startup no longer throws in that case and the fallback behaviour is covered by a test.

索引モデルが issue の本文から書いたものです。

説明

Needs-Triage :mag:
Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.
Exception report
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.4.5
PowerShell: 7.6.9
OS: AlmaLinux 9.8 (Olive Jaguar)
BufferWidth: 235
BufferHeight: 71

Last 0 Keys:



### Exception

System.IO.IOException: The system cannot open the device or file specified. : 'PSReadLineHistoryFile_3685172568'. One or more system calls failed: lstat("/run/user/1001/.dotnet", ...) == -1; errno == EACCES;
   at System.Threading.Mutex.CreateMutexCore(Boolean initiallyOwned, String name, NamedWaitHandleOptionsInternal options, Boolean& createdNew)
   at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)
   at Microsoft.PowerShell.PSConsoleReadLine.DelayedOneTimeInitialize()
   at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)
Screenshot

[imagine a command line with pwsh as the only input]

Environment data
PS Version: 7.6.9
PS HostName: ConsoleHost
PSReadLine Version: 2.4.5
PSReadLine EditMode: Emacs
OS: Linux redacted 5.14.0-687.61.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Oct 26 20:10:21 EDT 2026 x86_64 x86_64 x86_64 GNU/Linux
BufferWidth: 235
BufferHeight: 71
Steps to reproduce
  • login as any user (uid 1001 in this case)
  • su to another user (uid 1004 in this case)
    -> watch the error
Expected behavior

pwsh launches as expected

Actual behavior

XDG_RUNTIME_DIR=/run/user/1001 is still set, so the call goes out to stat a directory we don't have access to. This should be handled gracefully and not surface the exception

If you use "su - ", dropping the environment vars, everything works as expected

主要言語
C#
スター
4.4k
フォーク
346
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PowerShell/PSReadLine のほかの issue

PowerShell/PSReadLine の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。