Introducing swiftly, a new Swift toolchain installer and manager

swiftly 0.1.0

We are excited to announce the 0.1.0 release of swiftly, a new Swift toolchain manager developed by the SSWG!

What is swiftly?

swiftly is a CLI tool for installing, managing, and switching between Swift toolchains, written in Swift. swiftly is designed to be extremely easy to install and get running (installation is usually just a bash one-liner), and its command interface is intended to be flexible while also being simple to use.

swiftly currently supports the following features:

  • Installing Swift toolchains, either releases or snapshots
    • toolchains can be installed by name, or portions of the name can be left out and swiftly will fetch the most recently produced matching toolchain
  • Switching which installed toolchain is active (i.e. which one is discovered via $PATH)
  • Uninstalling toolchain(s)
  • Listing installed toolchains

In the future, swiftly will supporting updating installed toolchains and listing toolchains that are available for install.

Right now, swiftly only supports Linux, but the medium term plan is to also support macOS and in long term to support all platforms that Swift runs on.

For more information about swiftly, check out the README.

Installation

As mentioned before, swiftly's installation is designed to be extremely fast and easy. In fact, pasting the following one-liner into your shell is all you need to get started:

curl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bash

The installation script will first display a prompt allowing you to customize the installation (the defaults should be fine for most users), and then it will proceed with downloading the swiftly binary and installing it. As part of this, any system dependencies required by Swift itself will also be installed via the system's package manager (this is enabled by default but can optionally be disabled).

The landing page at swiftly - A Swift toolchain installer and manager, written in Swift also contains these instructions in case you need them in the future or want to share them with a friend.

Example usage

$ swiftly install latest

Fetching the latest stable Swift release...
Installing Swift 5.8.1
Downloaded 488.5 MiB of 488.5 MiB
Extracting toolchain...
Swift 5.8.1 installed successfully!

$ swift --version

Swift version 5.8.1 (swift-5.8.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Feedback/suggestions/bug reports

While this does mark the first public release of swiftly, it is still in early development, so any feedback, feature requests, and bug reports would be greatly appreciated! To do so, please file an issue on swiftly's GitHub repository, or just respond with your initial thoughts in this thread. Thanks in advance!

FAQ

Why not install Swift through the package manager (e.g. apt or yum)?

Swift.org currently provides experimental .rpm and .deb packages that allow you to install Swift via your package manager. While these are an effective way to install and update a single version of Swift, they aren't well suited to the task of installing multiple Swift toolchains that you can easily switch between. swiftly's target audience are Swift developers that switch between versions for the purposes of testing their libraries and applications. The .deb and .rpm also currently don't provide support for snapshot toolchains.

How is this different from swiftenv?

swiftenv is an existing Swift version manager which already has much of the functionality that swiftly will eventually have. It's an awesome tool, and if it's part of your workflow then we encourage you to keep using it! That said, swiftly is/will be different a few ways:

  • swiftly is being built as a community driven effort led by the Swift Server Workgroup, and through this collaboration, swiftly may eventually become an official installation tool for Swift toolchains and use new swift.org APIs for fetching releases and snapshots (note: this is planned for the future, swiftly currently uses GitHub APIs for this).

  • swiftly will be written in Swift, which we think is important for maintainability and encouraging community contributions.

  • swiftly is optimized for ease of installation--it can be done with a bash one-liner similar to Homebrew and rustup.

  • swiftly has first-class support for installing and managing snapshot toolchains.

49 Likes

Can Swiftly be added to the Swift.org installation instructions?

Currently, Docker is front and center there for Linux. If I'm a beginner wishing to learn Swift, I would be under the impressions that whatever this Docker thing is, it's the official way to install Swift, and I'd be lost forever, as those instructions just assume the reader already has Docker installed, and knows how to use it.

3 Likes

Yes it should definitely be added to the list of options - as for whether it's the default option is something the language team and/or the SWWG need to discuss.

There are also security implications for linking to stuff outside of Swift.org that need to be discussed

3 Likes

This is super awesome and I've been using it for a while already! I love plopping onto a random VM and just hitting a macro key on keyboard to type out the curl -L https://swift-server.github.io/swiftly... and here I go -- ready to reproduce specific swift version bug reports etc :partying_face:

Probably good to give it a little bit of time so people can try it on various platforms and then promote to recommended main method? Though @patrick can speak to level of confidence we have right now more than myself I think.. :slight_smile:

1 Like

@ktoso put it pretty well--it's still early days for swiftly, so I think we want to let users try it out for a bit and let it mature some before we explore including it as an official installation path. That said, the hope is definitely for it to get there!

3 Likes

On that note, I was working on an orange pi 5 plus running Armbian 12 and it appears the install script just bails with unsupported platform. I think maybe that check could be disabled so people could experiment with getting it running with more distros perhaps since swift works on Debian and Ubuntu on arm or has in the past for me.

So what are the thoughts on "shared computer" installs, currently it seems to be per-user ?

1 Like

This looks interesting, thanks for your work on this! Is there any scope to use this to install custom toolchains? For our workflow it'd be valuable to be able to install different SwiftWasm toolchains for example. If not, would you be open to contributions with that goal in mind?

I don't think that swiftly is something that would be suitable for installing cross-compilation toolchains. For those you should use the new swift experimental-sdk install command introduced in Swift 5.9. With swiftly you'd install the top-level toolchain though, one that provides the swift command itself with the experimental-sdk subcommand.

4 Likes

Thanks, experimental-sdk install sounds interesting. Could you point me to more info about it? This is the first I've heard of it

I think it's probably best if we don't disable the platform detection, but what we can do is provide users with the option of selecting a supported platform to use for downloads if the detected one isn't supported. For exampe, I imagine when installing on debian, a user could just choose the latest Ubuntu and be fine. I filed Allow installation on unsupported platforms · Issue #60 · swift-server/swiftly · GitHub for this, thanks for the feedback!

1 Like

This is the same swift sdk command as specified in SE-0387, albeit with experimental- prefix until we can declare it fully ready for general use.

The default values for SWIFTLY_HOME_DIR and SWIFTLY_BIN_DIR are user-specific, but during installation you can configure them to be system-wide.

e.g. the following should do a system-level install of swiftly and its managed toolchains.

Select one of the following:
1) Proceed with the installation (default)
2) Customize the installation
3) Cancel
> 2
Enter the swiftly data and configuration files directory (default $HOME/.local/share/swiftly): 
> /usr/local/share
Enter the swiftly executables installation directory (default $HOME/.local/bin): 
> /usr/local/bin
Modify login config ($HOME/.profile)? (Y/n)
> y
Install system dependencies? (Y/n)
> n
Current installation options:

    Data and configuration files directory: /usr/local/share
        Executables installation directory: /usr/local/bin
      Modify login config ($HOME/.profile): true
               Install system dependencies: false

