Open rbhanot4739 opened 3 weeks ago
have you tried putting the devbox eval to the very top of your first rc file?
@DerArkeN what do you mean by first rc file ?Its already placed at the top in the minimal zshrc i shared above.
@rbhanot4739 Does this issue persist even after running refresh-global
? Sometimes that error occurs if you've recently upgraded devbox
the BASH_FUNC()
error that you are seeing is a Shellshock mitigation, because something in either your zshrc or system zshrc is trying to export a function, which is a security vulnerability. From the linked article:
Bash no longer generally interprets the x=() {...} environment variable as a function definition. Function definitions in environment variables are now required to be prefixed with BASHFUNC. Exporting functions with export -f x will now set a environment variable BASH_FUNC_x%%=() {...} instead of simply x=() {...}.
Can you check if there is a pathappend
or pathprepend
function exported in your shell rc?
@Lagoja I am using zsh as my primary shell, the bashrc example was just for test i did in bash to check if it works in bash. No there is no pathappend or pathprepend in my .zshrc
or .bashrc
and both rc files were completely vanilla just containing devbox intitialization hook and couple of source commands. Also this is a fresh installation of devbox, so not sure why refresh-global
warning is coming in first place.
I tried uninstalling devbox few times completely as per instructions in faqs and then installing it again but same issues pop up every time.
Which Linux Distro are you using? I can try to repro in a VM and see if it's a setting in the VM that we aren't handling
I am using azure linux previously known as CBL Mariner
Ah yep, here it is:
It looks like Azure sets those functions in the zprofile, and Devbox trying to source and reexport them is what's causing the issue
EDIT: Doing some testing, this shouldn't be triggering the issue in ZSH, meaning either we are using Bash somewhere in the middle when sourcing the environment, or something on your system is prompting us to evaluate Bash as your default shell. Does your environment have the $SHELL variable set to bash by any chance?
Yes, you are right, so the default shell for the user is being set by ldap profile. So yes initially the default login shell is bash but as a workaround, i do a exec zsh -l
to in my bashrc to spawn zsh as my login shell. Wouldn't that fix this ?
Also i am not loading devbox in bash profile.
But thank you so much for taking the time to troubleshoot this issue.
Can you try adding export SHELL=/bin/zsh
to your zshrc, and see if that fixes the issue? I can check with the team as well to see if we should modify our detection logic to handle this case.
@Lagoja I am already exporting SHELL=/bin/zsh
as part of exec
ing zsh from .bashrc
but unfortunately it didn't work.
Here are the contents of it.
if [ -f "/etc/bash.bashrc" ]; then
source /etc/bash.bashrc
fi
# End ~/.bashrc
if [[ $- == *i* ]]; then
export SHELL=/bin/zsh
exec -l /bin/zsh
else
echo "not an interactive shell"
fi
And here is my .zshrc
eval "$(devbox global shellenv --init-hook)"
source <(fzf --zsh)
eval "$(zoxide init zsh)"
source ~/powerlevel10k/powerlevel10k.zsh-theme
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
@Lagoja Even exporting SHELL=/bin/zsh
explicitly does not work.
$ export SHELL=/bin/zsh
$ zsh -l
❯ echo $SHELL
/bin/zsh
❯ eval "$(devbox global shellenv)"
export: not valid in this context: BASH_FUNC_pathappend%%
It looks shell initialization hook from .zshrc
is not being picked up at all
$ cat .zshrc
eval "$(devbox global shellenv)"
$ exec -l zsh
(eval):export:1: not valid in this context: BASH_FUNC_pathappend%%
$ devbox global list
* ripgrep@latest - 14.1.1
Warning: devbox global is not activated.
Add the following line to your shell's rcfile (e.g., ~/.bashrc or ~/.zshrc)
and restart your shell to fix this:
eval "$(devbox global shellenv)"
$ type refresh-global
refresh-global not found
Not sure why but the issue seemed to be the refresh-global
not being available in zsh
for me, so I replaced it with the actual command eval "$(devbox global shellenv --preserve-path-stack -r)" && hash -r
and this seemed to did the trick for me. After I ran this command devbox
was activated and the shell initialization hook seemed to load it.
What happened?
I installed devbox as per the documentation and then added few global packages. After that when I ran
devbox global list
I was getting the following warningSo following the docs mentioned here I added the shell initialization hooks to to the shell rc file with
eval "$(devbox global shellenv --init-hook)"
, but even then I am getting the following errors:Bash
Zsh
Even after adding the devbox initialization hook to zshrc/bashrc devbox not seem to be activated, and the installed packages are not added to the path, and hence all the tools which I installed via DevBox aren't being loaded(e.g. fzf and zoxide in this case). Also there is subtle discrepancy with the hook command as well as reported by the tool (
eval "$(devbox global shellenv)"
) vs command in the documentation (eval "$(devbox global shellenv --init-hook)"
) and I have tried both but no luck.Here is the snippet from
.zshrc
Also I am not sure why I keep getting this annoying warning after I install any package
Steps to reproduce
Command
shellenv
devbox.json
Devbox version
0.13.4
Nix version
nix (Nix) 2.24.7
What system does this bug occur on?
Linux (x86-64)
Debug logs
No response