The sound distributed version control system

#486 No such subcommand: "uptime"

Closed on August 4, 2021
tankf33der on July 21, 2021

If I run wrong subcommand from user or root it gives me different errors:

$ id 
uid=1000(mpech) gid=1001(mpech)
$ pijul uptime
Error while running "uptime": Permission denied (os error 13)
$ sudo bash
$ id
id=0(root) gid=0(root)
$ pijul uptime
No such subcommand: "uptime"
$
fogti on July 21, 2021

could you try to run both through strace -f?

tankf33der on July 22, 2021

mpech: strace -f pijul uptime -> https://envs.sh/gZ.txt

root: strace -f pijul uptime -> https://envs.sh/gL.txt

fogti on July 22, 2021

ok, difference:

# root
[pid 176369] execve("/root/.gem/ruby/3.0.0/bin/pijul-uptime", ["pijul-uptime"], 0x7ffdeed5b960 /* 29 vars */) = -1 ENOENT (No such file or directory)
[pid 176369] write(2, "No such subcommand: ", 20No such subcommand: ) = 20
# mpech
[pid 176307] execve("/root/.gem/ruby/3.0.0/bin/pijul-uptime", ["pijul-uptime"], 0x7fff448f16e0 /* 64 vars */) = -1 EACCES (Permission denied)
[pid 176307] write(2, "Error while running ", 20Error while running ) = 20

so this is somewhat expected, mpech can’t access /root/.gem/ruby/3.0.0/bin, but I wonder how that ended up in $PATH (I suppose pijul / rust runtime just uses that to find executables via name)…

coconut on July 24, 2021

Huh, why is it even attempting to execute pijul-uptime to begin with? Subcommands are actually separate binaries now? If not, then I do not understand the reason. Plus, since the executable pijul-uptime does exist and as root you do have permission for it, how come it says there is no such subcommand? That makes me think that after all, no, subcommands are not separate binaries, but for unknown reasons it tries to execute pijul-SUBCOMMAND that it finds in $PATH and is most likely a bug. So after all, the important and odd thing here is that it attempts to execute the command pijul-SUBCOMMAND from $PATH instead of its own internal subcommand argv[1], which is uptime in this case.

May I have some clarification please?

pmeunier on August 3, 2021

@coconut: there are “core” subcommands, and the Pijul CLI is extensible: if Pijul can’t find a subcommand with some name, it will try to run pijul-… instead.

I can’t reproduce this one (I get “No such command” as a non-root user). @tankf33der, if you still run into this, can you tell us more about your $PATH (is /root/.gem/ruby/3.0.0/bin in mpech’s $PATH?).

pmeunier on August 3, 2021

Thanks. Just out of curiosity, what happens when you run pijul-uptime in a bash shell, both as mpech and as root?

pmeunier on August 3, 2021

Right, but there you typed pijul uptime (without the -), my question was, is the error coming from Pijul or from the shell itself? Pijul looks for a binary called pijul-uptime in that case, so knowing what the shell returns would give an idea of what to do.

tankf33der on August 3, 2021

I dont understand how to check if error coming from shell. I missed the point.

pmeunier on August 3, 2021

Sorry for being unclear, I was just asking you about the outcome of running pijul-uptime (mind the -, this is not pijul uptime) directly in a shell, as both users.

pmeunier on August 4, 2021

Good to know. The “problem” seems to come from the way execvpe uses $PATH. The only thing we can do is probably the same bash is doing: report a permission error as a “subcommand not found”, which is what I’ve done in #NIDZT2SQUZHH4YZWNQLSJYRHZPGT2EAGHHJHGZF2XYEFUL3N3YIQC.

pmeunier closed this discussion on August 4, 2021