yofi icon indicating copy to clipboard operation
yofi copied to clipboard

ENOENT: Panicking when exec executables

Open StayPirate opened this issue 2 years ago • 2 comments

Dunno why but yofi binapps tries to run $TERM when execvp.

> yofi --verbose binapps
[2022-06-30][13:45:10][yofi::exec][DEBUG] execvp: "tmux-256color" ["tmux-256color", "/home/crazybyte/.local/bin/weechat"]
thread 'main' panicked at 'execvp failed: ENOENT', src/exec.rs:60:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2022-06-30][13:45:10][yofi][ERROR] panic: execvp failed: ENOENT

I saw an undocumented option to overwrite it, so I set term to zsh and it works.

~/.config/yofi/yofi.config:

[...]
term = "zsh"
[...]

Might I know why it is happening and if it is an intended behavior?

I'm using yofi-git on Archlinux.

StayPirate avatar Jun 30 '22 12:06 StayPirate

From man execve(2):

By convention, the first of these strings (i.e., argv[0]) should contain the filename associated with the file being executed.

In particular firefox segfaults, if the first arg is not binary itself.

Also from man:

ENOENT The file pathname or a script or ELF interpreter does not exist.

which means the problem is in the running tmux-256color rather than its argument.

l4l avatar Jul 01 '22 00:07 l4l

Right, so why yofi tries to run tmux-256color in first instance?

StayPirate avatar Jul 01 '22 07:07 StayPirate

I hit this too. FWIW I don't see why spawning an app requires a terminal invocation in the first place.

Ristovski avatar Sep 26 '22 20:09 Ristovski

why yofi tries to run tmux-256color in first instance?

Didn't answer at that time, still don't remember why I did it :\ See linked PR

Thanks for bumping the issue!

l4l avatar Sep 30 '22 18:09 l4l

Yeah, ok. I figure out the reason. Certain apps have Terminal=true field as specified in XDG spec. vim as an example if launched without term it simply quits.

There are several approaches to guess the default terminal since there's no standard way of querying one. $TERM env is one of the options that seems to behave quite poorly.

So far the $TERM heuristic removed and I leave the decision to set-up the term config up to the user. If not set most of Terminal=true apps won't launch as there's no (unless yofi launched from terminal) stdin/stdout.

l4l avatar Sep 30 '22 19:09 l4l