Closed NovaViper closed 1 year ago
when I run echo $ZSH it does report back with /home/novaviper/.config/zsh/zplug/repos/robbyrussell/oh-my-zsh
Yes, this is the root cause, Topgrade detects whether you have oh-my-zsh
installed by checking the existence of:
I currently don't have any good solution to this issue, and I am sorry to say that you cannot disable oh-my-zsh
update at present, the only option that is available is to disable all the shell-related steps via:
[misc]
disable = ["shell"]
Yes, this is the root cause, Topgrade detects whether you have
oh-my-zsh
installed by checking the existence of:
- environment variable ZSH
- ~/.oh-my-zsh
For me, topgrade runs oh-my-zsh even though ~/.oh-my-zsh is NOT present on my fedora system. The $ZSH environment variable is set by my .zshrc for unrelated reasons, but it is not exported, and unsetting it doesn't fix the issue.
Changing the variable name to $ZSHDATA fixed it
but it is not exported
This is kinda weird, did you run topgrade over ssh?
but it is not exported
This is kinda weird, did you run topgrade over ssh?
yes
but it is not exported
This is kinda weird, did you run topgrade over ssh?
yes
Get it, I should enhance the impl then:)
@SteveLauC Hey so I've been looking at the source code for zplug and it appears that zplug actually does this to make oh-my-zsh plugins work.. perhaps maybe the oh-my-zsh step should also check to ensure that zplug isn't installed on the system? That way if zplug isn't there, the program would assume that oh-my-zsh is actually installed and if it is there, then it must be the case that oh-my-zsh was installed using zplug and thus, should actually trigger the zplug step.
I noticed zplug in particular seems to be the only plugin manager doing this, because I switched over to antidote and it doesn't trigger the same behavior as observed when using zplug
it appears that zplug actually does this to make oh-my-zsh plugins work
Would you like to give me a link to this?
And, one thing I noted was that the zplug
steps was not activated on your system cause you don't have a .zshrc
file, from the source code of the zplug
step:
It checks:
zsh
is installed and can be found in the PATH
.zshrc
file existsZPLUG_HOME
(fall back to ~/.zplug
) points to an existing directory it appears that zplug actually does this to make oh-my-zsh plugins work
Would you like to give me a link to this?
And, one thing I noted was that the
zplug
steps was not activated on your system cause you don't have a.zshrc
file, from the source code of thezplug
step:It checks:
1. `zsh` is installed and can be found in the `PATH` 2. `.zshrc` file exists 3. Environment variable `ZPLUG_HOME` (fall back to `~/.zplug`) points to an existing directory
I do have a .zshrc folder, it's located in the ~/.config/zsh
folder (using the XDG_CONFIG_HOME
variable that's defined in the XDG standard), and the ZPLUG_HOME
variable also points to ~/.config/zsh/zplug
I do have a .zshrc folder, it's located in the ~/.config/zsh folder (using the XDG_CONFIG_HOME variable that's defined in the XDG standard), and the ZPLUG_HOME variable also points to ~/.config/zsh/zplug
I love this spec, but does zsh
respect its environment variables? The last time I searched this, they told me that zsh does not support the XDG spec, and you have to hack it with the environment variable ZDOTDIR
Yeah it doesn't use them by default but I do have the environment configs for zsh pointing to the XDG paths
Yeah it doesn't use them by default but I do have the environment configs for zsh pointing to the XDG paths
By hacking the src of zsh or the env var ZDOTDIR?
If it is the latter, then Topgrade should be able to detect your zshrc file
Yeah it doesn't use them by default but I do have the environment configs for zsh pointing to the XDG paths
By hacking the src of zsh or the env var ZDOTDIR?
If it is the latter, then Topgrade should be able to detect your zshrc file
Using the ZDOTDIR
environment variable, using Home Manager like this
programs.zsh = {
enable = true;
dotDir = ".config/zsh";
... More stuff but not important for the snippet
Which all it simply does it change the ZDOTDIR
environment variable: Declared here and here
Using the ZDOTDIR environment variable
This is weird, from the verbose output you pasted:
zplug: SKIPPED: Path "/home/novaviper/.zshrc" doesn't exist
Your .zshrc
file was not found by Topgrade...
Does
$ echo $ZDOTDIR
give you the path you configured?
Yes it does! 🤔 odd that it didn't catch that.
Yes it does! 🤔 odd that it didn't catch that.
Is it exported?
Yes it does! thinking odd that it didn't catch that.
Is it exported?
From what I can tell what Home Manager+NixOS does, it directly creates a zshenv file in the home folder, which points to the zshenv file within the XDG_CONFIG_HOME/zsh
path, and that contains the new ZDOTDIR
variable that sets it to point to the ~/.config/zsh
path, and it starts up this way by default, so yes, it seems to be exported as far as I can tell
so yes, it seems to be exported as far as I can tell
Then I have no idea why Topgrade didn't find it...
BTW, it is easy to test whether it has been exported or not:
$ export -p | grep ZDOTDIR
so yes, it seems to be exported as far as I can tell
Then I have no idea why Topgrade didn't find it...
BTW, it is easy to test whether it has been exported or not:
$ export -p | grep ZDOTDIR
The command doesn't return anything back. The odd thing is that zsh and all other programs can clearly see that ZDOTDIR
is set and points to ~/.config/zsh
, but topgrade doesn't 🤷🏾♀️
Here's where exactly Home Manager sets up the zshenv files: https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix#L481C1-L493
And mine results like this
# Environment variables
. "/home/novaviper/.nix-profile/etc/profile.d/hm-session-vars.sh"
# Only source this once
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then
export __HM_ZSH_SESS_VARS_SOURCED=1
fi
ZDOTDIR=$HOME/.config/zsh
The command doesn't return anything back.
If it is exported, then it should be returned, see How do you determine whether shell variables are exported or not?
zsh and all other programs can clearly see
ZDOTDIR
zsh
will source its config file so it should be visible
Here's where exactly Home Manager sets up the zshenv files: https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix#L481C1-L493
And mine results like this
# Environment variables . "/home/novaviper/.nix-profile/etc/profile.d/hm-session-vars.sh" # Only source this once if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then export __HM_ZSH_SESS_VARS_SOURCED=1 fi ZDOTDIR=$HOME/.config/zsh
I am not a nix user, so I cannot understand this :<, sorry about this:(
The command doesn't return anything back.
If it is exported, then it should be returned, see How do you determine whether shell variables are exported or not?
zsh and all other programs can clearly see
ZDOTDIR
zsh
will source its config file so it should be visible
Ah so it's exported, but even though it's not exported, its variable seems to still be visible within ZSH (but not inside of bash, zsh is set as the default shell on my system).
Here's where exactly Home Manager sets up the zshenv files: https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix#L481C1-L493 And mine results like this
# Environment variables . "/home/novaviper/.nix-profile/etc/profile.d/hm-session-vars.sh" # Only source this once if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then export __HM_ZSH_SESS_VARS_SOURCED=1 fi ZDOTDIR=$HOME/.config/zsh
So what it looks like it's doing directly is just making ZDOTDIR
whatever value that's defined, but not exporting it to make it available for other shells. 🤔
Ah so it's exported, but even though it's not exported, its variable seems to still be visible within ZSH (but not inside of bash, zsh is set as the default shell on my system).
$ bash
$ echo $ZDOTDIR
Another way to test if it is exported, launch a bash
in zsh
, bash
won't source the zsh file, if it is exported, then bash
can definitely see ZDOTDIR
but not exporting it to make it available for other shells. thinking
An exported variable can be inherited by its children processes
Ah so it's exported, but even though it's not exported, its variable seems to still be visible within ZSH (but not inside of bash, zsh is set as the default shell on my system).
$ bash $ echo $ZDOTDIR
Another way to test if it is exported, launch a
bash
inzsh
,bash
won't source the zsh file, if it is exported, thenbash
can definitely seeZDOTDIR
Ah yeah, so the main issue is that the variable isn't being exported. I just made an issue over on Home Manager, hopefully the devs can address it
Hey just wanted to give an update to this, I did actually go ahead and make a PR on home-manager. Waiting for it to get reviewed and then merged 🎉
And the commit's been merged! So I'm going close the issue since the fix is merged in the master branch of HM!
Erroneous Behavior
Ohmyzsh step is being ran instead of zplug step, as mentioned in here.
Expected Behavior
Zplug step should be running instead of ohmyzsh
Steps to reproduce
Install and setup Zsh with zplug with the following plugin configurations on NixOS:
Possible Cause (Optional)
This could be possibly caused by me using the sudo plugin from the ohmyzsh framework, since that's the only plugin that's coming directly from there, as when I run
echo $ZSH
it does report back with/home/novaviper/.config/zsh/zplug/repos/robbyrussell/oh-my-zsh
Problem persists without calling from topgrade
Configuration file (Optional)
Additional Details
Operation System/Version NixOS v23.05 (running 23.11 unstable channel) + Home-Manager 23.11-pre
Installation Used HomeManager to install the package onto my NixOS install
Topgrade version (
topgrade -V
) v12.0.1Verbose Output (
topgrade -v
)