Skip to content
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

Defensively making juliaup availible on $PATH #1013

Open
tecosaur opened this issue Aug 19, 2024 · 1 comment
Open

Defensively making juliaup availible on $PATH #1013

tecosaur opened this issue Aug 19, 2024 · 1 comment

Comments

@tecosaur
Copy link

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.

@kdheepak
Copy link
Contributor

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?

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

2 participants