PowerShell and Arch Linux
Table of Contents
- PowerShell and Arch Linux
I won’t pull your leg, I have primarily been a Windows user my whole life. Before I lose any die hard Linux readers, I will also say that I love Linux, like, A LOT! Since I like to play PC games and have worked places that have huge Microsoft footprints I have just spent more time in the Windows world (for better or worse). Between those two things, that’s what made me jump into PowerShell over another language a long time ago.
I have been ecstatic since PowerShell Core (and .Net Core) released and brought a era of open source and cross platform goodness to Windows, Linux, and Mac!
I still play PC games, but despite that I have decided that I am going to live as a Linux user henceforth, only booting into Windows to play games that can’t run on Linux yet natively. So hello from Linux, where I intend to stay (at least on my home desktop and laptop) from now on!
This isn’t about me using Linux, it’s about how to install PowerShell Core on my favorite Linux distribution, Arch Linux!
NOTE BEFORE READING: Arch Linux has a somewhat unique package manager (pacman) and has a rolling release model, which is part of why I love the distribution. With that said, this process is a lot different than if you are going to install PowerShell on CentOS, RedHat, Debian, Ubuntu or almost any other distribution!
Make sure you read the instructions specific to your Linux distribution!
Before diving in, the most important place by far to start here is going to be the documentation on Github for PowerShell.
The README.md markdown file has a lot of details for installing PowerShell on Windows, Mac and many of the most popular Linux distributions.
In this example we’re looking for Arch Linux, and we can see that it’s in the section for Linux distributions that have community support.
If you follow the link it’ll bring you to official Microsoft documentation. There you’ll see that Arch support is experimental and you need to install PowerShell from the AUR (Arch User Repository). Since this is a personal machine, you likely won’t need official Microsoft support. Also if you are familiar with Arch, installing packages from the AUR is a fairly standard activity1.
You can also see there a few different options available to us in the AUR. If you navigate to the links listed on the Microsoft page you can view a bit about each of the package options. You can install a package based off the latest Git commit to the master branch, the latest tagged release, or the latest available release binary2.
AUR and an AUR Helper
We’ll go ahead and take the latest available release binary package
powershell-bin from the AUR.
You can see if you try to use
pacman to find the package it doesn’t show up.
pacman can’t help us with packages in the AUR.
# Refresh the database
# Search the Arch repositories for PowerShell
pacman -Ss powershell-bin
You have two primary options for installing packages from the AUR.
- You can get the build files, review them, and execute a
makepkg -si, this is outlined in the Installing Packages section of the AUR page in the ArchWiki.
- You can use an AUR helper. An AUR helper will assist in searching the AUR, getting the build files, and running through the steps for you.
- As AUR helpers are not officially supported, if using one you will need to install it manually first!
We’ll walk through both options. Note that you only will need to do one if you’re following along.
git to get the build files. Install
git if needed
sudo pacman -S git.
# Clone the AUR package down with git, use the "Git Clone URL"
git clone https://aur.archlinux.org/powershell-bin.git
# Navigate into the directory from the Git clone
# AUR Packages are community created, MAKE SURE YOU REVIEW THE FILES BEFORE INSTALL!
# Run makepkg to build the AUR package, '-s' will sync dependencies, '-i' will install the package after build.
This gif will show the process!
Now we can PowerShell our days away!
Using an AUR Helper (yay)
yay is a
pacman wrapper, it can function as
pacman or be used to install AUR packages. It is a lightweight utility written in Go with a feel very similar to using
pacman that also has all the features an AUR helper should have.
First you’ll need to install
yay. The instructions for installing
yay can be found on the README.md of the Github project.
# Clone down the yay build files.
git clone https://aur.archlinux.org/yay.git
# Navigate into the directory from the Git clone
# Run makepkg to build the package, '-s' will sync dependencies, '-i' will install the package after build.
Just like that you should have a shiny new AUR helper to help install AUR packages!
Installing PowerShell now with
yay is a one liner. You will be asked if you want to review the files before install (which you always should). You’ll also be asked if you want to do a “Clean build”, which just means that it will not export new variables that may prevent a successful build.
yay -S powershell-bin
When you go through the package you should review the files when prompted by the
yay install. When you are done reviewing you would use “q” to stop reviewing the files and continue the install.
Again, we’re ready to PowerShell it up!
You should now have PowerShell installed on your Arch system, cool!
I usually don’t expressly call them out, but the foot notes on this one are worth reading. Lastly I want to re-stress, this blog post is specific to Arch Linux, the process for installing on any other distribution will be different!
Arch Linux package management as well as the AUR are pretty huge topics in themselves which could be worthy of multiple blog posts. The follow links will provide more context if interested. pacman, aur, aur helpers ↩
At the time of writing this (September 17th 2018) PowerShell Core 6.1.0 has released. However as AUR packages are community maintained there is no AUR package that has 6.1.0, yet… Hopefully at some point it gets picked up and added to the Arch Linux “extra” repository (like Ruby and Python). ↩