Skip to content

Automatically install project toolchain version if it is not currently installed on the host #239

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

Open
bkhouri opened this issue Mar 2, 2025 · 2 comments

Comments

@bkhouri
Copy link

bkhouri commented Mar 2, 2025

It would be ideal if swiftly automatically installed the project toolchain if it's not currently installed.

Steps to reproduce

  1. Create a swift package
  2. List all installed versions
  3. In the created package, specify a version in .swift-version file that is not currently installed
  4. swift build or swift --version, or swift test etc...
❯ swift --version
The swift version file `/Users/bkhouri/Documents/git/public/swiftlang/swift-package-manager/.swift-version` uses toolchain version main-snapshot-2025-02-24, but it doesn't match any of the installed toolchains. You can install the toolchain with `swiftly install`

Instead of that message, running swift should automatically install the version of the toolchain, thus streamlining the build process.

@bkhouri bkhouri changed the title Automatically install toolchain Automatically install project toolchain version if it is not currently installed on the host Mar 2, 2025
@cmcgee1024
Copy link
Member

This would be a nice feature. There are a few things to consider.

People running a toolchain command like swift or lldb might find it surprising that a seemingly local and fast operation is instead of network intensive, and long running operation. Sometimes the download can be more than 1GB.

Because you're running a toolchain command, there's no opportunity to specify any command-line options for the swiftly install command, such as --use to use the toolchain for the next commands, or the --verify/--no-verify options.

Note that the install operation is potentially fallible, requiring system packages to be installed before continuing with the toolchain command that was originally requested. System packages are installed by the user either by running the recommended command as root, or specifying as a command-line parameter the "post-install file" where the command is placed. In the case of the latter there is no way to specify that command-line option in this workflow.

Given these considerations this is why swiftly currently opts to give an actionable message in this situation.

@kateinoigakukun
Copy link
Member

rustup has a similar functionality to automatically install toolchain when a proxy binary is invoked. However, they removed the feature for its too much implicit behavior:

(And unfortunately they had to revert the change because it caused disaster to many CIs)

I feel the current swiftly decision is reasonable.

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