juliaup icon indicating copy to clipboard operation
juliaup copied to clipboard

Allow disable prompting or answer "yes" to all questions

Open jlapeyre opened this issue 3 years ago • 9 comments

Doing non-interactive installation is sometimes needed for installing to containers and for test environments. Perhaps via environment variables.

Hope this is not a dup. I looked for a while.

I am not sure when with_prompt is called. juliaup is already installed on my machine. When I try to add a new version with juliaup add x.y.z I get no prompting. But, at least the first time I installed julia, I was prompted.

jlapeyre avatar Feb 22 '22 19:02 jlapeyre

Seconding this - this would be a really useful feature!

calebwin avatar Feb 24 '22 23:02 calebwin

I think the only case where we have interactivity at the moment is the initial install, if it is done via the shell script route. And agreed, we should add a quiet option there, plus also command line arguments to configure all the things that one can configure via prompts at the moment.

davidanthoff avatar Mar 05 '22 19:03 davidanthoff

Just a reminder. I am trying to install Julia via juliaup in a docker container. Unless someone has another idea, I think this is a blocker.

jlapeyre avatar Mar 15 '22 18:03 jlapeyre

I would also be interested in this use case.

DanteOz avatar Apr 03 '22 22:04 DanteOz

I would also be very keen to make this use-case possible. At the minute, it's unclear to me how one should automatically install JuliaUp in a non-interactive manner, which is important to me for automating the set up of new machines

willtebbutt avatar Aug 09 '22 10:08 willtebbutt

It's a bit confusing at the moment because in the install script at https://install.julialang.org, it says Unable to run interactively. Run with -y to accept defaults, --help for additional options but the line 95 is commented out:

            # "-y"|"--yes")       _y=yes; need_tty=no ;; # skip prompt; no need for /dev/tty

so passing -y doesn't actually work

blegat avatar Aug 28 '22 08:08 blegat

Same issue here, we are trying to build an AMI for EC2 instances and this seems to be a blocking issue. I'm wondering what's the blocking item here that preventing this feature/bug being fixed?

Roger-luo avatar Sep 13 '22 13:09 Roger-luo

@blegat I encountered the same issue, while trying to install juliaup on Google Colab.

Uncommenting line 95 in the juliaup-install.sh, everything proceeds and the juliaup installer is downloaded and launched. But it too prompts the user and fails in my use case (i.e. within a cell of a jupyter notebook, invoking shell commands, user interaction is not allowed).

mgiugliano avatar Oct 02 '22 08:10 mgiugliano

I had a brief look into the code, it seems the prompt comes from the new self-update code in rust. I'm not sure how to change that, however.

Roger-luo avatar Oct 03 '22 04:10 Roger-luo

Hey, just pinging this. This is really important to have. I'm building a docker container and I'm pretty much forced to use the base Julia image despite Julia being just one of several dependencies, since I literally can't use juliaup in a non-interactive way.

@davidanthoff why did you comment out the -y option in commit https://github.com/JuliaLang/juliaup/commit/4ed907bc8ca9835bb951ac0289a6436b59aa0196? Could this be reverted?

MilesCranmer avatar Nov 15 '22 20:11 MilesCranmer

I really needed this so I came up with a workaround to get things working with the existing script, which I share below.

Surprisingly you can't just do echo '\n' | juliaup.sh. I think rustup (which juliaup based on) checks for interactivity in a non-standard way which makes this not work.

This workaround requires linux's expect tool. It also assumes that the user prompt ends with Cancel installation. If that changes, this will break.

Anyways, here's the non-interactive install script, given you've downloaded the existing shell script to juliaup-init.sh

#!/usr/bin/expect
spawn juliaup-init.sh
expect "Cancel installation"
send -- "\r"
expect eof

This will wait for "Cancel installation" to show up, and then send a carriage return back. That's all you need.

Here's my docker commands which let you use juliaup:

RUN apt-get update && apt-get install -y expect && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install juliaup:
RUN curl -fsSL https://install.julialang.org -o /tmp/install-julia.sh && \
    echo '#!/usr/bin/expect\nspawn /tmp/install-julia.sh\nexpect "Cancel installation"\nsend -- "\\r"\nexpect eof' > /tmp/install-julia.exp && \
    chmod +x /tmp/install-julia.sh && \
    chmod +x /tmp/install-julia.exp && \
    /tmp/install-julia.exp && \
    rm /tmp/install-julia.sh && \
    rm /tmp/install-julia.exp

This works, which lets you now use juliaup inside a dockerfile!

(Depending on where you are running this, you might need to add a $ before the ' in the echo command of that dockerfile. Or you could simply copy in that expect file using the docker ADD directive.)


Edit: see below for one-line version

MilesCranmer avatar Nov 15 '22 21:11 MilesCranmer

Here is a rough roadmap to implement this feature. I won't get to it anytime soon, but maybe this helps someone else.

The first set of changes is in the shell script that bootstraps the actual binary juliainstaller onto a system:

  1. Reenable https://github.com/JuliaLang/juliaup/blob/b13ebd7a764404442dea59e3861769f476c0a2a7/deploy/shellscript/juliaup-init.sh#L90 and https://github.com/JuliaLang/juliaup/blob/b13ebd7a764404442dea59e3861769f476c0a2a7/deploy/shellscript/juliaup-init.sh#L95.
  2. Pass a flag to the juliainstaller binary (that is written in Rust) to do a quiet install in this line https://github.com/JuliaLang/juliaup/blob/b13ebd7a764404442dea59e3861769f476c0a2a7/deploy/shellscript/juliaup-init.sh#L136. Note that this flag does not yet exist in juliainstaller!

The second set of changes is that we need to add a quiet option to juliainstaller. Roughly that involves:

  1. Adding some command line argument for a quiet mode at https://github.com/JuliaLang/juliaup/blob/b13ebd7a764404442dea59e3861769f476c0a2a7/src/bin/juliainstaller.rs#L93.
  2. If that flag is set, skip all the interactive steps in juliainstaller (https://github.com/JuliaLang/juliaup/blob/main/src/bin/juliainstaller.rs) and use the defaults instead. I think that should be relatively simple, it essentially would just mean that in https://github.com/JuliaLang/juliaup/blob/b13ebd7a764404442dea59e3861769f476c0a2a7/src/bin/juliainstaller.rs#L237-L277 we would not show the prompt and be done.
  3. In quiet mode disable https://github.com/JuliaLang/juliaup/blob/b13ebd7a764404442dea59e3861769f476c0a2a7/src/bin/juliainstaller.rs#L170.

A more comprehensive solution of course would add many more command line argument options so that one can specify values for all the choices that the interactive wizard offers at the moment, but I think that could presumably be a second step?

davidanthoff avatar Nov 21 '22 23:11 davidanthoff

Wow, that's way more involved than I would have expected! I wonder if including an expect script as a semi-official way to do this would be a good idea in the meantime? Basically just adding a section to the readme with @MilesCranmer's script and some hints on how to further modify it.

StefanKarpinski avatar Nov 22 '22 13:11 StefanKarpinski

Here is a one-liner to use this:

expect -c 'spawn bash -c "curl -fsSL https://install.julialang.org | sh"; expect "Proceed"; send -- "\r"; expect eof'

MilesCranmer avatar Nov 22 '22 16:11 MilesCranmer

Another easier solution (I came here with a quick search)

curl -fsSL https://install.julialang.org | sh -s -- -y 

feefladder avatar Feb 28 '24 19:02 feefladder