zellij icon indicating copy to clipboard operation
zellij copied to clipboard

Could not find the SHELL variable: NotPresent

Open Lingzo opened this issue 3 years ago • 8 comments

Basic information

zellij --version: 0.31.4 stty size: 52 192

uname -av or ver(Windows): run in docker (host is Linux Master 5.15.60-1-MANJARO)

Further information

image

Error occurred in server:

  × Thread 'pty' panicked.
  ├─▶ Originating Thread(s)
  │   	1. ipc_server: NewClient
  │   	2. pty_thread: NewTab
  │
  ├─▶ At zellij-server/src/pty.rs:206:54
  ╰─▶ Could not find the SHELL variable: NotPresent
  help: If you are seeing this message, it means that something went wrong.
        Please report this error to the github issue.
        (https://github.com/zellij-org/zellij/issues)

        Also, if you want to see the backtrace, you can set the `RUST_BACKTRACE` environment variable to `1`.

Lingzo avatar Sep 10 '22 09:09 Lingzo

Inside the docker container, if you do echo $SHELL, what do you get?

imsnif avatar Sep 10 '22 10:09 imsnif

Inside the docker container, if you do echo $SHELL, what do you get?

it's /bin/bash.

when i run zellij in tmux session inside docker container, it works.

Lingzo avatar Sep 10 '22 12:09 Lingzo

Hmm, very odd. Could you help me understand how you are running this? What computer you are on, how are you connecting to the docker host, etc. I want to figure out where this env variable gets dropped.

imsnif avatar Sep 10 '22 13:09 imsnif

  1. I used docker img base ubuntu 20.04
  2. I started a container with docker start -i
  3. execute zellij

Lingzo avatar Sep 10 '22 16:09 Lingzo

I encountered the same issue on Fedora 36 docker image run on podman. I was logged in the container as root and SHELL environ variable was set to /bin/bash.

karczex avatar Sep 22 '22 13:09 karczex

@altair-albert , @karczex - could this be an issue of timing or environment? Instead of running Zellij with zellij, could you maybe do something like echo $SHELL > /tmp/logfile && zellij, and then see what you get in /tmp/logfile?

imsnif avatar Sep 22 '22 13:09 imsnif

Btw, a workaround for this would be to specify a default_shell in the zellij configuration: https://zellij.dev/documentation/options.html

But I still want to get to the bottom of this

imsnif avatar Sep 22 '22 13:09 imsnif

@altair-albert , @karczex - could this be an issue of timing or environment? Instead of running Zellij with zellij, could you maybe do something like echo $SHELL > /tmp/logfile && zellij, and then see what you get in /tmp/logfile?

I get /bin/bash as expected, but for some reason it's not propagated to the application.

It seems the problem lays somewhere outside of zellij. I tried simple C program, which reads SHELL env variable and it also cannot get it. The fun part is that, it reads PATH variable without any problems.

#include <stdlib.h>
#include <stdio.h>
#define BUFSIZE 880

int main(){
    char shell[BUFSIZE];
    char *envvar = "SHELL";
   
     if(!getenv(envvar)){
        fprintf(stderr, "The environment variable %s was not found.\n", envvar);
        exit(1);
    }

    if(snprintf(shell, BUFSIZE, "%s", getenv(envvar)) >= BUFSIZE){
        fprintf(stderr, "BUFSIZE of %d was too small. Aborting\n", BUFSIZE);
        exit(1);
    }
    printf("SHELL: %s\n", shell);

    return 0;
}

karczex avatar Sep 22 '22 13:09 karczex

Quick update: Zellij will now fall back to using /bin/sh when $SHELL cannot be read, and panics if whatever shell it ends up using doesn't exist.

This doesn't fix nor explain why in some circumstances env vars cannot be read in the first place, but now at least you'll be made aware that something went wrong!

har7an avatar Nov 15 '22 15:11 har7an