You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With eval "$(fnm env --version-file-strategy recursive --use-on-cd)" on my bashrc and system set as default, when opening a shell I have the following error:
error: Could not find any version to use. Maybe you don't have a default version set?
Try running `fnm default <VERSION>` to set one, or create a .node-version file inside your project to declare a Node.js version.
Creating a .node-version with "system" in my home directory doesn't solve the problem.
If I remove one of both flags, then it works. If I set default to another version, then it works. fnm default system doesn't give any error. fnm use system either.
I am using fnm-bin 1.31.0 on arch.
My use case is that I would like to always use the system version of node, and only use fnm for my work and personal projects.
Thus I can globally always have the version of node auto-update, through my package manager.
The text was updated successfully, but these errors were encountered:
After looking over the code, this error seems to come from the fact that --version-file-strategy recursive runs on every cd, not just the ones that it may be useful like --version-file-strategy local.
Local:
__fnm_use_if_file_found() {{
if [[ -f .node-version ||-f .nvmrc ]];then
fnm use --silent-if-unchanged
fi
}}
__fnmcd() {{
\cd "$@"||return$?
__fnm_use_if_file_found
}}
alias cd=__fnmcd
Recursive:
__fnm_use_if_file_found() {{
fnm use --silent-if-unchanged
}}
__fnmcd() {{
\cd "$@"||return$?
__fnm_use_if_file_found
}}
alias cd=__fnmcd
A solution is to suppress the CantInferVersion error if silent_if_unchanged is true. Instead fnm could add a debug line saying that fnm is suppressing the error due to the use of silent_if_unchanged. This would only be visible when the user sets the RUST_LOG environment variable.
Technically, if fnm does not find a version, fnm does not change the version, so fnm could silence the error with silent_if_unchanged.
The issue is if you make your default system. On *nix systems, fnm sets the default alias to symlink to /dev/null/installation. When fnm tries to get the default version, fnm calls canonicalize on that symlink.
Since canonicalize follows symlinks, we get a NotADirectory error; Instead of, the system alias.
Hi,
With
eval "$(fnm env --version-file-strategy recursive --use-on-cd)"
on my bashrc and system set as default, when opening a shell I have the following error:Creating a .node-version with "system" in my home directory doesn't solve the problem.
If I remove one of both flags, then it works. If I set default to another version, then it works.
fnm default system
doesn't give any error.fnm use system
either.I am using fnm-bin 1.31.0 on arch.
My use case is that I would like to always use the system version of node, and only use fnm for my work and personal projects.
Thus I can globally always have the version of node auto-update, through my package manager.
The text was updated successfully, but these errors were encountered: