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

Plugin API: open_terminal fails when default_shell is not set #3272

Closed
SecretPocketCat opened this issue Apr 17, 2024 · 0 comments · Fixed by #3296
Closed

Plugin API: open_terminal fails when default_shell is not set #3272

SecretPocketCat opened this issue Apr 17, 2024 · 0 comments · Fixed by #3296

Comments

@SecretPocketCat
Copy link

2. Issues with the Zellij UI / behavior / crash

zellij --version:
zellij 0.41.0 (built from main)

uname -av or ver(Windows):
Linux archrig 6.8.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 16 Mar 2024 17:15:35 +0000 x86_64 GNU/Linux

Issue description

Opening a terminal pane from a plugin using the open_terminal command fails when default_shell is unset. (The same happens with open_terminal_floating, but open_command_pane works fine.

This code

open_terminal(get_plugin_ids().initial_cwd);

leads to this ERROR log

ERROR  |zellij_server::pty       | 2024-04-16 22:52:23.462 [pty       ] [zellij-server/src/pty.rs:213]: Failed to spawn terminal: failed to spawn terminal for ClientId(1)

Caused by:
    0: failed to spawn terminal for ClientId(1)
    1: failed to spawn terminal
    2: failed to open PTY for command ''
    3: could not find command '' for terminal 5

Minimal reproduction

  1. Plugin code:
use std::collections::BTreeMap;
use zellij_tile::prelude::*;

#[derive(Default)]
struct PluginState {}

register_plugin!(PluginState);

impl ZellijPlugin for PluginState {
    fn load(&mut self, _configuration: BTreeMap<String, String>) {
        request_permission(&[PermissionType::OpenTerminalsOrPlugins]);
        subscribe(&[EventType::Key]);
    }

    fn update(&mut self, event: Event) -> bool {
        match event {
            Event::Key(Key::Char('t')) => {
                open_terminal(get_plugin_ids().initial_cwd);
            }
            _ => unimplemented!("{event:?}"),
        };

        false
    }
}
  1. Layout:
layout {
    pane {
        plugin location="file:target/wasm32-wasi/release/terminal_pane_repro.wasm"
    }
}  
  1. Start zellij:
    zellij --layout workspace.kdl

  2. Press t, but nothing happens

Other relevant information

Setting default_shell (to fish in my case) fixed the issue and terminal panes are spawning fine with that setting.

Running echo $SHELL in a terminal pane spawned by the layout:

echo $SHELL 
/usr/bin/fish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant