Search code examples
swiftlinuxfedoraclion

Swift toolchain location on Fedora


I am trying to set up CLion to work with Swift on Fedora 32. The Swift plugin asks for a toolchain path.

I have installed Swift through swift-lang package. Running which swift returns /usr/bin/swift.

This is a symbolic link to /usr/libexec/swift/bin/swift which is the actual executable. Neither /usr/bin/swift nor /usr/libexec/swift/bin/swift seem to be the toolchain paths that CLion wants.

Any sort of help would be much appreciated.


Solution

  • I encountered the same issue and I've managed to figure it out! Basically, you need to create a usr folder under /usr/libexec/swift/ and mv all the original folders like bin, local, share, etc. to the new usr folder. Remember to recreate the symbolic links for swiftc and swift inside /usr/bin/.

    Longer version:

    Based on the comment by Cgarcia E88 here:

    Apparently the path you choose must contain the folder usr underneath, so in you(r) case it should be just / but in general if swift is located at SOME_PATH/usr/bin/swift then you must select SOME_PATH.

    After learning more about what a Swift toolchain folder looks like here, I am pretty sure that the /usr/libexec/swift/ is supposed to be the toolchain folder, albeit missing some required folder structure. By default it is:

    /usr/libexec/swift
    ├── bin
    │   ├── swift
    │   └── ...
    ├── include
    ├── lib
    ├── local
    └── share
    

    While it should be:

    /usr/libexec/swift
    └── usr
        ├── bin
        │   ├── swift
        │   └── ...
        ├── include
        ├── lib
        ├── local
        └── share