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

Can't change user shell #1209

Closed
tedbyron opened this issue Dec 3, 2024 · 22 comments
Closed

Can't change user shell #1209

tedbyron opened this issue Dec 3, 2024 · 22 comments

Comments

@tedbyron
Copy link

tedbyron commented Dec 3, 2024

-sh-3.2$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

# List of shells managed by nix.
/run/current-system/sw/bin/bash
/run/current-system/sw/bin/zsh

-sh-3.2$ echo $SHELL
/run/current-system/sw/bin/zsh

-sh-3.2$ dscl . -read /users/ted/ UserShell
UserShell: /run/current-system/sw/bin/zsh

-sh-3.2$ echo $0
-sh

Both dscl and $SHELL show the correct shell but any time I open a new shell it uses apple bash. Any idea why this could be happening? I'm using programs.zsh and have users.users.ted.shell = pkgs.zsh. chsh also doesn't do anything because it's already set to the correct shell but running the wrong one

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

What terminal are you using? Have you added yourself to users.knownUsers?

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

What terminal are you using? Have you added yourself to users.knownUsers?

Tried both alacritty and apple's terminal program. I am not currently using users.knownUsers, am I supposed to be?

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

Yes, you want to add your own user to knownUsers. What you see when you run /run/current-system/sw/bin/zsh directly?

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

Gotcha thanks, can I ask why it says not to add admin users to knownUsers in the docs? I assumed I shouldn't add my account because it's the only account on the computer and is an admin.

Running the path for zsh will run it fine

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

Ah, I forgot to update that, basically it’s because adding a user to knownUsers means that nix-darwin manages them and if you delete them from the configuration, nix-darwin will delete the user, however I’ve added some protections to prevent deleting the user you’re running darwin-rebuild switch as so it should be fine

Have you tried restarting your computer?

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

I added myself to knownUsers, ran darwin-rebuild switch ..., fully power cycled my computer, still got the same issue. Issue first appeared when I switched to the 24.11 release of nixpkgs & home manager.

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

Are you setting the SHELL environment variable somewhere?

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

Nope

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

Have you tried quitting Terminal.app and opening it fresh?

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

Yeah I killed the tmux session too, no change

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

In the menus there should be a New Command option and if you use that and put /run/current-system/sw/bin/zsh does it work?

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

No, that's what is currently entered in that setting
image

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

What happens if you change that back to Default login shell? Also what happens if you run New Command with /bin/zsh?

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

Thanks for the help, the issue has to do with something in my tmux config - just rebuilt without tmux and it's fine. Didn't notice that earlier because every shell auto attaches to tmux

@tedbyron tedbyron closed this as completed Dec 3, 2024
@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

Looks like tmux just doesn't use my shell when I start it up

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

I have no tmux configuration and it launches the correct shell. You can run a tmux server then run tmux show -g in any window

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

$ tmux show -g
...
default-command ''                                                              
default-shell /run/current-system/sw/bin/zsh
...

@tedbyron
Copy link
Author

tedbyron commented Dec 3, 2024

image there's the issue, looks like tmux-sensible plugin has `$SHELL` as /bin/sh when it's running for some reason

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

According to this commit, reattach-to-user-namespace is not necessary anymore:

9a04aea

Maybe you can just override it with set -g default-command '' somewhere in your config?

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

Looks like there's a pull request to fix this: tmux-plugins/tmux-sensible#75

@Enzime
Copy link
Collaborator

Enzime commented Dec 3, 2024

It looks like reattach-to-user-namespace is only used if that command exists:

https://github.com/tmux-plugins/tmux-sensible/blob/25cb91f42d020f675bb0a2ce3fbd3a5d96119efa/sensible.tmux#L102-L104

So you can make sure the package is not installed and you don't need to set anything else

@tedbyron
Copy link
Author

tedbyron commented Dec 4, 2024

Thanks for the help!

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

2 participants