Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift toolchain location on Linux

I'm looking into running Swift on a Ubuntu 16.04 server. However I want to be certain about where I should install the toolchain.

From swift.org:

If you installed the Swift toolchain on Linux to a directory other than the system root, you will need to run the following command, using the actual path of your Swift installation...

Then from Kitura's Setting Up instructions:

After extracting the .tar.gz file, update your PATH environment variable so that it includes the extracted tools:

$ export PATH=<path to uncompressed tar contents>/usr/bin:$PATH

  1. Where is the best place to install these type of things? In the past I would rely on apt-get or installation scripts provided by maintainers but this doesn't seem to be the case with Swift.

  2. Are there any benefits or disadvantages to not installing it at the system root?

Note: This question borders on "best practices", which I believe is frowned upon here. I'm sorry about that; I've googled around and this seems to be something that people know implicitly. However, I don't yet and need some guidance

like image 592
Shawn Throop Avatar asked Oct 28 '25 16:10

Shawn Throop


1 Answers

The versions of the software in your system root - in /usr/bin, /usr/share, /usr/lib, etc. - are carefully coordinated by the maintainers of your distribution to handle all reasonable dependencies. The maintainers also keep the software up-to-date with bug fixes.

When you need to install software that isn't supplied by your distribution, it's best to install it in a separate directory, such as /opt (in your case, one possibility is /opt/swift-3.1.1). This will avoid overwriting existing installed software (in your case, /usr/bin/lldb and /usr/lib/lldb) with something that's possibly incompatible with other software. And it will make it easy to uninstall (just rm -r /opt/swift-3.1.1 rather than having to get a list of files from the original tarball that are potentially strewn all over /usr).

There is some extra effort: you'll need to add /opt/swift-3.1.1/usr/bin to your PATH1. With some software, you'll need to add the directory containing dynamic library files to LD_LIBRARY_PATH. The software's installation instructions typically explains what you need to do.

[1]An alternative to changing PATH is to add a symlink to each new executable, in a directory that's already in your PATH. GNU Stow can help you do this.

like image 172
Mark Plotnick Avatar answered Oct 30 '25 07:10

Mark Plotnick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!