Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider changing the installation location #383

Open
kkebo opened this issue May 3, 2024 · 9 comments
Open

Consider changing the installation location #383

kkebo opened this issue May 3, 2024 · 9 comments

Comments

@kkebo
Copy link

kkebo commented May 3, 2024

Currently, a swift toolchain is installed under /usr/bin.

https://github.com/apple/swift-docker/blob/88941f87eaded894699adae832cd0a820ee544ae/nightly-6.0/ubuntu/22.04/Dockerfile#L62

This is a problem because apt packages overwrites them. For example, apt-get install llvm overwrites Swift's builtin LLVM tools by themselves so that LLVM tools is downgraded from 17 to 14.

@finagolfin
Copy link

This is a known issue with the Swift toolchain, which is why Fedora installs it in /usr/libexec/swift/5.8.1/ instead.

@kkebo
Copy link
Author

kkebo commented May 8, 2024

Thank you for the information.

However, when it comes to swift-docker, I think this problem can be solved with small modifications like this:

diff --git a/nightly-main/ubuntu/22.04/Dockerfile b/nightly-main/ubuntu/22.04/Dockerfile
index 31496b5..1088ee2 100644
--- a/nightly-main/ubuntu/22.04/Dockerfile
+++ b/nightly-main/ubuntu/22.04/Dockerfile
@@ -59,8 +59,8 @@ RUN set -e; \
     && curl -fSsL https://swift.org/keys/all-keys.asc | gpg --import -  \
     && gpg --batch --verify latest_toolchain.tar.gz.sig latest_toolchain.tar.gz \
     # - Unpack the toolchain, set libs permissions, and clean up.
-    && tar -xzf latest_toolchain.tar.gz --directory / --strip-components=1 \
-    && chmod -R o+r /usr/lib/swift \
+    && tar -xzf latest_toolchain.tar.gz --directory /usr/local --strip-components=2 \
+    && chmod -R o+r /usr/local/lib/swift \
     && rm -rf "$GNUPGHOME" latest_toolchain.tar.gz.sig latest_toolchain.tar.gz \
     && apt-get purge --auto-remove -y curl

@finagolfin
Copy link

Feel free to submit a pull, and someone may review it.

@kkebo
Copy link
Author

kkebo commented May 9, 2024

I was wrong. My suggestion will be a breaking change if there's a user who expects swift to be in /usr/bin/swift.

@finagolfin
Copy link

That's why Fedora adds symlinks into /usr/bin/.

@kkebo
Copy link
Author

kkebo commented May 9, 2024

I don't think so. Fedora's package manager always needs to install packages under /usr, but docker images don't have such restrictions. The whole problem with swift-docker is just a compatibility issue.

@finagolfin
Copy link

Right, Fedora worked around this issue already by installing the Swift toolchain into /usr/libexec/swift/5.8.1/ instead and symlinking Swift executables into /usr/bin/. These docker images could do the same.

@FranzBusch
Copy link
Member

It might be worth considering if we could do a one-time change of install locations for Swift 6 cc @shahmishal

@kkebo
Copy link
Author

kkebo commented May 10, 2024

Right, Fedora worked around this issue already by installing the Swift toolchain into /usr/libexec/swift/5.8.1/ instead and symlinking Swift executables into /usr/bin/. These docker images could do the same.

Like swift-ci images, if Swift executables are installed into $SWIFT_PREFIX/ and $SWIFT_PREFIX/usr/bin has a higher priority position than /usr/bin in $PATH, it may be acceptable to copy the executable to /usr/bin for compatibility.

However, we may not be able to use symbolic links for that purpose. Because symlinking Swift executables does not work in Swift 6.0 due to swiftlang/swift#70932 at least for now. It has been fixed on the main branch, but not on the release/6.0 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants