Are there developers out there using Swift on Ubuntu?

I have had too many issues trying to run Swift on Ubuntu over the years - mostly the compiler will crash when trying to compile "Hello, World!" program.

Today - in a moment of exasperation I tried using the latest Centos 8 version:

swift-5.5.2-RELEASE-centos8.tar.gz

and surprisingly my project compiled without any warnings or errors.

So if you are using the latest version of Ubuntu 21.10 and you want to try Swift - download the Centos 8 package.

Best Regards,

Eugene

I regularly use Swift on Ubuntu, albeit mostly for (basic) educational stuff.

I've never had any issues with the official releases, but I only ran them on officially supported LTS versions. For the past year, I've been using the packages from https://www.swiftlang.xyz, as they are much easier to install, and support more versions of Ubuntu.

1 Like

I also thought that sticking to the LTS versions would help, so I did reinstall the OS on my computer using Ubuntu 20.04
Tried hard to get Swift to work and then I gave up and decided to upgrade to 21.10.
No luck again until I installed the Centos 8 package.

Quite a while ago I had v5.11 (I think) working fine then a new version came I "upgraded" - nothing worked. So I went back to v5.11 and every time the new version came out - I will try it and none of them worked.

Then I managed to get 5.3? working and subsequent versions were broken again. I tried official Swift releases, I tried development snapshots, nothing worked ...

Well - I started this thread just to let other people know as a last ditch effort - try the other Linux versions of Swift. There was nothing on the Internet about the crashes I experienced. ( I use many compilers on this machine and everything works fine. )

If you have the option - maybe switch to Centos from Ubuntu.

CentOS is a dead operating system, so that's not really good advice.

2 Likes

Isn't CentOS the free version of RedHat?

Swift is supported only on Ubuntu, CentOS and AmazonLinux ...
Is AmazonLinux better than CentOS? (In terms of updates and support.)

It's been discontinued.

1 Like

Oh - OK. Thanks

I use it every day on both M1 (through Parallels) and Intel (VMWare) Ubuntu and through a QEMU virtual server. I use it mostly to make SwiftNIO server apps and a SwiftWASM app using a very similar code base. I have all the regular required packages installed and am usually running the most recent version of Swift compiler and Ubuntu. I haven't experienced any errors in a while. I've had to do fresh installs recently and installed all the required packages freshly (about two-three months ago) and also had no issues getting up and running. I wish I had any advise for what might be going wrong here.

Are you using the server version:

Download Ubuntu Server 20.04.3 LTS

?

I did clean install of Ubuntu Desktop 20.04.3, tried to get Swift running unsuccessfully. Then upgraded to 21.10 - again no luck with the Swift Ubuntu 20.04 version. Now with the latest CentOS 8 version - everything works fine.

I don't remember having issues with Swift when I was running Ubuntu 16.04 or 18.04.

Oh well - I have now working version, so I am set up.

However after the issues I described I was really wondering if other developers actually use Ubuntu do develop Swift applications.

It would be probably accurate guess that 98% or more of the Swift developers use Mac OS.

My only problem with Ubuntu is that the dependency list isn't actually complete (back in 2019, not sure about now). So when you run any command, you'd be greeted with things like missing libSomethingSomething.so. It was quite annoying finding the right package to install. However, it works smoothly afterward.

I use the official builds of Swift for Ubuntu 20.04 on my Android CI to cross-compile several Swift packages for Android, haven't had a problem. Were you getting missing dependency errors like @Lantua says or was the compiler actually crashing? If you paste your errors here, we could see what the problem is.

