Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
17.51k stars 444 forks source link

Install script configures .zshrc incorrectly on MacOS when using Homebrew #1237

Open esseb opened 2 weeks ago

esseb commented 2 weeks ago

Using macOS 14.6.1 (23G93) on a MacBook Pro 16-inch, 2021 with an Apple M1 Pro chip.

Steps to reproduce

  1. Install using curl -fsSL https://fnm.vercel.app/install | bash
  2. Run source /Users/esseb/.zshrc as instructed
  3. Run fnm use

Expected result

fnm should run without any errors.

Actual result

error: We can't find the necessary environment variables to replace the Node version.
You should setup your shell profile to evaluate `fnm env`, see https://github.com/Schniz/fnm#shell-setup on how to do this
Check out our documentation for more information: https://fnm.vercel.app

Further information

I think the bug is because setup_shell in https://fnm.vercel.app/install appends this to .zshrc:

# fnm
FNM_PATH="/Users/esseb/Library/Application Support/fnm"
if [ -d "$FNM_PATH" ]; then
  export PATH="/Users/esseb/Library/Application Support/fnm:$PATH"
  eval "`fnm env`"
fi

The folder that FNM_PATH refers to is never created in download_fnm when using homebrew, however, so the if statement is not true and fnm env does not get run.

esseb commented 2 weeks ago

https://github.com/Schniz/fnm/issues/824#issuecomment-2291882222 seems to have discovered the same issue with the incorrect FNM_PATH.