fnm
fnm copied to clipboard
Compatibility Issue with Powerlevel10k Instant Prompt
Hello!
I'm trying to understand why fnm
is causing issues with the p10k
instant prompt feature. p10k
is supposed to allow for programs to output text during initialization as described here.
When you initialize a zsh
session in a directory with a specified node-version
, fnm
outputs Using Node v{version}
in color. I suspect color might be the cause of the issue here? It'd be nice if there was a way to configure this in some way or simply disable it as I have a snippet to display my node
version with p10k
anyways.
I'm opening a similar discussion in a comment on a p10k
thread here.
Last login: Mon Jun 6 16:32:28 on ttys000
[WARNING]: Console output during zsh initialization detected.
When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.
You can:
- Recommended: Change ~/.zshrc so that it does not perform console I/O
after the instant prompt preamble. See the link below for details.
* You will not see this error message again.
* Zsh will start quickly and prompt will update smoothly.
- Suppress this warning either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
* You will not see this error message again.
* Zsh will start quickly but prompt will jump down after initialization.
- Disable instant prompt either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
* You will not see this error message again.
* Zsh will start slowly.
- Do nothing.
* You will see this error message every time you start zsh.
* Zsh will start quickly but prompt will jump down after initialization.
For details, see:
https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt
-- console output produced during zsh initialization follows --
Using Node v15.14.0
- How it should look

- The colorless output appearing under p10k error message

I'm almost certain fnm is working as intended and the issue is with the user rc files, specifically ~/.zshrc
. I'm posting this so that fnm dev(s) don't waste time investigating.
In case anyone finds this page while looking for a workaround, you can get rid of this warning by editing your .zshrc
and moving the eval
snippet for fnm before the instant prompt preamble, as described here:
https://github.com/romkatv/powerlevel10k/blob/master/README.md#how-do-i-configure-instant-prompt
Since fnm lives up to its name, this should have negligible impact on shell startup time.
@P4, when I do move the eval the warning stops... but unfortunately the switching of node version stops as well.
I get a nice prompt telling all is good... then I do fnm current
and get another version than the one fem just said it installed.

There might be a way to avoid that double change, I hope.
[EDIT] fig.io was the culprit here, it is the one that makes the fnm change ineffective. [EDIT bis] the solution was to uninstall fnm through fig, then restart the computer and re-install fem with the script.
Now all is good
what can we do to make this work nicer for y'all? allow to make the initial/all fnm use
on cd
quiet? --use-on-cd=quiet
and --use-on-cd=quiet-init
?
Some kind of quiet mode would be great, but honestly don't spend too much time on this since people can easily use @P4's solution. For others that are finding this thread, the key is to put the fnm eval code before
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
rather than
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
A quiet mode would be nice, but yeah moving the eval statement above the powerlevel10k statement is fine. Closing this for now. Thanks all!