Skip to content

Need better error message when it fails to create a Mutex due to no-write permission to the '/tmp' folder on macOS or Linux #36823

Closed
@daxian-dbw

Description

@daxian-dbw

We consistently get issue reports in PSReadLine about an IOException when creating a Mutex object on macOS:

System.IO.IOException: The system cannot open the device or file specified. : 'PSReadLineHistoryFile_1525368525'
   at System.Threading.Mutex.CreateMutexCore(Boolean initiallyOwned, String name, 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)

I worked with a user on that issue and it turned out it was because the /tmp folder (mapped to /private/tmp) on the user's mac shows 755 for the permissions, namely no write permission for a non-root user. The user thought the permission change could be caused by Homebrew, and Mutex creation works fine after changing the permission to 777, see PowerShell/PSReadLine#1464 (comment)

The error message is not helpful to get to the root of the problem. Given it's a permission issue, it could be great if the error message could indicate the permission issue.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions