Skip to content

Conversation

patrickfreed
Copy link
Contributor

Closes #42

This PR updates swiftly-install.sh to create $SWIFTLY_HOME_DIR/env.sh, which contains the required environment variable definitions needed to run swiftly. After installation, users can source it to enable using swiftly in their current shell easily.

This PR also updates swiftly-install.sh to optionally modify the user's login shell configuration profile (on by default) to include a line that sources the aforementioned env.sh file. For right now, only one of .profile, .bash_profile, .bash_login, or .zprofile will be modified, depending on the value of $SHELL and the existence of said files. In other words, only login configuration files will be modified but not any per-shell rc files like .bashrc. The reasons for this are twofold: 1) environment variables that are inherited by subshells are supposed to be defined in a login configuration file, not an rc file, since otherwise they would get redefined in each subshell, possibly recursively (as is the case with $PATH), 2) this approach is more conservative and can be extended in the future should .profile and friends prove to be insufficient. rustup takes the opposite approach of putting . $HOME/.cargo/env` in every profile or rc file it can find, but that seems like it might be overkill.

@patrickfreed
Copy link
Contributor Author

@swift-server-bot test install please

@patrickfreed
Copy link
Contributor Author

@swift-server-bot test install please

@patrickfreed patrickfreed marked this pull request as ready for review April 25, 2023 05:58
Copy link
Contributor

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@patrickfreed
Copy link
Contributor Author

@swift-server-bot test install please

@patrickfreed patrickfreed merged commit 81d7607 into swiftlang:main May 3, 2023
@gregcotten
Copy link

gregcotten commented Oct 22, 2024

This has never worked for me on any clean vanilla Ubuntu 20, 22, or 24 installs. I'm not entirely sure why, but the "Terminal" app in Ubuntu simply doesn't load the .profile file by default. So I run the swiftly curl install incantation and have to manually add the env.sh invocation in the user's .bashrc

Perhaps relevant: https://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile/183980#183980

On modern unices, there's an added complication related to ~/.profile. If you log in in a graphical environment (that is, if the program where you type your password is running in graphics mode), you don't automatically get a login shell that reads ~/.profile. Depending on the graphical login program, on the window manager or desktop environment you run afterwards, and on how your distribution configured these programs, your ~/.profile may or may not be read. If it's not, there's usually another place where you can define environment variables and programs to launch when you log in, but there is unfortunately no standard location.

@gregcotten
Copy link

rustup takes the opposite approach of putting . $HOME/.cargo/env` in every profile or rc file it can find, but that seems like it might be overkill.

There might be a reason for this :)

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

Successfully merging this pull request may close these issues.

Provide an env file that can be used to quickly set up swiftly installation
3 participants