DEV Community

Alexander Chichigin
Alexander Chichigin

Posted on

Setting up a Swift Vapor development environment on Linux

... which is not Ubuntu 14.04, 16.04, 16.10, 18.04 or 18.10.

As you've certainly guessed these are officially supported ones. So if you're not happened to use one of them (I use Linux Mint 19.3) official install instructions will not work (I've tried).

Luckily enough "manual" installation works pretty much automatically and out-of-the-box anyway. :)

Install Swift

Apparently official latest Ubuntu 18.04 toolchain works on my Linux Mint 19.3 just fine. I simply downloaded the archive, extracted it and added usr/bin subdirectory to my PATH and then swift worked with no issues (so far :)).

Install Vapor CLI

As we already know we can't just install Vapor CLI (aka Vapor Toolbox) simply following official instructions. Luckily building from source works as automatic as it can. :)

Step one: clone the toolbox repository into some directory and cd there.

$ git clone https://github.com/vapor/toolbox vapor-toolbox
$ cd vapor-toolbox
Enter fullscreen mode Exit fullscreen mode

Step two: just build the thing with Swift! :D (Note: I copied the command from a Dockerfile in the repo).

$ swift build -c release
Enter fullscreen mode Exit fullscreen mode

After that we have a self-contained executable file vapor somewhere down the hidden .build dir we can copy anywhere on our PATH (I've copied it to my $HOME/.local/bin).

$ cp .build/release/vapor ~/.local/bin/
Enter fullscreen mode Exit fullscreen mode

Now we can use it! :)

$ cd /tmp
$ vapor new Hello
$ cd Hello
Enter fullscreen mode Exit fullscreen mode

And after answering 2 questions (I agreed to use Fluent and choose PostgreSQL) we have our first Vapor project.

Now we can build it!

$ vapor build
Building project..
swift build
/tmp/VaporTest/Hello: error: manifest parse error(s):
Invalid semantic version string '-beta'
error:
Failed to build.
Enter fullscreen mode Exit fullscreen mode

OK, just not yet.

Apparently, the toolbox missed some template data for the Package.swift. Particularly in the line 13:

.package(url: "https://github.com/vapor/fluent--driver.git", from: "-beta")
Enter fullscreen mode Exit fullscreen mode

That should be

.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "1.0.0-beta")
Enter fullscreen mode Exit fullscreen mode

At least that's what I've figured from the Github repo and that worked. :)

Run build again, wait for ages... I had no nerve and time to wait till completion, I only waited for couple hours. The process is still flawed it seems... :'D

Top comments (0)