install-powershell.sh doesn't work on azure-linux
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues.
- [X] Refer to the FAQ.
- [X] Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I deployed a virtual machine in azure specifying:
publisher: MicrosoftCBLMariner offer: azure-linx sku: azure-linux-gen2
when I ran the install script, it failed saying it was an unsupported os:
Sorry, your operating system is based on and is not supported by PowerShell or this installer at this time
Expected behavior
pwsh is installed
Actual behavior
pswh installation fails with error:
Sorry, your operating system is based on and is not supported by PowerShell or this installer at this time
Error details
Sorry, your operating system is based on and is not supported by PowerShell or this installer at this time
Environment data
N/A
Visuals
No response
https://gitee.com/chuanjiao10/kasini3000_agent_linux#microsoft-azurelinux-20-kernel515
Hey, Can you please run the code like this in the azure linux console and let me know the output?
OS=$(lowercase "$(uname)") echo ${OS}
My best guess is the above statement doesn't work in Azure linux. Maybe it misses lowercase command and it is failing at that level. I will put a PR, if you can confirm me the output of ${OS}
yes it seems the base image is missing lowercase:
adminUsername@vm [ ~ ]$ OS=$(lowercase "$(uname)")
-bash: lowercase: command not found
adminUsername@vm [ ~ ]$ echo ${OS}
FYI
uname returns Linux
cat /etc/os-release returns
NAME="Microsoft Azure Linux"
VERSION="3.0.20240524"
ID=azurelinux
VERSION_ID="3.0"
PRETTY_NAME="Microsoft Azure Linux 3.0"
ANSI_COLOR="1;34"
HOME_URL="https://aka.ms/azurelinux"
BUG_REPORT_URL="https://aka.ms/azurelinux"
SUPPORT_URL="https://aka.ms/azurelinux"
I just tried an experiment to see if it had been there whether it would have worked. I created a script called lowercase with the following contents:
#!/bin/bash
echo $1 | tr 'A-Z' 'a-z'
and put it in /bin
now the command returns
root@vm [ / ]# OS=$(lowercase "$(uname)")
root@vm [ / ]# echo $OS
linux
but... install_powershell.sh still doesn't work.
I modified it and added set -x here is the output:
+ install
+ local VERSION=1.2.0
+ local gitreposubpath=PowerShell/PowerShell/master
+ local gitreposcriptroot=https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools
+ local gitscriptname=install-powershell.psh
+ echo 'Get-PowerShell MASTER Installer Version 1.2.0'
Get-PowerShell MASTER Installer Version 1.2.0
+ echo 'Installs PowerShell and Optional The Development Environment'
Installs PowerShell and Optional The Development Environment
+ echo ' Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh'
Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh
+ echo 'Arguments used: '
Arguments used:
+ echo ''
+ trap '
trap - INT # restore default INT handler
echo "Interrupted"
kill -s INT "$$"
' INT
+ local OS
+++ uname
++ lowercase Linux
++ echo Linux
++ tr '[:upper:]' '[:lower:]'
+ OS=linux
+ local KERNEL
++ uname -r
+ KERNEL=6.6.29.1-3.azl3
+ local MACH
++ uname -m
+ MACH=x86_64
+ local DIST
+ local DistroBasedOn
+ local PSUEDONAME
+ local REV
+ '[' linux == windowsnt ']'
+ '[' linux == darwin ']'
+++ readlink -f ./i.sh
++ dirname /var/lib/waagent/custom-script/download/0/i.sh
+ SCRIPTFOLDER=/var/lib/waagent/custom-script/download/0
++ uname
+ install
+ local VERSION=1.2.0
+ local gitreposubpath=PowerShell/PowerShell/master
+ local gitreposcriptroot=https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools
+ local gitscriptname=install-powershell.psh
+ echo 'Get-PowerShell MASTER Installer Version 1.2.0'
Get-PowerShell MASTER Installer Version 1.2.0
+ echo 'Installs PowerShell and Optional The Development Environment'
Installs PowerShell and Optional The Development Environment
+ echo ' Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh'
Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh
+ echo 'Arguments used: '
Arguments used:
+ echo ''
+ trap '
trap - INT # restore default INT handler
echo "Interrupted"
kill -s INT "$$"
' INT
+ local OS
+++ uname
++ lowercase Linux
++ echo Linux
++ tr '[:upper:]' '[:lower:]'
+ OS=linux
+ local KERNEL
++ uname -r
+ KERNEL=6.6.29.1-3.azl3
+ local MACH
++ uname -m
+ MACH=x86_64
+ local DIST
+ local DistroBasedOn
+ local PSUEDONAME
+ local REV
+ '[' linux == windowsnt ']'
+ '[' linux == darwin ']'
+++ readlink -f ./i.sh
++ dirname /var/lib/waagent/custom-script/download/0/i.sh
+ SCRIPTFOLDER=/var/lib/waagent/custom-script/download/0
++ uname
+ OS=Linux
++ lsb_release --id
++ sed -E 's/^.*:[[:space:]]*//'
+ DISTRIBUTOR_ID=
+ '[' Linux == SunOS ']'
+ '[' Linux == AIX ']'
+ '[' Linux == Linux ']'
+ '[' -f /etc/redhat-release ']'
+ '[' -f /etc/system-release ']'
+ '[' -f /etc/mariner-release ']'
+ '[' -f /etc/mandrake-release ']'
+ '[' -f /etc/debian_version ']'
+ '[' '' = Gentoo ']'
+ '[' -f /etc/UnitedLinux-release ']'
++ source /etc/os-release
+++ NAME='Microsoft Azure Linux'
+++ VERSION=3.0.20240524
+++ ID=azurelinux
+++ VERSION_ID=3.0
+++ PRETTY_NAME='Microsoft Azure Linux 3.0'
+++ ANSI_COLOR='1;34'
+++ HOME_URL=https://aka.ms/azurelinux
+++ BUG_REPORT_URL=https://aka.ms/azurelinux
+++ SUPPORT_URL=https://aka.ms/azurelinux
++ echo Microsoft Azure Linux 3.0
+ osname='Microsoft Azure Linux 3.0'
+ [[ Microsoft Azure Linux 3.0 = *SUSE* ]]
++ lowercase Linux
++ echo Linux
++ tr '[:upper:]' '[:lower:]'
+ OS=linux
++ lowercase
++ echo ''
++ tr '[:upper:]' '[:lower:]'
+ DistroBasedOn=
+ echo 'Operating System Details:'
Operating System Details:
+ echo ' OS: linux'
OS: linux
+ echo ' DIST: '
DIST:
+ echo ' DistroBasedOn: '
DistroBasedOn:
+ echo ' PSUEDONAME: '
PSUEDONAME:
+ echo ' REV: '
REV:
+ echo ' KERNEL: 6.6.29.1-3.azl3'
KERNEL: 6.6.29.1-3.azl3
+ echo ' MACH: x86_64'
MACH: x86_64
+ echo ' OSSTR: '
OSSTR:
+ case "$DistroBasedOn" in
+ echo 'Sorry, your operating system is based on and is not supported by PowerShell or this installer at this time.'
Sorry, your operating system is based on and is not supported by PowerShell or this installer at this time.
+ exit 1
it seems to behave the same way with or without lowercase command so that may not be the issue
i think the script will need to be updated to check for /etc/azurelinux-release
Let me see, thanks for your findings.
Yes, it is certain that there is no support for Microsoft Azure Linux.
I might be completely off, but this was a quick and easy solution to try and implement.
https://github.com/PowerShell/PowerShell/pull/23955
This is a PR that I have raised to fix the issue. Please let me know your thoughts on this.
I tested with your changes and it didn't work, here is the error:
Get-PowerShell MASTER Installer Version 1.2.0
Installs PowerShell and Optional The Development Environment
Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh
Arguments used:
Operating System Details:
OS: linux
DIST:
DistroBasedOn: mariner
PSUEDONAME: Azure Linux 3.0
AZURELINUX_BUILD_NUMBER=3.0.20240524
REV: Azure
AZURELINUX_BUILD_NUMBER=3.0.20240524
KERNEL: 6.6.29.1-3.azl3
MACH: x86_64
OSSTR:
Configuring PowerShell Environment for: mariner Azure
AZURELINUX_BUILD_NUMBER=3.0.20240524
Could not find "installpsh-mariner.sh" next to this script...
Pulling and executing it from "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/installpsh-mariner.sh"
found and using curl
*** PowerShell Development Environment Installer 1.2.0 for mariner
*** Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/installpsh-mariner.sh
*** Arguments used:
*** This installer is only for mariner and you are running , please run "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.sh" to see if your distro is supported AND to auto-select the appropriate installer if it is.
I deployed a virtual machine in azure specifying:
publisher: MicrosoftCBLMariner offer: azure-linx sku: azure-linux-gen2
@dpoole73 Can you share the details steps to create an Azure VM with the azure-linux image? I cannot find the image when creating a VM in Auzre Portal. The https://github.com/microsoft/azurelinux says the azurelinux is an internal Linux distribution for Microsoft’s cloud infrastructure and services. If so, the image won't be public, right?
GitHub
Linux OS for Azure 1P services and edge appliances - microsoft/azurelinux
oh I didn't realize it was an internal image. I am using an internal microsoft subscription so likely it shows up for me but not for you. I'm trying to install powershell on it so that I can validate the image for testing. I guess mariner got rebranded to azure-linux so I'm guessing this is just the latest image and will be available going forward?
📣 Hey @dpoole73, how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback