JuliaLang/juliaup

Defensively making juliaup availible on $PATH

tecosaur opened this issue · 1 comments

Once again copying over from a conversation on Slack with David, I'm sharing my proposal on how juliaup could approach making julia/juliaup availible to run at the shell, while making as few assumptions about the user's system as reasonably possible.

  1. Look on current $PATH and the default/fallback juliaup install dir for an existing install of juliaup
  2. Look for the standard user executable folder(s)
  3. Identify the login shell using the first successful rule:
    a. Read $SHELL
    b. Check getent passwd ${USER:-$(whoami)} (linux)
    c. Check dscl . -read /Users/${USER:-(whoami)} UserShell (darwin)
    d. Look for known shell config files (also needed for step 7), taking into account system configuration ($ZDOTDIR affects ZSH, $XDG_CONFIG_HOME affects Fish, etc.)
  4. If a standard executable folder already exists, or is placed on $PATH by a login shell, create or link the juliaup binary there. Stop here, further steps are not needed.
  5. If a shell RC file exists for the user, attempt to edit $PATH in it.
    a. If it cannot be modified, inform the user and ask if they'd like to:
    i. Using sudo, make the file read-write for the current user, and modify normally
    ii. Abort and make the $PATH change manually themselves
    iii. Using sudo, forcibly modify the shell file
  6. If a shell RC file does not exist, create it.
  7. If other shell files were detected, optionally or eagerly modify them too
  8. Run a login shell to confirm that juliaup is indeed added to $PATH

I'll note that step No.4 on Linux is covered in more detail, with a few extra comments, in #844. However, that issue got sidetracked talking about the impact of XDG and Linux norms on Julia again, which is a different problem from being able to run Julia in the first place.

Where does ~/.local/bin fall into this? I'm not quite sure how it got there but that appears to be on my mac's $PATH.

Also, mise, pixi, starship, direnv all have a subcommand that a user can eval to add the appropriate paths into the user path:

eval "$(mise activate zsh)"
eval "$(pixi completion --shell zsh)"
eval "$(starship init zsh)"
eval "$(direnv hook zsh)"

This may be something to consider when Julia app support drops?