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 when trying to use powershell 7.1 as default shell of ubuntu 20.04 in wsl #14055
Issue-BugIssue has been identified as a bug in the productOS-WSLResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
Any ideas on this one? I have the same issue. I've got Ubuntu 20.04 WSL and the apt package install of powershell 7.1.X gives me the following error when configured as my shell: : 6: export: (x86)/Microsoft: bad variable name.
Oddly, if I install the dotnet global tool: sudo dotnet tool update --tool-path /usr/local/bin powershell and use that location as my shell I do not get this error.
I'd prefer to use the APT install, especially since the nuget tool package is a few days late with the 7.1.4 update and it would just feel more natural to use the APT install.
As noted in #14640, the problem is probably that something is trying to
export PATH=...
and the ... is not quoted correctly for the current shell, so the first thing that has a space before it, and doesn't look like a valid shell env-var name, i.e. (x86)/Microsoft or (x86)/Dev-Cpp/TDM-GCC-64/bin:/mnt/c/Program, causes this error.
I would guess that PowerShell is being asked to evaluate a bash script, and differences in quoting behaviour (not a bug) are breaking this. So not really a PowerShell issue, unless reading the script is a built-in PowerShell behaviour.
I think it's much more likely it's a WSL issue, that (per microsoft/WSL#1640 (comment)) WSL's appendWindowsPath feature is assuming bash is the shell when it appends that path, and hence the quoting is incorrect when PowerShell is the shell.
Any suggestions of how I might debug this? The error message isn’t super helpful.
Also, why the dotnet global tool install works but the apt package doesn’t? I’m guessing some configuration that comes with the apt package but not with the global tool?
Assuming disabling appendWindowsPath avoids the issue (at the cost of not having Windows's $PATH in the WSL $PATH), then the problem is probably in the appendWindowsPath implementation, which might have magic to detect PowerShell, but it is failing for the APT-installed version.
It's also possible that the reason it works with the global tool version is that the global tool version has known issues in command-line parsing and quotes, e.g. #11747, and those issues coincide with the appendWindowsPath implementation to work (or at least not-fail).
One other thing to check: Does appendWindowsPath actually work with the gobal tool install? You've mentioned that it doesn't give the error, but I don't know if that means that appendWindowsPath is successful, or if it's just failing in a way that doesn't produce an error.
This seems to be caused by an issue in Ubuntu in /etc/profile.d/apps-bin-path.sh. It sounds like apps-bin-path.sh has been fixed in 21.10 but Ubuntu on WSL is still 20.04.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
Issue-BugIssue has been identified as a bug in the productOS-WSLResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
Activity
fMichaleczek commentedon Nov 12, 2020
Hyperhydrochloric Acid (@HCl-10) I had problems with WSL and PATH which contains "Program Files" to compile OpenWrt, so I am sure it's a PowerShell Issue. see microsoft/WSL#1640 (comment)
anmenaga commentedon Nov 12, 2020
Dongbo Wang (@daxian-dbw) may have more info on this.
iSazonov commentedon Nov 13, 2020
/cc Rob Holt (@rjmholt)
jonstelly commentedon Aug 16, 2021
Any ideas on this one? I have the same issue. I've got Ubuntu 20.04 WSL and the apt package install of powershell 7.1.X gives me the following error when configured as my shell:
: 6: export: (x86)/Microsoft: bad variable name.Oddly, if I install the dotnet global tool:
sudo dotnet tool update --tool-path /usr/local/bin powershelland use that location as my shell I do not get this error.I'd prefer to use the APT install, especially since the nuget tool package is a few days late with the 7.1.4 update and it would just feel more natural to use the APT install.
TBBle commentedon Aug 20, 2021
As noted in #14640, the problem is probably that something is trying to
and the
...is not quoted correctly for the current shell, so the first thing that has a space before it, and doesn't look like a valid shell env-var name, i.e.(x86)/Microsoftor(x86)/Dev-Cpp/TDM-GCC-64/bin:/mnt/c/Program, causes this error.I would guess that PowerShell is being asked to evaluate a bash script, and differences in quoting behaviour (not a bug) are breaking this. So not really a PowerShell issue, unless reading the script is a built-in PowerShell behaviour.
I think it's much more likely it's a WSL issue, that (per microsoft/WSL#1640 (comment)) WSL's
appendWindowsPathfeature is assuming bash is the shell when it appends that path, and hence the quoting is incorrect when PowerShell is the shell.jonstelly commentedon Aug 20, 2021
Any suggestions of how I might debug this? The error message isn’t super helpful.
Also, why the dotnet global tool install works but the apt package doesn’t? I’m guessing some configuration that comes with the apt package but not with the global tool?
TBBle commentedon Aug 20, 2021
Assuming disabling
appendWindowsPathavoids the issue (at the cost of not having Windows's$PATHin the WSL$PATH), then the problem is probably in theappendWindowsPathimplementation, which might have magic to detect PowerShell, but it is failing for the APT-installed version.It's also possible that the reason it works with the global tool version is that the global tool version has known issues in command-line parsing and quotes, e.g. #11747, and those issues coincide with the
appendWindowsPathimplementation to work (or at least not-fail).One other thing to check: Does
appendWindowsPathactually work with the gobal tool install? You've mentioned that it doesn't give the error, but I don't know if that means thatappendWindowsPathis successful, or if it's just failing in a way that doesn't produce an error.jonstelly commentedon Dec 16, 2021
This seems to be caused by an issue in Ubuntu in
/etc/profile.d/apps-bin-path.sh. It sounds like apps-bin-path.sh has been fixed in 21.10 but Ubuntu on WSL is still 20.04.Work-around: #9842 (comment)
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.