Skip to content

Commit ba9f315

Browse files
committed
Merge commit 'rbenv-tags/v1.2.0' into pull-rbenv
* commit 'rbenv-tags/v1.2.0': rbenv 1.2.0 Clarify bash config for Ubuntu Desktop vs. other platforms 💅 Clean up version sorting and add test Sort versions semantically in rbenv versions Have shims survive symlinked rbenv updates a la Homebrew GitHub now auto-generates a Table of Contents Speed up rehash Have `rbenv init` print instructions that hardcode the detected shell Supply `head -n` flag explicitly Update rbenv-doctor link master -> main Updated rbenv-doctor url to reflect renaming master branch to main Fix link to rbenv-doctor test(init): remove misleading arg in detect from parent shell case feat(init): strip -<suffix> when autodetecting shell [DOCS] Typo and formatting fix. Use a better PS4 as recommeneded by Bash Hackers Wiki Update README.md README: reflect changes in rbenv/ruby-build#1402 Rename CONDUCT.md to CODE_OF_CONDUCT.md bash completion: avoid unintentional globbing Make work in set -u (nounset) mode Spelling fix Remove agignore Fix fish instructions test Remove another `fish` psub usage Fix fish shell initialization Use `actions/checkout` v2 Run CI for pull requests from forks Re-add zsh completion script and remove fish completion script Remove fish completion script Fix (revert) test/version-origin.bats libexec/rbenv-version{,-origin}: move "missing rbenv-version-file detection" logic as per @mislav Fix tests for #1203 libexec/rbenv-version{,-origin}: fix earlier commit to allow for RBENV_VERSION env var libexec/rbenv-version: get rid of misleading "set by $(rbenv-version-origin)" message when system ruby is in use test/run: handle optional paths/args for bats Documentation unclear
2 parents 4f52abc + 38e1fbb commit ba9f315

22 files changed

+296
-162
lines changed

.agignore

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.

README.md

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,38 @@ Version names to nodenv are simply the names of the directories or symlinks in
147147

148148
## Installation
149149

150-
### Homebrew on macOS
150+
### Using Package Managers
151151

