Powershell feature fails to install version 7.4.3 properly for linux arm64
PowerShell feature install of 7.4.3 for linux arm64 Issue
Issue with install.sh
If an install using GitHub is attempted, install.sh logic for devcontainers/features/src/powershell does not explicitly set pwsh as executable. Successful installation currently depends on the permissions in the tar file.
Symptoms of Failure
If I pinned the version to 7.4.2, the powershell feature would function correctly. Looking at the permissions inside the tar file showed the execute bit was set on pwsh.
tar -tvf /Users/donhunt/local/powershell-7.4.2-linux-arm64.tar.gz pwsh
-rwxr-xr-x 0 cloudtest cloudtest 72544 Apr 9 18:48 pwsh
Using an explicit version of 7.4.3, latest or not specifying a version, pwsh could not be run because permissions were not set to execute. The install did not return an error code. It just did not function at runtime.
tar -tvf /Users/donhunt/local/powershell-7.4.3-linux-arm64.tar.gz pwsh
-rw-rw-r-- 0 root root 72544 Jun 18 10:15 pwsh
NOTE: The instructions from the powershell team to install powershell into linux using the binaries does include setting pwsh as an executable. In my case I am running MacOS on a MacBook Pro with an M1 processor. Docker Desktop is installed using a linux arm64 virtual machine. When installing devcontainer features, such as powershell, install scripts are running as root in a linux arm64 environment.
In the case of installing from github, powershell-7.4.3-linux-arm64.tar.gz is extracted into /opt/microsoft/powershell/7 but the pwsh executable does not have proper permissions to run.
Fix install.sh
Add chmod after the extract to make pwsh executable.
223 tar xf "${powershell_filename}" -C "${powershell_target_path}"
224 chmod 755 "${powershell_target_path}/pwsh"
225 ln -s "${powershell_target_path}/pwsh" /usr/local/bin/pwsh
Fixed as the vscode user with the commands
cd /opt/microsoft/powershell/7
sudo chmod 755 pwsh
Log snippets showing before and after fix
vscode ➜ /opt/microsoft/powershell/7 $ ls -l pwsh
-rw-rw-r-- 1 root root 72544 Jun 18 14:15 pwsh
...
vscode ➜ /opt/microsoft/powershell/7 $ ls -l $(which zsh)
-rwxr-xr-x 1 root root 898808 Feb 12 2022 /usr/bin/zsh
vscode ➜ /opt/microsoft/powershell/7 $ ls -l $(which bash)
-rwxr-xr-x 1 root root 1399416 Mar 14 11:31 /usr/bin/bash
vscode ➜ /opt/microsoft/powershell/7 $ sudo chmod 755 pwsh
vscode ➜ /opt/microsoft/powershell/7 $ ls -l pwsh
-rwxr-xr-x 1 root root 72544 Jun 18 14:15 pwsh
vscode ➜ /opt/microsoft/powershell/7 $ ./pwsh
PowerShell 7.4.3
PS /opt/microsoft/powershell/7> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Ubuntu 22.04.4 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS /opt/microsoft/powershell/7>