[BUG] Check if user is root on install.ab
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
The script has a prompt so as you are using it, it will not work anyway.
Right. I still think that sudo check might be also performed with UID == 0 test. What do you think?
we have now in std a method to check if the user is root but is a complete different issue
https://github.com/amber-lang/amber/blob/staging/setup/install.ab as reference we are not checking if the user is root.
I'm away from home today. Can anyone provide me with some additional context of what happens when user is a root?
It tries to use sudo which is not needed and fails on systems without sudo installed.
@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.
I proposed that one year ago https://github.com/amber-lang/amber/issues/220
Blocking the fix of this issue until implementing a new feature seems as an overkill to me. Isn't a quick fix needed?
Yeah if someone can implement a workaround in the meantime is fine :-)
True. I'll try to get my hands on this
Now we have to rewrite the installer script to better work with sudo.