aaronjanse / 3mux

Terminal multiplexer inspired by i3
MIT License
1.82k stars 45 forks source link

"couldn't find shell to use" panic on startup #57

Closed mhutter closed 4 years ago

mhutter commented 4 years ago

When I run 3mux, it immediately crashes with the following stack trace:

Error during: couldn't find shell to use
Tiling state: Universe[0]()
goroutine 1 [running]:
runtime/debug.Stack(0x11856e0, 0xc00012e008, 0xc000145c90)
  /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/debug/stack.go:24 +0x9d
main.fatalShutdownNow(0x115d4ff, 0x1a)
  /Users/username/go/src/github.com/aaronjanse/3mux/main.go:133 +0x17e
main.getShellPath(0x0, 0x0)
  /Users/username/go/src/github.com/aaronjanse/3mux/pane.go:71 +0x297
main.newTerm(0x1, 0x1162060)
  /Users/username/go/src/github.com/aaronjanse/3mux/pane.go:76 +0x26
main.main()
  /Users/username/go/src/github.com/aaronjanse/3mux/main.go:77 +0x2f9

go1.14.2 iTerm2 v3.3.9 MacOS Catalina v10.15.4

Digging into this...

mhutter commented 4 years ago

Looking into getShellPath, I can see that it tries to read the users's shell from /etc/passwd.

However, it seems that in recent MacOS versions, there are no entries in /etc/passwd anymore, grep $USER /etc/passwd returns no results.

Now, I noticed that the currently used shell is available in $SHELL, so I can think of two possible PR's:

  1. Use $SHELL by default and only try to fetch the shell from /etc/passwd if $SHELL is not set
  2. Use $SHELL as the fallback if user could not be found in /etc/passwd

Personally I think semantically option 1 would be correct... but WDYT @aaronjanse ?

mhutter commented 4 years ago

I see this is already adressed in #56

aaronjanse commented 4 years ago

Hey, thanks for the explanation! Fixed. Cheers to releasing code at 3 am :tada: