Amber icon indicating copy to clipboard operation
Amber copied to clipboard

[BUG] Check if user is root on install.ab

Open shanduur opened this issue 5 months ago • 12 comments

Describe the bug There is no way to install Amber system wide when running as root, e.g. while building container.

To Reproduce

FROM debian:12

RUN apt-get update && apt-get install --yes --no-install-recommends bash bc ca-certificates curl tar xz-utils

RUN curl -sL "https://github.com/amber-lang/amber/releases/download/0.4.0-alpha/install.sh" | bash

Expected behavior Successful install

Additional context N/A

shanduur avatar Jul 22 '25 15:07 shanduur

The script has a prompt so as you are using it, it will not work anyway.

Mte90 avatar Jul 22 '25 16:07 Mte90

Right. I still think that sudo check might be also performed with UID == 0 test. What do you think?

shanduur avatar Jul 23 '25 05:07 shanduur

we have now in std a method to check if the user is root but is a complete different issue

Mte90 avatar Jul 23 '25 08:07 Mte90

https://github.com/amber-lang/amber/blob/staging/setup/install.ab as reference we are not checking if the user is root.

Mte90 avatar Jul 23 '25 08:07 Mte90

I'm away from home today. Can anyone provide me with some additional context of what happens when user is a root?

Ph0enixKM avatar Jul 27 '25 08:07 Ph0enixKM

It tries to use sudo which is not needed and fails on systems without sudo installed.

shanduur avatar Jul 27 '25 09:07 shanduur

@Mte90 @lens0021 maybe a new sudo command modifier would be good enough. This would insert sudo if there is a need for it.

sudo $ mv /test.txt /test1.txt $

This command would evaluate to this logic:

if (user is a root) {
  run the command without sudo
} else if (sudo command is installed) {
  run the command with sudo  
} else {
  run the command without sudo
}

We can further extend this logic later on with a header code that detects what is installed on the OS: sudo, doas or any other command.

Ph0enixKM avatar Sep 22 '25 10:09 Ph0enixKM

I proposed that one year ago https://github.com/amber-lang/amber/issues/220

Mte90 avatar Sep 22 '25 10:09 Mte90

Blocking the fix of this issue until implementing a new feature seems as an overkill to me. Isn't a quick fix needed?

lens0021 avatar Sep 25 '25 02:09 lens0021

Yeah if someone can implement a workaround in the meantime is fine :-)

Mte90 avatar Sep 25 '25 07:09 Mte90

True. I'll try to get my hands on this

Ph0enixKM avatar Sep 26 '25 12:09 Ph0enixKM

Now we have to rewrite the installer script to better work with sudo.

Ph0enixKM avatar Sep 30 '25 15:09 Ph0enixKM