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

Add juliaup-init installer for Windows, Linux and OSX #143

Merged
merged 14 commits into from
Nov 21, 2021
Merged

Add juliaup-init installer for Windows, Linux and OSX #143

merged 14 commits into from
Nov 21, 2021

Conversation

heetbeet
Copy link
Contributor

@heetbeet heetbeet commented Sep 9, 2021

Related to #84

@heetbeet
Copy link
Contributor Author

heetbeet commented Sep 10, 2021

I have written the installation script as a polyglot in order for the same script to run on sh as well as Windows Cmd+Powershell. I have done some extra work on the installation side to integrate with the environment, that should eventually move to juliaup self install:

  • On Windows we prompt the user if they want to add to PATH and then automatically do it for them.
  • On Windows we copy julialauncher.exe as julia.exe in order to overcome the frustrating lack of symlink privilges
  • On *nix we symlink julialauncher as julia right next to it
  • On *nix we guide the user into adding juliaup & julia to their path, eg.
To add juliaup to PATH, run:
    sudo ln "/home/simon/.juliaup/bin/juliaup" /usr/local/bin/juliaup -s
    sudo ln "/home/simon/.juliaup/bin/julialauncher" /usr/local/bin/julia -s 

#104

@PhilipVinc
Copy link
Contributor

PhilipVinc commented Sep 15, 2021

I tested the script on Mac.
It runs fine, however the message add julep to PATH should be changed from sudo ln .... -s to sudo ln -s ... because I believe ln in macOS is not fully compliant...

➜  ml-intro sudo ln "/home/simon/.juliaup/bin/juliaup" /usr/local/bin/juliaup -s
Password:
ln: -s: No such file or directory

juliaup-init.sh.cmd Outdated Show resolved Hide resolved
Co-authored-by: Filippo Vicentini <[email protected]>
@heetbeet heetbeet changed the title Add juliaup-init installer for Windows, Linux and OSX(untested) Add juliaup-init installer for Windows, Linux and OSX Sep 16, 2021
Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

It looks like this could be useful, and I think it makes a lot of sense just to copy rustup's implementation. Could use a link to their source repo I guess.

The polyglot script is very entertaining but from a practical standpoint it seems more complicated than useful. Can you explain why it's better than just having two separate scripts?

README.md Outdated

### Linux and macOS Users
- Run `curl https://raw.github.com/Julialang/juliaup/master/juliaup-init.sh.cmd | sh` or [download and run](https://raw.githubusercontent.com/Julialang/juliaup/master/juliaup-init.sh.cmd) to install juliaup.
- Optionally, add the `~/.juliaup/bin` binaries to your `PATH`. Preferably, add symlinks via sudo privileges: `sudo ln "$HOME/.juliaup/bin/juliaup" /usr/local/bin/juliaup -s; sudo ln "$HOME/.juliaup/bin/julialauncher" /usr/local/bin/julia -s`.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should recommend linking things in $HOME to things in /usr/local.

  • /usr/local is a system-wide install location
  • $HOME is specific for your user

If there's any other users on the system this won't work well for them as all the files will reside in your specific $HOME directory with your permissions.


A better alternative is to recommend the use of the $HOME/.local/bin directory which is part of the XDG standard:

User-specific executable files may be stored in $HOME/.local/bin. Distributions should ensure this directory shows up in the UNIX $PATH environment variable, at an appropriate place.

Perhaps juliaup itself could be installed into $HOME/.local/bin/juliaup and we could skip the symlinks completely? If that's not possible, we can symlink it in there.

See also https://unix.stackexchange.com/questions/316765/which-distributions-have-home-local-bin-in-path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, it's messy symlinking user-level things to system-wide directories. Will think a bit about this... It might be worth asking the user if the path should be appended in ~/.bashrc like conda and rust does is. I have a strange feeling about installing it flat into $HOME/.local/bin/, since I want to be able to delete the whole directory (such as ~/.juliaup/bin) and not have side effects.




__sh__
Copy link
Member

@c42f c42f Sep 17, 2021

Choose a reason for hiding this comment

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

So... this way of combining sh and cmd and powershell within one script is clever and entertaining. IIUC

  • In sh mode, this first part is treated as a heredoc and skipped.
  • As a cmd script, the part above is a cmd bootstrapper to run powershell with the content of the file
  • As a powershell script, the whole first part is skipped and the script starts at line ~750

It's pretty amazing that can be made to work, but practically it also seems unnecessary and complicated!

Wouldn't it be cleaner just to have one script file for windows (cmd+powershell) and another for unix? I guess I just don't see the advantage in combining them. This would also reduce divergence with the original unix script at https://github.com/rust-lang/rustup/blob/master/rustup-init.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will split to julia-init.sh and julia-init.cmd


#>
# ******************************************************************
# (3) juliaup-init Windows Powershell version
Copy link
Member

Choose a reason for hiding this comment

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

Was this script also derived from somewhere else, or is it completely new?

I'm no powershell user, but rustup had interesting commentary on their equivalent thing in rust-lang/rustup#1878, though it seems that was never merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrote the script from scratch, I didn't know that there were a rustup .ps1 in the making, will have to go and see if that is a better approach.

Copy link
Contributor Author

@heetbeet heetbeet Sep 17, 2021

Choose a reason for hiding this comment

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

I see they are building a cross-platform Powershell solution with quite a discussion on using Powershell idiomatic arguments. The purpose of my Powershell implementation is to get something working on the Windows side and to mimic the .sh script as close as possible. So I think I'll keep it as a .cmd file, to distingue it from a cross-platform Powershell solution, and also that is can run under stringent Windows security settings (e.g. running powershell scripts directly is disabled by default on Windows).

- Add an add to path option in bash
- Split bash and batch implementations
@PhilipVinc
Copy link
Contributor

did this PR stall? I think it would be great to have it... I can contribute some work if needed

@davidanthoff
Copy link
Collaborator

Sorry that I sat on this so long, too many other things going on! BUT, this is fantastic!

I reviewed the Windows version pretty carefully, and one problem there is that the binaries we compile right now require a MSVC runtime that I think we can not rely on being present. When we deploy via the Store, this is not a problem because we declare that we need those and then the Store installs it for us, but we won't have that for this version. One option (I think) is to compile another version of juliaup that uses the MINGW stack and use that here, I think one can either statically link the runtime in there or it would presumably use the same (outdated) VC runtime that ships by default with Windows. Or something like that...

Another thing we should do is copy the install script as part of the release GitHub workflow somewhere, and then reference that location to users, i.e. not have them use the version on master here.

How about this: why don't we merge this as is for now, but remove the mention in the README? I think we should really only start to advertise this once we also have the self-update mechanism in place. But if we just merge this for now without mentioning it in the docs, then devs can try it more easily and we can improve with incremental PRs.

@heetbeet if that sounds OK to you, do you just want to remove the README edits, and then I'll merge?

@davidanthoff davidanthoff merged commit f8c4f6d into JuliaLang:master Nov 21, 2021
@heetbeet
Copy link
Contributor Author

Thanks for the merge, sorry this was on my todo list, but it ultimately fell off while trying to finish my academics before the end of the calendar year

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.

4 participants