Skip to content

Inconsistent behavior between init and install regarding post-install commands #348

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
vzsg opened this issue May 9, 2025 · 0 comments

Comments

@vzsg
Copy link

vzsg commented May 9, 2025

I've noticed that the init and the install command behave differently when the tool decides that there are post-install commands to be executed.

Consider the following (executed in an ubuntu:24.04 container):

# apt-get update && apt-get install curl gpg -y
[...]
# curl -sL -O "https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz"
# tar xfz "swiftly-$(uname -m).tar.gz"
# ./swiftly init --quiet-shell-followup -y
[...]
Installing Swift 6.1.0
[...]
Swift 6.1.0 installed successfully!
There are some dependencies that should be installed before using this toolchain.
You can run the following script as the system administrator (e.g. root) to prepare
your system:

    apt-get -y install binutils git unzip gnupg2 libc6-dev libcurl4-openssl-dev libedit2 libgcc-13-dev libpython3-dev libstdc++-13-dev libxml2-dev libncurses-dev libz3-dev pkg-config tzdata zlib1g-dev

# echo $?
0

In short, when the init command preinstalls the latest version, the post-install command is just an advice, but the command succeeded. This is good.

However, if I am to install a different version with swiftly install, there are two possible outcomes.

  1. If the --post-install-file parameter is not used, the command exits with status 1! That error exit code can, for example, break the build of the application on Heroku (ask me how I learned that).
# swiftly install --use 6.0.3
Installing Swift 6.0.3
[...]
Swift 6.0.3 installed successfully!
NOTE: We have updated some elements in your path and your shell may not yet be
aware of the changes. You can run this command to update your shell.

    hash -r

Error: 
There are some dependencies that should be installed before using this toolchain.
You can run the following script as the system administrator (e.g. root) to prepare
your system:

apt-get -y install binutils git unzip gnupg2 libc6-dev libcurl4-openssl-dev libedit2 libgcc-13-dev libpython3-dev libstdc++-13-dev libxml2-dev libncurses-dev libz3-dev pkg-config tzdata zlib1g-dev
# echo $?
1
  1. Or when --post-install-file is used, the exit code is zero, and everything works out fine. There are even considerably less log lines on the console.
# swiftly install --use 6.0.2 --post-install-file postinstall.sh
Installing Swift 6.0.2
[...]
Swift 6.0.2 installed successfully!
root@147ea1585345:/# echo $?
0

Out of the two behaviors, I definitely prefer the init version of returning successfully, with some advisory messages on the console. Alternatively, it would be nice to have a --skip-post-install flag to completely skip the check1 in both commands.

What do you think?

Footnotes

  1. I did not look into which package exactly is triggering the issue – but there's also nothing to do about it. On Heroku, installing extra packages with apt-get is not possible. It shouldn't be necessary in the first place, as the stack image contains everything that Swift apps usually need.

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

1 participant