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

OS X Installer script doesn't work with zsh #4990

Closed
jonaf opened this issue Jul 6, 2021 · 4 comments
Closed

OS X Installer script doesn't work with zsh #4990

jonaf opened this issue Jul 6, 2021 · 4 comments
Labels
bug macos Nix on macOS, aka OS X, aka darwin

Comments

@jonaf
Copy link

jonaf commented Jul 6, 2021

Describe the bug

The installer for Mac OS writes this line to ~/.bash_profile:

if [ -e /Users/jona/.nix-profile/etc/profile.d/nix.sh ]; then . /Users/jona/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer

However, Apple switched the default shell from bash to zsh a couple years back. If you're using zsh like I am, you might restart your computer and then be unable to find nix-shell, and the reason is because the installer wrote the above line in /.bash_profile instead of ~/.zshrc

It would be great if the installer detected the shell that was in use and update that.

Steps To Reproduce

  1. Be a zsh user
  2. Run the installer script from https://nixos.org/guides/install-nix.html
  3. Open a new terminal session
  4. Notice that nix-env, nix-shell, etc are not in the $PATH

Expected behavior

It's expected that new terminal sessions have the nix commands in the $PATH

@jonaf jonaf added the bug label Jul 6, 2021
@jonaf
Copy link
Author

jonaf commented Jul 6, 2021

On closer inspection, I realized that the installer does add the line in question to both ~/.bash_profile and ~/.zshrc

however, the last line of my ~/.zshrc was a commented line at the time of the install, and it looks like I didn't have a newline at the end of that line, so the installer just appended to the last line instead of adding a new line. This effectively commented it out from the installer, so this issue is a fairly specific situation (where a person like me doesn't properly terminate a file's contents with a newline).

@domenkozar domenkozar added the macos Nix on macOS, aka OS X, aka darwin label Jul 7, 2021
@domenkozar
Copy link
Member

That's fixed in master, but needs backporting to 2.3 /cc @toonn

@stale
Copy link

stale bot commented Jan 3, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jan 3, 2022
@toonn
Copy link
Contributor

toonn commented Jan 11, 2022

I believe this can be closed. The backport isn't necessary anymore since 2.4 has been released.

@stale stale bot removed the stale label Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug macos Nix on macOS, aka OS X, aka darwin
Projects
None yet
Development

No branches or pull requests

3 participants