Open chuwy opened 4 years ago
It seems that problem went away after nix-env -i bash
when calling nix-shell
in the bash provided MacOS you get a shell that is provided by nix:
$ nix-shell -p hello --run "where bash"
/nix/store/<hash>-bash-interactive-4.4-p23/bin/bash
but the plugins build-shell-shim uses /bin/bash
. I'm not sure how I would get that shell without building the plugin with nix.
For now I will update the Readme.
On MacOS you have to have a bash with version 4 or greater. https://github.com/chisui/zsh-nix-shell/issues/14
it appears that brew's bash isn't good enough either (though I'm getting a slightly different error, ... command not found
):
$ which -a bash
/usr/local/bin/bash
/bin/bash
$ bash --version
GNU bash, version 5.2.2(1)-release (x86_64-apple-darwin21.6.0)
#...
$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin22)
#...
$ nix-shell --command 'sed "s/\033/ESC/g" < /private/tmp/nix-shell-*/rc;echo;echo' -p cowsay
_nix_shell_clean_tmpdir() { command rm -rf '/private/tmp/nix-shell-48073-0'; }; trap _nix_shell_clean_tmpdir EXIT; exitHooks+=(_nix_shell_clean_tmpdir); failureHooks+=(_nix_shell_clean_tmpdir); [ -n "$PS1" ] && [ -e ~/.bashrc ] && source ~/.bashrc;p=$PATH; unset PATH;dontAddDisableDepTrack=1; [ -e $stdenv/setup ] && source $stdenv/setup; PATH=$PATH:$p; unset p; PATH='/path/to/zsh-nix-shell/scripts':"$PATH"; SHELL='/path/to/zsh-nix-shell/scripts/buildShellShim'; BASH='/path/to/zsh-nix-shell/scripts/buildShellShim'; set +e; [ -n "$PS1" -a -z "$NIX_SHELL_PRESERVE_PROMPT" ] && PS1='
\[ESC[1;32m\][nix-shell:\w]\$\[ESC[0m\] '; if [ "$(type -t runHook)" = function ]; then runHook shellHook; fi; unset NIX_ENFORCE_PURITY; shopt -u nullglob; unset TZ; shopt -s execfail;sed "s/ESC/ESC/g" < /private/tmp/nix-shell-48073-0/rc
SHELL=
unset NIX_BUILD_SHELL
FPATH=$(echo 'echo $FPATH' | --stdin)
for path in ${PATH//:/ }; do
if [[ $path = /nix/store/* ]]; then
path=${path/%bin/share\/zsh\/site-functions}
if [ -d "$path" ]; then
FPATH="$path:$FPATH"
fi
fi
done
FPATH=$FPATH
/private/tmp/nix-shell-48073-0/rc: line 5: --stdin: command not found
(note, actual escape characters replaced with ESC
for readability)
Hm, the issue seems to be that $NIX_EXECUTING_SHELL
is not set. See the line SHELL=
and FPATH=$(echo 'echo $FPATH' | --stdin)
right before the --stdin
there should be the shell.
@mark-pictor-csec could you post the output of readlink /proc/$$/exe
in zsh
?
Hi @chisui
I am getting the same error as @mark-pictor-csec after installing bash 5.1 with nix-env -i bash-interactive
and whitelisting it as the by-default bash shell by editing /etc/shells
.
When I run readlink /proc/$$/exe
on zsh
I do not get anything:
$ echo $SHELL
/bin/zsh
$ readlink /proc/$$/exe
$
sorry @chisui I should have checked for replies as with dsalaza4, I get nothing:
$ readlink /proc/$$/exe
$ readlink /proc/$$/exe | wc -c
0
$ zsh -c 'ls /proc/$$/exe'
ls: /proc/40813/exe: No such file or directory
Issue description
I'm getting the following error when trying to run
nix-shell
withzsh-nix-shell
enabled:If I comment
zsh-nix-shell
out - it works fine. I thought it might be related to https://github.com/NixOS/nixpkgs/issues/71625, but I have same old default bash-3.2 from Mojave and didn't have to update it with brew.I used plain installation (I use prezto instead of Oh-My-ZSH).
Steps to reproduce
I have a following
default.nix
file:Technical details