Hi, I'm getting this error:
~/scm/bigSmall/ops/stage/mupx ~/bigSmall/ops/stage/mupx
=====================================================
---- Mupx Deploy for stage ---------------------
-----------------------------------------------------
load
current
v0.10.46
install
/usr/bin/sort
/home/michael/.nvm/nvm.sh: line 748: sort -t. -u -k 1.2: command not found
From this script:
#!/bin/bash
set -e
BUILDFOR="$1"
SERVER="$2"
IFS=',' MUPX_APPS=($3)
CONFDIR=`pwd`
echo "====================================================="
echo "---- Mupx Deploy for $BUILDFOR ---------------------"
echo "-----------------------------------------------------"
echo "load"
source ~/.nvm/nvm.sh
echo "current"
nvm current
echo "install"
which sort
nvm install 0.10.46
echo "update"
npm update -g mupx
echo "done"
Any suggestions?
What does nvm debug output? sort is part of POSIX, so it should be available.
Hey there, I'm on Linux Mint (Ubuntu 14.04).
Yes, it is available - see the which sort output -> /usr/bin/sort
What about type sort, and command sort?
☀ type sort NewMod master
sort is /usr/bin/sort
michael@mc-desktop ~/bigSmall/ops/stage/mupx
☀ command sort NewMod master
^C
command sort needed to be ctrl-c'd
I'm using version v0.30.1
I tried:
cd ~/.nvm
git pull
git checkout v0.31.7
But it didn't help :-/
current
v0.10.46
install
/usr/bin/sort
sort is /usr/bin/sort
/home/michael/.nvm/nvm.sh: line 1006: sort -t. -u -k 1.2: command not found
Version 'v0.10.46' not found - try `nvm ls-remote` to browse available versions.
So I found a work around. This code was in a called script.
``` deploy.sh
blah
../../deploy-some-apps.sh blah blah blah
Then the error happened in
nvm install v0.10.46 <---- Error here
But if I moved the `nvm install` to the outer script it works:
blah
nvm install v0.10.46 <-- works here in script called directly from command line.
../../deploy-some-apps.sh
blah
blah
blah
```
Anyways, thanks for nvm. It's cool.
Glad you figured it out - not sure why it wasn't working :-/
I'm crap at bash, but thinking about it, the environment wasn't getting passed to nvm (PATH to sort).
So probably changing ../../deploy-some-apps.sh to source ../../deploy-some-apps.sh would have fixed it.
getting this in v0.32.0 as well. Is there a v0.32.1 coming with this fix in tow?
@artlawry there's no fix yet, since we're still not sure what the problem was. What's your nvm debug output, as well as which sort?
This is all on a MacBook Air recently restored to factory and upgraded to Sierra - I'm unsure if this is related to Sierra as I had installed nvm and autoenv a good deal ago on El Capitan before this.
I'm using autoenv (runs nvm use on cd), digging into what the actual nvm command it executes is
cd control
Found '/Users/alawry/dev/brighttag/ui/control/.nvmrc' with version <v5.7.1>
-bash: sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n: command not found
Version 'v5.7.1' not found - try `nvm ls-remote` to browse available versions.
here's proof that v5.7.1 is on my system:
$ nvm use
Found '/Users/alawry/dev/brighttag/ui/control/.nvmrc' with version <v5.7.1>
Now using node v5.7.1 (npm v3.6.0)
Debug information:
$ nvm debug
nvm --version: v0.31.7
$SHELL: /bin/bash
$HOME: /Users/alawry
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v5.7.1
which node: $NVM_DIR/versions/node/v5.7.1/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v5.7.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v5.7.1
npm root -g: $NVM_DIR/versions/node/v5.7.1/lib/node_modules
$ which sort
/usr/bin/sort
$ type sort
sort is /usr/bin/sort
$ command sort
^C
had to ctrl-c the command sort
Hmm, I haven't tested on Sierra yet since I'm still on El Cap everywhere.
I don't understand why command sort wouldn't be the same as sort for you, since you have no aliases or function overrides. Since this is likely OS-related, can you file a separate issue with all the same debug output?
will do
I've been struggling with this for weeks. From what I can tell, what is happening in this command:
VERSIONS="$(nvm_echo "${VERSION_LIST}" \
| command awk -v pattern="${PATTERN-}" -v lts="${LTS-}" '{
if (!$1) { next }
if (pattern && tolower($1) !~ tolower(pattern)) { next }
if (lts == "*" && $10 ~ /^\-?$/) { next }
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
if ($10 !~ /^\-?$/) print $1, $10; else print $1
}' \
| nvm_grep -w "${PATTERN:-.*}" \
| $SORT_COMMAND)"
is that $SORT_COMMAND is not being tokenized properly. Rather, bash was interpreting the entire string (either command sort or command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n) as the command to be executed.
I'm not entirely sure //why//, but that seems to be the case. I solved this for //me// (probably not portable to all supported shells) by changing $SORT_COMMAND into an array variable.
local -a SORT_COMMAND_ARGS
SORT_COMMAND_ARGS=()
case "${FLAVOR}" in
node) SORT_COMMAND_ARGS=(-t. -u -k 1.2,1n -k 2,2n -k 3,3n) ;;
esac
... (Skip a few lines)
VERSIONS="$(nvm_echo "${VERSION_LIST}" \
| command awk -v pattern="${PATTERN-}" -v lts="${LTS-}" '{
if (!$1) { next }
if (pattern && tolower($1) !~ tolower(pattern)) { next }
if (lts == "*" && $10 ~ /^\-?$/) { next }
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
if ($10 !~ /^\-?$/) print $1, $10; else print $1
}' \
| nvm_grep -w "${PATTERN:-.*}" \
| command sort ${SORT_COMMAND_ARGS[*]} )"
Not making a pull request because I don't think it's portable, but maybe this will help track down the issue?
@aegarbutt can you open a new issue with your problem, and fill out the issue template? my first suspicion is that you're using zsh and have an interesting zsh option set, but let's flesh that out independently :-)
Will do.
(Nope, bash from homebrew)
I'm running into this on our linux CI server. I don't see any resolution or a follow up issue from @aegarbutt
Was there any resolution ?
@apsoto nope; please file an issue and fill out the template
Hi, I actually found the source of the problem. I'm using 'bash strict mode'.
http://redsymbol.net/articles/unofficial-bash-strict-mode/
The change of the field separator from space to \n\t triggers the problem.
I worked around it by setting the IFS
IFS=$' ' # nvm expects the default field separator
# DO nvm stuff
IFS=$'\n\t' # reset to use bash strict mode
You still need a separate issue since this ticket is what google sent me to when I searched for the same error?
(I thought I had sent an email response in finding my problem, but I apparently did not.)
My root cause was an IFS leakage from my bash config. Never actually determined why it only seemed to impact nvm.
@aegarbutt because nvm is sourced in your shell, so it always can be affected by anything you set in your shell.
@apsoto yes, a separate issue about IFS would be great, just because this thread is so long (but it appears that was the OP's issue too)
Most helpful comment
Hi, I actually found the source of the problem. I'm using 'bash strict mode'.
The change of the field separator from space to
\n\ttriggers the problem.I worked around it by setting the
IFSYou still need a separate issue since this ticket is what google sent me to when I searched for the same error?