Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zellij run -- <exec> <args> yields Command not found: <exec> #3599

Open
justkash opened this issue Sep 11, 2024 · 5 comments
Open

zellij run -- <exec> <args> yields Command not found: <exec> #3599

justkash opened this issue Sep 11, 2024 · 5 comments

Comments

@justkash
Copy link

Issue Description

The command zellij run cannot see all executables that are part of $PATH. In my case, I use nix to manage executables; I will often have binaries that are only relevant to a given project defined within a flake.nix file. Nix then ensures that declared binaries are installed and included in the $PATH. However, when I run zellij run -- cargo run, I get the following message:

Command not found: cargo
If you were including arguments as part of the command, try including them as 'args' instead.

The command cargo is available at the location /nix/store/q5fs39w0pshsvp1icdpfnx8vkf6m3fx4-cargo-nightly-minimal-2024-09-11/bin/cargo and I can execute it within the terminal otherwise. Note that I have multiple versions of cargo on my system including one at Users/<user>/.cargo/bin and zellij run is still unable to see either executable.

System Information

Command Result
zellij --version zellij 0.40.1
stty size 34 122
uname -av Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 arm64 arm Darwin

Reproduction Steps

  1. Run zellij run -- <command not under /bin or without explicit path>
@Zykino
Copy link
Contributor

Zykino commented Sep 11, 2024

Note that zellij run -- … does not run your shell, it start the command immediately. I don’t know how nix work or how you started your zellij server (first command that started the session you are in.). So zellij run -- … use the $PATH given to it when starting its server.

Now on the help part: You can check the $PATH with zellij run -- env.
Fix: Make sure to start zellij from sowewhere that already have the $PATH however you want it to. If you want to auto-start it when starting your terminal, you usually can use the -c option of your shell: fish -c zellij.

@HKalbasi
Copy link

Wouldn't be a good idea for zellij run to inherit the $PATH from the current environment instead of the starting one? Using the current shell's $PATH feels more natural to me.

@justkash
Copy link
Author

Note that zellij run -- … does not run your shell, it start the command immediately. I don’t know how nix work or how you started your zellij server (first command that started the session you are in.). So zellij run -- … use the $PATH given to it when starting its server.

Is there a way to get zellij to inherit $PATH from the current environment? Nix shells populate the current environment with binaries relevant to the project in which the flake.nix file is found. So, for cases where I rely on tools defined in the flake.nix file, I cannot use the environment determined when zellij is first started.

Now on the help part: You can check the $PATH with zellij run -- env. Fix: Make sure to start zellij from sowewhere that already have the $PATH however you want it to. If you want to auto-start it when starting your terminal, you usually can use the -c option of your shell: fish -c zellij.

I start zellij directly without a shell process parenting it. Zellij for me runs as the first process for my terminal emulator. So I don't think your solution would work for me.

@Zykino
Copy link
Contributor

Zykino commented Sep 12, 2024

Wouldn't be a good idea for zellij run to inherit the $PATH from the current environment instead of the starting one? Using the current shell's $PATH feels more natural to me.

For me too but it is how it is. I don’t code this just helping on the support side 😅

I start zellij directly without a shell process parenting it. Zellij for me runs as the first process for my terminal emulator. So I don't think your solution would work for me.

This is not an issue. You can configure your terminal to start your shell and tell it to start zellij (either by auto-load or by giving it the command).

Is there a way to get zellij to inherit $PATH from the current environment? Nix shells populate the current environment with binaries relevant to the project in which the flake.nix file is found. So, for cases where I rely on tools defined in the flake.nix file, I cannot use the environment determined when zellij is first started.

This is more problematic since you don’t get the environment you want.

This is this problem that initially made me try to create a plugin (https://github.com/Zykino/zellij-console) that try to expose the plugin API to the user. At first I was limited to only from a plugin pane, and now thanks to pipes I can work with CLI. But I did not have time to work on it when pipes were introduced, I adapted to them only recently. I still have some issues with kind of everything, but I want to release a first version soon TM even with issues… Right now the run commands is deactivated, but I will try to re-enable it ASAP (even if without the first official release).
Note: Re-activating it I can’t use people default’s shell because of #2871. Will see what I can do 🤔

@aquacode
Copy link

aquacode commented Oct 4, 2024

Macos/Alacritty user here:
I seem to be having a similar issue with some binaries that I'm setting for the command in a pane within my custom layout. Executable is not found when launching the session with custom layout but if I drop into the shell it's no problem. Any workaround for getting these binaries to work in the layout/pane/command?

As I continued to search after posting this I found this #2349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants