Skip to content

Regression: wsl ~ works in 7.5 but fails in 7.6 due to tilde expansion and argument mangling #27098

@smzmster

Description

@smzmster

Prerequisites

Steps to reproduce

Summary

wsl ~ works in PowerShell 7.5 but fails in PowerShell 7.6 due to unexpected tilde expansion and argument mangling

Steps to reproduc

Run the following command in PowerShell:
wsl ~

the command fails with:

/bin/bash: line 1:
 D:Users<username>: command not found

Additional information

The issue does not occur in cmd.exe
The issue did not occur in PowerShell 7.5
This suggests a regression or change in native argument passing behavior in 7.6

Workarounds

The following commands work as expected:
wsl --cd ~
wsl "~"

Expected behavior

~ should be passed to WSL and resolved to the Linux home directory (e.g. /home/<user>).
This is the behavior observed in PowerShell 7.5.

Actual behavior

In PowerShell 7.6, the command fails with:

/bin/bash: line 1:
 D:Users<username>: command not found

It appears that:
1. ~ is expanded by PowerShell into a Windows path (e.g. D:\Users\<username>)
2. The backslashes (\) are stripped or mangled when passed to the native command
3. The resulting string (D:Users<username>) is interpreted by bash as a command

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.0
PSEdition                      Core
GitCommitId                    7.6.0
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions