JuliaLang / juliaup

Julia installer and version multiplexer
MIT License
931 stars 81 forks source link

Fails when startup scripts are inaccessible (even if asked not to modify them) #920

Open goerz opened 1 month ago

goerz commented 1 month ago

While preparing setup instructions for a tutorial, I was trying to install juliaup on a fresh macOS installation (inside an UTM virtual machine, using the default/automatic installation image provided by Apple for a minimal, unconfigured install). The VM is running Snonoma 14.4.1.

In the standard Terminal app, I tried to install juliaup with the recommended curl -fsSL https://install.julialang.org | sh, keeping all the default options. The installation failed ("Juliainstaller had a problem and crashed"). The report file boils down to

Failed to open file /Users/goerz/.bash_profile

Caused by:
    Permission denied (os error 13)

This appears to be related to some kind of macOS security feature, as I get permission denied if I try to manually run touch .bash_profile in the terminal. Similarly, for other configuration files like ~/.bashrc and ~/.zshrc, although touch random_file works. Strangely, I haven't been able to find anything on Google about this issue. The only workaround I've found is to run

sudo touch .bashrc .bash_profile .zshrc
sudo chown goerz:staff .bashrc .bashr_profile .zshrc

to create the files. Once they exist, the juliaup installation runs through without any issues.

In principle, I would expect the juliaup installer to work around any such macOS permission issues (potentially even by prompting for a sudo password).

Strangely, the crash during the juliaup installation also occurs if I customize the installation to decline "Do you want to add the Julia binaries to your PATH by manipulating various shell startup scripts?".

Even if juliaup cannot work around the permissions issue, that seems like bug! I would expect not to run into any kind of issue at all related to the startup files if I don't ask the installer to modify the startup file.

LilithHafner commented 1 month ago

Applications in mac (even Terminal) often need explicit user permission to modify "files and folders". It's hard to install software without modifying files.

See https://support.apple.com/guide/mac-help/control-access-to-files-and-folders-on-mac-mchld5a35146/mac for a mediocre explanation.

goerz commented 1 month ago

Yeah… I actually tried to put Terminal.app into the list of "Full Disk Access" apps, which (surprisingly!) didn't help, either. It's also not one of those special folders like Desktop. I actually get a popup asking for confirmation when I try to just cd into one of those. That's a little annoying, but okay… it still works. This thing where specific "system" file names inside the home folder are somehow protected (but not other files) seems like something different, and it's not something I've ever seen before, or even something I've been able to find any information about online.

goerz commented 1 month ago

Huh. I might have to walk that back a bit…

I just nuked the VM and tried the juliaup installer again, first thing (on a really clean system). And it worked! And, in fact, the issue of permission denied if I try manually touch .zshrc and similar files has disappeared, too.

My only guess is that in my previous attempt, before I tried to install juliaup, I installed Anaconda, and maybe that mucked up something in a truly strange way. I'll play around for a bit to see if I can get the error to reappear.

There's still a bug in juliaup, though: I can force the problem with

sudo  touch .zshrc
sudo chmod og-r .zshrc

That is, create an empty .zshrc file that is not readable or writable by the current user. If I then try the juliaup installation but customize the installation to say "no" to "Do you want to add the Julia binaries to your PATH by manipulating various shell startup scripts?", the installation still crashes with a permissions error.

I've further tested that when juliaup is asked not to modify the startup scripts, it indeed doesn't modify them, but apparently it still tries to access (write?) them in some way, and fails if it lacks permissions.

adrhill commented 1 month ago

Strangely, the crash during the juliaup installation also occurs if I customize the installation to decline "Do you want to add the Julia binaries to your PATH by manipulating various shell startup scripts?".

I wonder whether this is a bug or a missing feature. I opened #935 to track this since this has stopped me from using juliaup on my new machine.