raspberrypi / pico-setup

92 stars 42 forks source link

Please write environment variable configuration to ~/.pam_environent and ~/.profile, or /etc/profile.d instead of ~/.bashrc #13

Open scratch-er opened 3 years ago

scratch-er commented 3 years ago

This script write environment variable configuration to ~/.bashrc, which means that this configuration will only take effect in an interactive bash session. However, users may want to launch the IDE under a graphical environment, or they may wish to use a different shell, e.g. zsh. So the configuration should be writen to ~/.pam_environment and ~/.profile instead. Alternatively, if the configuration needs to take effect for all users, the script should create a new file in /etc/profile.d and write the configuration there.

lurch commented 3 years ago

ping @XECDesign @liamfraser Would changing https://github.com/raspberrypi/pico-setup/blob/master/pico_setup.sh#L71 to write to ~/.profile instead of ~/.bashrc be a good solution? I have to confess I've never heard of ~/.pam_environment - how does that differ from ~/.profile ?

Although bear in mind I'm not sure how much support we should give to non-standard setups...

XECDesign commented 3 years ago

Can't find anything about ~/.pam_environment either. Since the script installs the SDK into the user's home directory, ~/.profile seems appropriate. For the deb package (when that existed), I was using /etc/profile.d/, which is the system-wide equivalent

bablokb commented 3 years ago

Your patch suffers from the same problem as the original script, i.e. if ~/.profile does not end with a new line, you create garbage. See issue #12

michaelstoops commented 3 years ago

I agree that ~/.bashrc is not the ideal place for these. I think ~/.profile works for the Bourne family of shells. For zsh, you need ~/.zprofile. See http://zsh.sourceforge.net/Guide/zshguide02.html, section 2.2.

I don't think that installing to a global location (/etc/profile) is a good idea. Besides file permissions, etc, build dirs are by nature stateful, and you generally don't want others messing with the state of your build dir. If you want something to be shared across the system, install the build products to proper global locations.

lurch commented 3 years ago

@michaelstoops See the proposed fix in #14 This script was only written to run on up-to-date installations of Raspberry Pi OS running on a Raspberry Pi, with "out of the box" settings, and therefore it only supports bash and not zsh.

theAkito commented 3 years ago

I see no point in supporting such weird exceptions. This script runs on most target platforms, i.e. works with ~/.bashrc.

I also never heard of ~/.pam_environment before and I've never really seen ~/.profile being used at all. Not sure, if this would even work as expected on most operatings systems. ~/.bashrc is the in my opinion best way to handle this. All the rare exceptions may be handled exclusively, by e.g. adjusting the installation script, through e.g. making it possible to provide a variable alternative to ~/.bashrc as a command line option to the script. However, I would oppose changing the default. ~/.bashrc is the best default for almost all users. The remaining users may customize the setup script.

aallan commented 3 years ago

I also never heard of ~/.pam_environment before and I've never really seen ~/.profile being used at all. Not sure, if this would even work as expected on most operatings systems. ~/.bashrc is the in my opinion best way to handle this. All the rare exceptions may be handled exclusively, by e.g. adjusting the installation script, through e.g. making it possible to provide a variable alternative to ~/.bashrc as a command line option to the script. However, I would oppose changing the default. ~/.bashrc is the best default for almost all users.

Depends on your platform, macOS uses .bash_profile for instance, not .bashrc.

The remaining users may customize the setup script.

That's the whole point of #20. The original script worked just fine for Raspberry Pi OS on a Pi 4. It worked less well for other users on other platforms. So there is an ongoing PR process to improve the script.