juliaup icon indicating copy to clipboard operation
juliaup copied to clipboard

Find a solution for a sudo based workflow

Open cstjean opened this issue 9 months ago • 8 comments

I'm working in a secured environment. juliaup worked fine, so does julia, but sudo julia fails with:

Checking for new Julia versions
Error: Failed to run `run_command_add` from the `run_command_initial_setup_from_launcher` command.

Caused by:
    0: Failed to update versions db.
    1: Failed to download current version db version.
    2: Failed to download from url `https://julialang-s3.julialang.org/juliaup/RELEASECHANNELDBVERSION`.
    3: error sending request for url (https://julialang-s3.julialang.org/juliaup/RELEASECHANNELDBVERSION)
    4: operation timed out
Error: The Julia launcher failed to figure out which juliaup channel to use.

Obviously, I can spend a week negociating with BigCo's IT department to fix the underlying issue, but I'd appreciate a shorter work-around. Is there any way to skip that check? Or to run the non-juliaup'ed julia binary directly?

Related: https://github.com/JuliaLang/juliaup/issues/705.

cstjean avatar Mar 18 '25 02:03 cstjean

It also looks like julia --version also performs startup check which increases startup time. (Things like starship prompt timeout-fails when trying to determine julia version)

pddshk avatar Oct 07 '25 12:10 pddshk

I think what is happening here is that when you run sudo julia, the launcher is run as the root user. It will then try to find the Juliaup config file in a folder in the profile of the root user instead of your user profile. Of course, nothing Juliaup specific is installed in the root profile, and in that case Juliaup tries to go through its initial setup procedure to install the release channel, create the Juliaup config file etc.

I am not entirely sure what the right course of action is here...

One option would be to check whether we are run via sudo and check something like SUDO_USER, and then try to locate the Juliaup config stuff in the profile for that user.

Another thinking might be that when one runs sudo juliaup or sudo julia one actually wants to access a Juliaup depot that is in the root profile...

I am not familiar enough with Linux to say which of these is the right approach :)

davidanthoff avatar Nov 05 '25 01:11 davidanthoff

I am not familiar enough with Linux to say which of these is the right approach :)

Should behave as root.

Keno avatar Nov 05 '25 01:11 Keno

Ok, so (I think) that is what it is doing right now.

So essentially the story here is that if you install Juliaup as non root, and then run sudo julia you don't have a Juliaup install for root, and you need network access to get an initial install for root going.

davidanthoff avatar Nov 05 '25 01:11 davidanthoff

At the very least, julia or sudo julia should always start julia, regardless of whether the juliaup check failed or not...

cstjean avatar Nov 07 '25 02:11 cstjean

Well, Juliaup performs an install into a specific user profile. If the idea of sudo is that the next command is entirely run in the context of a different user (namely root), then it is unclear to me what should happen. Juliaup/Julia isn't installed in the root profile. So unless we look back into the original user profile where sudo was launched from, I don't really see how that could work?

Now, the twist here is that currently Juliaup is trying to install a Juliaup depot into root and that is not working because apparently there is no network connection. So that is an additional complication.

davidanthoff avatar Nov 07 '25 16:11 davidanthoff

I am not well-versed in Unix permissions, but on an OSX machine that does not use juliaup (the julia executable is in the PATH), sudo julia works fine at first glance. It found the correct default environment (from my home directory).

cstjean avatar Nov 13 '25 03:11 cstjean

It found the correct default environment (from my home directory).

So, it used the home directory not of root, but of the user that launched sudo, right? I understood @Keno above as saying that is not the right behavior...

davidanthoff avatar Nov 13 '25 17:11 davidanthoff