152+
1. Install nodenv.
153+
- **macOS**
152154
If you're on macOS, we recommend installing nodenv with
153155
[Homebrew](https://brew.sh).
154156

155-
1. Install nodenv.
156-
157157
~~~ sh
158158
$ brew install nodenv
159159
~~~
160160

161161
Note that this also installs `node-build`, so you'll be ready to
162162
install other Node versions out of the box.
163163

164+
- **Upgrading with Homebrew**
165+
166+
To upgrade to the latest nodenv and update node-build with newly released
167+
Node versions, upgrade the Homebrew packages:
168+
169+
~~~ sh
170+
$ brew upgrade nodenv node-build
171+
~~~
172+
- **Debian, Ubuntu and their derivatives**
173+
~~~ sh
174+
$ sudo apt install nodenv
175+
~~~
176+
- **Arch Linux and it's derivatives**
177+
178+
Archlinux has an [AUR Package](https://aur.archlinux.org/packages/nodenv/) for
179+
nodenv and you can install it from the AUR using the instructions from this
180+
[wiki page](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_and_upgrading_packages).
181+
164182
2. Set up nodenv in your shell.
165183
166184
~~~ sh
@@ -178,7 +196,7 @@ If you're on macOS, we recommend installing nodenv with
178196
4. Verify that nodenv is properly set up using this [nodenv-doctor][] script:
179197

180198
~~~ sh
181-
$ curl -fsSL https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-doctor | bash
199+
$ curl -fsSL https://github.com/nodenv/nodenv-installer/raw/main/bin/nodenv-doctor | bash
182200
Checking for `nodenv' in PATH: /usr/local/bin/nodenv
183201
Checking for nodenv shims in PATH: OK
184202
Checking `nodenv install' support: /usr/local/bin/nodenv-install (node-build 3.0.22-4-g49c4cb9)
@@ -193,16 +211,6 @@ If you're on macOS, we recommend installing nodenv with
193211
`nodenv install`.
194212
195213
196-
#### Upgrading with Homebrew
197-
198-
To upgrade to the latest nodenv and update node-build with newly released
199-
Node versions, upgrade the Homebrew packages:
200-
201-
~~~ sh
202-
$ brew upgrade nodenv node-build
203-
~~~
204-
205-
206214
### Basic GitHub Checkout
207215
208216
For a more automated install, you can use [nodenv-installer][].
@@ -229,13 +237,15 @@ a systemwide install.
229237
command-line utility.
230238

231239
* For **bash**:
240+
241+
Ubuntu Desktop users should configure `~/.bashrc`:
232242
~~~ bash
233-
$ echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bash_profile
243+
$ echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
234244
~~~
235245

236-
* For **Ubuntu Desktop** and **Windows Subsystem for Linux (WSL)**:
246+
On other platforms, bash is usually configured via `~/.bash_profile`:
237247
~~~ bash
238-
$ echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
248+
$ echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bash_profile
239249
~~~
240250

241251
* For **Zsh**:
@@ -262,7 +272,7 @@ a systemwide install.
262272
5. Verify that nodenv is properly set up using this [nodenv-doctor][] script:
263273

264274
~~~ sh
265-
$ curl -fsSL https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-doctor | bash
275+
$ curl -fsSL https://github.com/nodenv/nodenv-installer/raw/main/bin/nodenv-doctor | bash
266276
Checking for `nodenv' in PATH: /usr/local/bin/nodenv
267277
Checking for nodenv shims in PATH: OK
268278
Checking `nodenv install' support: /usr/local/bin/nodenv-install (node-build 3.0.22-4-g49c4cb9)
@@ -349,13 +359,18 @@ provided by the [node-build][] project. If you installed it as part of GitHub
349359
checkout process outlined above you should be able to:
350360
351361
~~~ sh
352-
# list all available versions:
362+
# list latest stable versions:
353363
$ nodenv install -l
354364
365+
# list all local versions:
366+
$ nodenv install -L
367+
355368
# install a Node version:
356-
$ nodenv install 0.10.26
369+
$ nodenv install 16.13.2
357370
~~~
358371
372+
Set a Node version to finish installation and start using commands `nodenv global 18.14.1` or `rbenv local 18.14.1`
373+
359374
Alternatively to the `install` command, you can download and compile
360375
Node manually as a subdirectory of `~/.nodenv/versions/`. An entry in
361376
that directory can also be a symlink to a Node version installed
@@ -407,9 +422,17 @@ uninstall from the system.
407422
rm -rf `nodenv root`
408423
409424
If you've installed nodenv using a package manager, as a final step
410-
perform the nodenv package removal. For instance, for Homebrew:
411-
412-
brew uninstall nodenv
425+
perform the nodenv package removal.
426+
- Homebrew:
427+
428+
`brew uninstall nodenv`
429+
- Debian, Ubuntu and their derivatives:
430+
431+
`sudo apt purge nodenv`
432+
433+
- Archlinux and it's derivatives:
434+
435+
`sudo pacman -R nodenv`
413436
414437
## Command Reference
415438
@@ -548,7 +571,7 @@ McKenzie](https://github.com/oinutter) and modified for node.
548571

549572
[hooks]: https://github.com/rbenv/rbenv/wiki/Authoring-plugins#rbenv-hooks
550573
[node-build]: https://github.com/nodenv/node-build#readme
551-
[nodenv-doctor]: https://github.com/nodenv/nodenv-installer/blob/master/bin/nodenv-doctor
574+
[nodenv-doctor]: https://github.com/nodenv/nodenv-installer/blob/main/bin/nodenv-doctor
552575
[nodenv-installer]: https://github.com/nodenv/nodenv-installer#nodenv-installer
553576
[nodenv-update]: https://github.com/charlesbjohnson/nodenv-update
554577
[package-rehash-plugin]: https://github.com/nodenv/nodenv-package-rehash

completions/nodenv.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ _nodenv() {
66
COMPREPLY=( $(compgen -W "$(nodenv commands)" -- "$word") )
77
else
88
local words=("${COMP_WORDS[@]}")
9-
unset words[0]
10-
unset words[$COMP_CWORD]
9+
unset "words[0]"
10+
unset "words[$COMP_CWORD]"
1111
local completions=$(nodenv completions "${words[@]}")
1212
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
1313
fi

completions/nodenv.fish

Lines changed: 0 additions & 23 deletions
This file was deleted.

libexec/nodenv

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ if [ "$1" = "--debug" ]; then
77
fi
88

99
if [ -n "$NODENV_DEBUG" ]; then
10-
export PS4='+ [${BASH_SOURCE##*/}:${LINENO}] '
10+
# https://wiki-dev.bash-hackers.org/scripting/debuggingtips#making_xtrace_more_useful
11+
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
1112
set -x
1213
fi
1314

@@ -26,7 +27,9 @@ if enable -f "${BASH_SOURCE%/*}"/../libexec/nodenv-realpath.dylib realpath 2>/de
2627
echo "${path%/*}"
2728
}
2829
else
29-
READLINK=$(type -p greadlink readlink 2>/dev/null | head -1)
30+
[ -z "$NODENV_NATIVE_EXT" ] || abort "failed to load \`realpath' builtin"
31+
32+
READLINK=$(type -p greadlink readlink 2>/dev/null | head -n1)
3033
[ -n "$READLINK" ] || abort "cannot find readlink - are you missing GNU coreutils?"
3134

3235
resolve_link() {
@@ -65,6 +68,7 @@ else
6568
fi
6669
export NODENV_DIR
6770

71+
[ -n "$NODENV_ORIG_PATH" ] || export NODENV_ORIG_PATH="$PATH"
6872

6973
shopt -s nullglob
7074

libexec/nodenv---version

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
set -e
1313
[ -n "$NODENV_DEBUG" ] && set -x
1414

15-
cd "${BASH_SOURCE%/*}" 2>/dev/null
16-
1715
version=1.4.1
16+
git_revision=""
1817

1918
semver_compliant() {
2019
sed -E 's/-([[:digit:]]+)-g([[:alnum:]]+)/+\1.\2/'
2120
}
2221

23-
if git remote -v 2>/dev/null | grep -q nodenv; then
22+
if cd "${BASH_SOURCE%/*}" 2>/dev/null && git remote -v 2>/dev/null | grep -q nodenv; then
2423
git_revision="$(git describe --tags HEAD 2>/dev/null | semver_compliant || true)"
2524
git_revision="${git_revision#v}"
2625
fi

libexec/nodenv-help

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extract_initial_comment_block() {
4343

4444
collect_documentation() {
4545
local awk
46-
awk="$(type -p gawk awk 2>/dev/null | head -1)"
46+
awk="$(type -p gawk awk 2>/dev/null | head -n1)"
4747
if [ -z "$awk" ]; then
4848
echo "nodenv: cannot find awk" >&2
4949
return 1

libexec/nodenv-hooks

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,34 @@ if [ -z "$NODENV_COMMAND" ]; then
2222
fi
2323

2424
if ! enable -f "${BASH_SOURCE%/*}"/nodenv-realpath.dylib realpath 2>/dev/null; then
25-
READLINK=$(type -p greadlink readlink 2>/dev/null | head -1)
26-
if [ -z "$READLINK" ]; then
27-
echo "nodenv: cannot find readlink - are you missing GNU coreutils?" >&2
25+
if [ -n "$NODENV_NATIVE_EXT" ]; then
26+
echo "nodenv: failed to load \`realpath' builtin" >&2
2827
exit 1
2928
fi
29+
READLINK=$(type -p greadlink readlink 2>/dev/null | head -n1)
30+
if [ -z "$READLINK" ]; then
31+
echo "nodenv: cannot find readlink - are you missing GNU coreutils?" >&2
32+
exit 1
33+
fi
3034

31-
resolve_link() {
32-
$READLINK "$1"
33-
}
35+
resolve_link() {
36+
$READLINK "$1"
37+
}
3438

35-
realpath() {
36-
local cwd="$PWD"
37-
local path="$1"
38-
local name
39+
realpath() {
40+
local cwd="$PWD"
41+
local path="$1"
42+
local name
3943

40-
while [ -n "$path" ]; do
41-
name="${path##*/}"
42-
[ "$name" = "$path" ] || cd "${path%/*}"
43-
path="$(resolve_link "$name" || true)"
44-
done
44+
while [ -n "$path" ]; do
45+
name="${path##*/}"
46+
[ "$name" = "$path" ] || cd "${path%/*}"
47+
path="$(resolve_link "$name" || true)"
48+
done
4549

46-
echo "${PWD}/$name"
47-
cd "$cwd"
48-
}
50+
echo "${PWD}/$name"
51+
cd "$cwd"
52+
}
4953
fi
5054

5155
IFS=: hook_paths=($NODENV_HOOK_PATH)

libexec/nodenv-init

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ if [ -z "$shell" ]; then
3838
shell="${shell##-}"
3939
shell="${shell:-$SHELL}"
4040
shell="${shell##*/}"
41+
shell="${shell%%-*}"
4142
fi
4243

4344
root="${0%/*}/.."
@@ -70,10 +71,10 @@ if [ -z "$print" ]; then
7071
echo
7172
case "$shell" in
7273
fish )
73-
echo 'status --is-interactive; and source (nodenv init -|psub)'
74+
echo 'status --is-interactive; and nodenv init - fish | source'
7475
;;
7576
* )
76-
echo 'eval "$(nodenv init -)"'
77+
printf 'eval "$(nodenv init - %s)"\n' "$shell"
7778
;;
7879
esac
7980
echo
@@ -92,14 +93,14 @@ fish )
9293
* )
9394
echo 'export PATH="'${NODENV_ROOT}'/shims:${PATH}"'
9495
echo "export NODENV_SHELL=$shell"
96+
97+
completion="${root}/completions/nodenv.${shell}"
98+
if [ -r "$completion" ]; then
99+
echo "source '$completion'"
100+
fi
95101
;;
96102
esac
97103

98-
completion="${root}/completions/nodenv.${shell}"
99-
if [ -r "$completion" ]; then
100-
echo "source '$completion'"
101-
fi
102-
103104
if [ -z "$no_rehash" ]; then
104105
echo 'command nodenv rehash 2>/dev/null'
105106
fi
@@ -114,7 +115,7 @@ function nodenv
114115
115116
switch "\$command"
116117
case ${commands[*]}
117-
source (nodenv "sh-\$command" \$argv|psub)
118+
nodenv "sh-\$command" \$argv|source
118119
case '*'
119120
command nodenv "\$command" \$argv
120121
end

0 commit comments

Comments
 (0)