Note that you may want to use a bin directory other than /usr/local/bin, since Swift toolchains include a lot of other binaries in them that might clash with existing installations that your system is relying on (e.g. clang).

1 Like

Hi,

I'm trying to run it in a Github Actions is there a way to go around this configuration phase ?

Thanks,

Hi,
I am trying install swift on Linux Mint but the installer is failing saying it is an unsupported OS.
Linux Mint is basically Ubuntu 22.04 and uses the the standard Ubuntu apt repositories, so there is no reason why it shouldn't work.
I have tried several other desktop Linux distro's and they all fail as unsupported OS's.

Are you planning on supporting any of the popular Linux Ubuntu based distributions?

1 Like

Sweet, I can't wait till I can just zypper in swiftly, then swiftly update just like with rustup.

You can pass the -y (or --disable-confirmation) flag to swiftly-install.sh, and it'll skip through all the prompts and just use the defaults, if that's the issue you're running into.

1 Like

The toolchains are all downloaded directly from swift.org, so we can only "officially" support the platforms listed there. That said, swiftly (and those toolchains) will likely happily run on a bunch of other platforms. The plan is to allow users to select a platform from the supported ones to use in the event that theirs isn't one of them, which should help with this (see Allow installation on unsupported platforms · Issue #60 · swift-server/swiftly · GitHub).

In the meantime, you can just download the swiftly-install.sh script and modify it to use Ubuntu 22.04, and swiftly should install just fine.

If you apply the following patch, it should do the trick:

diff --git a/install/swiftly-install.sh b/install/swiftly-install.sh
index d2eb3a3..20c11bd 100755
--- a/install/swiftly-install.sh
+++ b/install/swiftly-install.sh
@@ -287,8 +287,12 @@ case "$ID" in
         ;;
 
     *)
-        echo "Error: Unsupported platform: $PRETTY_NAME"
-        exit 1
+        docker_platform_name="ubuntu"
+        package_manager="apt-get"
+        export DEBIAN_FRONTEND=noninteractive
+        PLATFORM_NAME="ubuntu2204"
+        PLATFORM_NAME_FULL="ubuntu22.04"
+        docker_platform_version="22.04"
         ;;
 esac
 

This will probably work for other debian-based distributions too (you may need to switch which Ubuntu version though).

1 Like

This won't cover Debian, but you should be able to read ID_LIKE out of the os-release file, many distributions that are derived from e.g. Ubuntu (like Pop!_OS or Linux Mint) report Ubuntu and Debian in the ID_LIKE field.

1 Like

@patrick I think you are missing the point.
Any distribution that uses the official Ubuntu repositories is already "officially" supported by swift.org. e.g Linux Mint == Ubuntu 22.04.
So "swiftly" should "officially" support these distributions out of the box.
We are not talking about "unsupported platforms" here.
You are already reading the os-release file in the install script so it should be a quick an easy fix to recognize these distributions.

1 Like