Closed thapabishwa-plerionaut closed 6 months ago
The default shell to open in Zed is set to "system". What happens if you change it to one of your preferred shells?
{
"terminal": {
"shell": {
"program": "zsh"
}
}
}
Hey @Moshyfawn, my default shell is /bin/zsh
. I was confused when Zed opened bash
even when SHELL
was set to /bin/zsh
.
I see the following with raycast only. Spotlight works fine with the config you suggested.
Hey there! Few questions to try to nail this down:
Zed.app
in /Applications
?Terminal.app
?What happens if you open it by clicking on Zed.app in /Applications?
Works as expected.
And what happens if you launch it via the CLI (if you have the CLI tools installed)?
Works as expected via CLI too.
What do you have set as your login shell in the macOS User settings? (You need to right click and "Advanced options..." to see these)
What shell do you get in Terminal.app?
Terminal.app
iterm2.app
Huh. So what happens when you start Alacritty.app? (That's what we use for the built-in terminal)
Do you have any plugins in Raycast that set a $SHELL
or something?
+1 to this issue - when opened via Raycast, Zed says my shell is /bin/sh
despite having it set to /bin/zsh
in my settings.json, but when opened via Finder or Spotlight it respects the setting. My login shell in the macOS User settings is /bin/zsh
and I don't believe I have any Raycast plugins that set a $SHELL
Not a huge problem since things work as expected when opened with anything that's not Raycast, just wanted to add my experience here.
@aspeth can you try to reproduce what happens when you just launch Alacritty.app, from the Dock and from Raycast?
echo $SHELL
in Alacritty shows /bin/zsh
when opened via Raycast as well as from the dock, but when opened via Raycast can't find commands in my .zshrc
(brew, starship, and atuin, specifically) even after running source ~/.zshrc
but has no problem finding those commands when opened via the dock.
This is so weird. I really wonder whether there isn't something going on inside Raycast wrt to env variables.
I'm having a similar issue. Zed is trying to open fish
and fails because fish is no longer installed on the system. My shell is set to "system", my default shell is zsh. Nothing in the Zed's settings seems to be pointing to fish, but it keeps trying to use it.
I'm having a similar issue.
When you open it via Raycast?
When you open it via Raycast?
No. When running Zed in general. It is a different case, I don't even have Raycast, but Zed trying to pick a weird shell is similar. I thought I'd mention it just on the off chance it helps with debugging.
@tkgalk can you also try running Alacritty.app? I'm wondering if you have the same problem there. That would help a lot with the debugging.
No, Alacritty seems to respect the default shell.
Found something here: https://github.com/neovide/neovide/issues/2394
Looks like Raycast doesn't forward the $SHELL
variable.
I dug into this a bit, here's what I found:
passwd
file when no SHELL
is set. https://github.com/alacritty/alacritty/blob/79b686df419d90e5557d1b7000f51f012986c141/alacritty_terminal/src/tty/unix.rs#L136-L171terminal.shell
, then we use the Alacritty default.So, to debug, here's a few things I need.
I wrote a little program to reproduce what alacritty does:
// main.c
#include <errno.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
struct Passwd {
const char *name;
const char *dir;
const char *shell;
};
struct Passwd get_pw_entry(char *buf, size_t buflen) {
struct passwd *entry;
struct Passwd result;
memset(&result, 0, sizeof(struct Passwd)); // Zero out the result struct
uid_t uid = getuid();
int status;
struct passwd pw;
status = getpwuid_r(uid, &pw, buf, buflen, &entry);
if (status != 0) {
perror("getpwuid_r failed");
exit(EXIT_FAILURE);
}
if (entry == NULL) {
fprintf(stderr, "pw not found\n");
exit(EXIT_FAILURE);
}
// Sanity check.
if (pw.pw_uid != uid) {
fprintf(stderr, "UID mismatch\n");
exit(EXIT_FAILURE);
}
// Fill the result struct
result.name = pw.pw_name;
result.dir = pw.pw_dir;
result.shell = pw.pw_shell;
return result;
}
int main() {
const size_t buf_size = 1024;
void *buf = malloc(buf_size);
if (buf == NULL) {
fprintf(stderr, "failed to malloc\n");
exit(1);
}
struct Passwd result = get_pw_entry(buf, buf_size);
printf("name: %s\n", result.name);
printf("dir: %s\n", result.dir);
printf("shell: %s\n", result.shell);
return 0;
}
You can run it like this: cc -o main ./main.c && ./main
That'll print the values that Alacritty uses, if no Shell is specified.
So, for everybody who experiences weird terminal behavior, I need the the following:
terminal: { shell: ... }
from your Zed settings.json
zed: open logs
, find the last line that contains: set environment variables from shell
. That should have the shell in it. Example: 2024-05-13T14:46:47+02:00 [INFO] set environment variables from shell:/bin/zsh, path:<myPATH>
What is the shell?zed: open logs
, find the last line that contains: set environment variables from shell
. That should have the shell in it. What is the shell?Terminal.app
(NOT via Raycast), do echo $SHELL
, then run my program: cc -o main ./main.c && ./main
- give me the outputTerminal.app
(NOT via Raycast), do unset $SHELL
(!!), then run my program: cc -o main ./main.c && ./main
- give me the output$SHELL
in your normal terminal emulator? Do you have that configured in the terminal emulator? Or not?https://github.com/zed-industries/zed/discussions/11751 moved my issue here, as it doesn't seem to be connected to Raycast. My zed
Terminal can't even open the shell, so I can't test that.
After fixing my issue with Zed, I installed Raycast just to help, but I can't reproduce the OP's problem. Zed seems to be correctly running the shell from Raycast.
/bin/zsh
./bin/zsh
./bin/zsh
.unset SHELL
, I think, not $SHELL
). name: tkg dir: /Users/tkg shell: /bin/zsh
/bin/zsh
.So at least for me seems like Zed is behaving correctly through both Raycast and outside of it.
Another finding that might be related: Alacritty.app doesn't seem to pickup changes made with chsh
to the default shell.
https://github.com/zed-industries/zed/assets/1185253/46fb7220-515b-419c-91cb-31a045d7910e
Figured out a little bit more my digging into Alacritty and compiling from source:
chsh -s /new/-shell
That new shell is not picked up, because Finder
does set the $SHELL
env variable, but it only gets updated once Finder is restarted.
There's so much environment variables and state involved here, especially when using Raycast/Finder (which are long-running applications) that I think the safest step for further reproduction of bugs is: Make sure you've restarted your computer after making changes to the default shell.
Check for existing issues
Describe the bug / provide steps to reproduce it
Zed
settings.json
Video:
https://github.com/zed-industries/zed/assets/124118626/c35661f4-cb05-4189-ad78-2cecf6c1b5a0
Environment
MacBook Pro 13-inch, M2, 2022 Chip: M2 Memory: 16 GB
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.If you only need the most recent lines, you can run the
zed: open log
command palette action to see the last 1000.No response