eugene@coconut:~$ swift hello.swift
Please submit a bug report (Swift.org - Contributing) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend -frontend -interpret hello.swift -disable-objc-interop -color-diagnostics -new-driver-path /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-driver -resource-dir /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/lib/swift -module-name hello

  1. Swift version 5.5.2 (swift-5.5.2-RELEASE)
  2. While evaluating request ParseSourceFileRequest(source_file "hello.swift")
  3. With parser at source location: hello.swift:1:22
    Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH to point to it):
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5a3efb3]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5a3ce9e]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5a3f335]
    /lib/x86_64-linux-gnu/libc.so.6(+0x46520)[0x7f35504f2520]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1d45c93]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1d424b9]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1949809]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ac4503]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ac051c]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1abea43]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab911b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab8e0a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab861b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6c71]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6b18]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ac8c9a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ad8d2b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1abd569]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1abd1a3]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab9812]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab9145]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab8e0a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab861b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6c71]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6b18]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae22a0]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae41d4]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1a84f77]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae11d1]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae1cdc]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19cfe84]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19cfb81]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19b823a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19b0bee]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x13d40dd]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x7121c1]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x712471]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5601d0]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x4b140e]
    /lib/x86_64-linux-gnu/libc.so.6(+0x2dfd0)[0x7f35504d9fd0]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x7d)[0x7f35504da07d]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x4b104e]
    Illegal instruction (core dumped)

When using the latest CentOS 8 version of Swift:

eugene@coconut:~$ swift hello.swift
Hello, World!
eugene@coconut:~$

I decided to try the AmazonLinux version of Swift:

swift-5.5.2-RELEASE-amazonlinux2.tar.gz

Everything worked fine.

So - to summarise:
I am using the latest up to date Ubuntu Desktop 21.10

This version of Swift does not work:
swift-5.5.2-RELEASE-ubuntu20.04

These work just fine:
swift-5.5.2-RELEASE-amazonlinux2
swift-5.5.2-RELEASE-centos8

Is that the error on Ubuntu 20.04.3 or 21.10?

FWIW, I'm using Ubuntu 20.04.3 Server. It already has a few compilation-related packages, potentially beyond the listed dependencies:

binutils git gnupg2 libc6-dev libcurl4 libedit2 libgcc-9-dev libpython2.7 libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config tzdata uuid-dev zlib1g-dev

So it's not a fresh install, but I can run swift hello.swift no problem.

eugene@coconut:~$ swift hello.swift

Strange, try compiling an executable instead, swiftc hello.swift && ./hello, that may give you a better idea what's going wrong.

There is no difference whey trying to compile the hello.swift program:

eugene@coconut:~$ which swift
/opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift
eugene@coconut:~$ swiftc hello.swift
error: compile command failed due to signal 4 (use -v to see invocation)
Please submit a bug report (Swift.org - Contributing) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend -frontend -c -primary-file hello.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -new-driver-path /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-driver -resource-dir /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/lib/swift -module-name hello -o /tmp/TemporaryDirectory.WmQ1fQ/hello-1.o

  1. Swift version 5.5.2 (swift-5.5.2-RELEASE)
  2. While evaluating request ParseSourceFileRequest(source_file "hello.swift")
  3. With parser at source location: hello.swift:1:22
    Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH to point to it):
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5a3efb3]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5a3ce9e]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5a3f335]
    /lib/x86_64-linux-gnu/libc.so.6(+0x46520)[0x7f3a8468f520]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1d45c93]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1d424b9]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1949809]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ac4503]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ac051c]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1abea43]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab911b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab8e0a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab861b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6c71]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6b18]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ac8c9a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ad8d2b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1abd569]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1abd1a3]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab9812]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab9145]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab8e0a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab861b]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6c71]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ab6b18]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae22a0]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae41d4]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1a84f77]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae11d1]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x1ae1cdc]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19cfe84]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19cfb81]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19b823a]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x19b0bee]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x13d40dd]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x7121c1]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x712471]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x5601d0]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x4b140e]
    /lib/x86_64-linux-gnu/libc.so.6(+0x2dfd0)[0x7f3a84676fd0]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x7d)[0x7f3a8467707d]
    /opt/swift-5.5.2-RELEASE-ubuntu20.04/usr/bin/swift-frontend[0x4b104e]

Is this on Ubuntu 21.10?

Swift works just fine on Ubuntu 18.04, the OS that Google Colab runs on (see Swift-Colab for more on this).

Yes