Repository navigation
fix(downloads): fix fnm, Homebrew, n, and 0install snippets #9351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| # Download and install Homebrew | ||
| curl -o- https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash | ||
| # Download and install Homebrew: | ||
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
|
|
||
| # Add Homebrew to your PATH: | ||
| ${props.os === 'MAC' ? | ||
| `if [ -x /opt/homebrew/bin/brew ]; then | ||
| eval "$(/opt/homebrew/bin/brew shellenv)" | ||
| grep -qs '/opt/homebrew/bin/brew shellenv' ~/.zprofile ~/.zshrc || { echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"'; } >> ~/.zprofile | ||
| fi` : | ||
| `if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then | ||
| eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | ||
| grep -qs '/home/linuxbrew/.linuxbrew/bin/brew shellenv' ~/.bashrc ~/.profile || { echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'; } >> ~/.bashrc | ||
| fi` | ||
| } | ||
|
|
||
| # Download and install Node.js: | ||
| brew install node@${props.release.major} | ||
|
|
||
| # Add Node.js to your PATH (required for keg-only LTS formulas): | ||
| export PATH="$(brew --prefix node@${props.release.major})/bin:$PATH" | ||
| grep -qs "$(brew --prefix node@${props.release.major})/bin" ${props.os === 'MAC' ? '~/.zshrc' : '~/.bashrc'} || { echo; echo 'export PATH="'"$(brew --prefix node@${props.release.major})/bin"':$PATH"'; } >> ${props.os === 'MAC' ? '~/.zshrc' : '~/.bashrc'} | ||
|
Comment on lines
+19
to
+21
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels rather complex. Why isn't brew adding this to PATH by itself?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because Homebrew's versioned LTS Node formulas ( So when a user selects an LTS release like v24 on |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| # Download and install fnm: | ||
| ${props.os === 'WIN' ? | ||
| 'winget install Schniz.fnm' : | ||
| 'curl -o- https://fnm.vercel.app/install | bash' | ||
| props.os === 'MAC' ? | ||
| 'curl -o- https://fnm.vercel.app/install | bash -s -- --force-no-brew' : | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a clean macOS machine without Homebrew, running Checking availability of curl... OK!
Checking availability of unzip... OK!
Checking availability of Homebrew (brew)... Missing!Notice If |
||
| 'curl -o- https://fnm.vercel.app/install | bash' | ||
| } | ||
|
|
||
| # In lieu of restarting the shell | ||
| ${props.os === 'WIN' ? | ||
| 'fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression' : | ||
| 'export PATH="$HOME/.local/share/fnm:$PATH"\neval "$(fnm env)"' | ||
| props.os === 'MAC' ? | ||
| 'export PATH="$HOME/Library/Application Support/fnm:$PATH"\neval "$(fnm env)"' : | ||
| 'export PATH="$HOME/.local/share/fnm:$PATH"\neval "$(fnm env)"' | ||
| } | ||
|
|
||
| # Download and install Node.js: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| # Download and install n and Node.js: | ||
| curl -fsSL https://raw.githubusercontent.com/mklement0/n-install/stable/bin/n-install | bash -s ${props.release.major} | ||
|
|
||
| # In lieu of restarting the shell: | ||
| export N_PREFIX="$HOME/n" | ||
| export PATH="$N_PREFIX/bin:$PATH" | ||
|
Comment on lines
+4
to
+6
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not keen on this; I think we should instead advise restarting the shell, or re-sourcing?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The runtime instructions already cover what to do. I would not make this change. For example: ===
CONTINUE (y/N)? y
-- Cloning https://github.com/tj/n to '/home/mike/n/n/.repo'...
-- Running local n installation to '/home/mike/n/bin'...
-- Shell initialization file '/home/mike/.bashrc' updated.
-- Installing helper scripts in '/home/mike/n/bin'...
-- Installing the requested Node.js version(s)...
1 of 1: 26...
installing : node-v26.13.1
mkdir : /home/mike/n/n/versions/node/26.13.1
fetch : https://nodejs.org/dist/v26.13.1/node-v26.13.1-linux-x64.tar.xz
copying : node/26.13.1
installed : v26.13.1 (with npm 11.20.0)
=== n successfully installed.
The active Node.js version is: v26.13.1
Run `n -h` for help.
To update n later, run `n-update`.
To uninstall, run `n-uninstall`.
IMPORTANT: OPEN A NEW TERMINAL TAB/WINDOW or run `. /home/mike/.bashrc`
before using n and Node.js.
===
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is that Right now, pasting the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The observation that the script does not verify the installed versions of An example of an unattended installation of curl -L https://bit.ly/n-install | bash -s -- -y
. ~/.bashrc
node -v
npm -vIt's not actually clear from the instructions whether it's intended for the script to be executed by copying the whole thing and executing it in one go, or whether a user is expected to execute each one of the commands manually, one after another. |
||
|
|
||
| # Node.js already installs during n-install, but you can also install it manually: | ||
| # n install ${props.release.major} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Homebrew's own instructions do not include this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Homebrew's official
install.shdoes instruct users to do this on both Apple Silicon macOS and Linux — it does not add/opt/homebrew/binor/home/linuxbrew/.linuxbrew/bintoPATHautomatically. At the end of a fresh install, Homebrew prints:Without running
eval "$(... brew shellenv)"first, the very next line in this snippet (brew install node@26) fails immediately withzsh: command not found: brewon a clean Apple Silicon Mac or Linux machine. And without persisting it to~/.zprofile/~/.bashrc, bothbrewandnodebecomecommand not foundas soon as the user opens a new terminal.