Skip to content
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

type alias conflicts with nvm #2352

Open
tonykaram1993 opened this issue Nov 19, 2020 · 11 comments · May be fixed by #2356
Open

type alias conflicts with nvm #2352

tonykaram1993 opened this issue Nov 19, 2020 · 11 comments · May be fixed by #2356
Labels
pull request wanted This is a great way to contribute! Help us out :-D shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh: oh-my-zsh shell: zsh

Comments

@tonykaram1993
Copy link

tonykaram1993 commented Nov 19, 2020

Operating system and version: macOs Catalina 10.15.7

nvm debug output:

$ nvm debug
nvm --version: v0.37.0
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'tk'
${HOME}: /Users/tk
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v14.15.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64'
sha256sum
checksum binary: 'sha256sum'
sw_vers
OS version: Mac 10.15.7 19H2
curl
curl
curl
curl
curl
curl
curl: , curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget
wget
wget
wget
wget
wget
nvm:187: command not found: wget
wget: ,
sed
sed
sed
sed
sed
sed
sed:
cut
cut
cut
cut
cut
cut
cut:
basename
basename
basename
basename
basename
basename
basename:
rm
rm
rm
rm
rm
rm
rm:
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir:
xargs
xargs
xargs
xargs
xargs
xargs
xargs:
git
git
git
git
git
git
ls: : No such file or directory
git
git
git
git
git
git: , git version 2.29.2
grep
grep
grep
grep
grep
grep
ls: : No such file or directory
^G^R
sha256sum
sw_vers
curl
curl
curl
curl
curl
curl
wget
wget
wget
wget
wget
wget
sed
sed
sed
sed
sed
sed
cut
cut
cut
cut
cut
cut
basename
basename
basename
basename
basename
basename
rm
rm
rm
rm
rm
rm
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir
xargs
xargs
xargs
xargs
xargs
xargs
git
git
git
git
git
git
git
git
git
git
git
grep
grep
grep
grep
grep
grep
^G^E^P
grep
grep
^G^R
sha256sum
sw_vers
curl
curl
curl
curl
curl
curl
wget
wget
wget
wget
wget
wget
sed
sed
sed
sed
sed
sed
cut
cut
cut
cut
cut
cut
basename
basename
basename
basename
basename
basename
rm
rm
rm
rm
rm
rm
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir
xargs
xargs
xargs
xargs
xargs
xargs
git
git
git
git
git
git
git
git
git
git
git
grep
grep
grep
grep
grep
grep
^G^E^P
grep
grep
^G^E^P
grep
grep: , grep (BSD grep) 2.5.1-FreeBSD
^K
^K
awk
awk
awk
awk
ls: : No such file or directory
awk
^K
^K
awk
awk
awk: , awk version 20070501
nvm current: v14.15.1
which node: ${NVM_DIR}/versions/node/v14.15.1/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v14.15.1/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v14.15.1
npm root -g: ${NVM_DIR}/versions/node/v14.15.1/lib/node_modules

~/.nvm ⌚ 20:58:11
$ sha256sum
zsh: command not found: sha256sum

~/.nvm ⌚ 20:58:11
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H2

~/.nvm ⌚ 20:58:11
$ curl
curl: try 'curl --help' or 'curl --manual' for more information

~/.nvm ⌚ 20:58:11
$ curl
curl: try 'curl --help' or 'curl --manual' for more information

~/.nvm ⌚ 20:58:11
$ curl
curl: try 'curl --help' or 'curl --manual' for more information

~/.nvm ⌚ 20:58:11
$ curl
curl: try 'curl --help' or 'curl --manual' for more information

~/.nvm ⌚ 20:58:11
$ curl
curl: try 'curl --help' or 'curl --manual' for more information

~/.nvm ⌚ 20:58:11
$ curl
curl: try 'curl --help' or 'curl --manual' for more information

~/.nvm ⌚ 20:58:11
$ wget
zsh: command not found: wget

~/.nvm ⌚ 20:58:11
$ wget
zsh: command not found: wget

~/.nvm ⌚ 20:58:11
$ wget
zsh: command not found: wget

~/.nvm ⌚ 20:58:11
$ wget
zsh: command not found: wget

~/.nvm ⌚ 20:58:11
$ wget
zsh: command not found: wget

~/.nvm ⌚ 20:58:11
$ wget
zsh: command not found: wget

~/.nvm ⌚ 20:58:12
$ sed
sed
sed
sed
sed
sed
cut
cut
cut
cut
cut
cut
basename
basename
basename
basename
basename
basename
rm
rm
rm
rm
rm
rm
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir
xargs
xargs
xargs
xargs
xargs
xargs
git
git
git
git
git
git
git
git
git
git
git
grep
grep
grep
grep
grep
grep
^G^E^P
grep
grep
^G^E^P
grep
^K
^K
awk
awk
awk
awk
awk
^K
^K
awk
awk
sed
sed
sed
sed
sed
cut
cut
cut
cut
cut
cut
basename
basename
basename
basename
basename
basename
rm
rm
rm
rm
rm
rm
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir
xargs
xargs
xargs
xargs
xargs
xargs
git
git
git
git
git
git
git
git
git
git
git
grep
grep
grep
grep
grep

nvm ls output:

$ nvm ls
tput
->     v14.15.1
        v15.2.1
tput
default -> lts/* (-> v14.15.1)
tputtputtput


tput
node -> stable (-> v15.2.1) (default)
stable -> 15.2 (-> v15.2.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
tputtputtputtputtputtputtput






lts/* -> lts/fermium (-> v14.15.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.23.0 (-> N/A)
lts/erbium -> v12.19.1 (-> N/A)
lts/fermium -> v14.15.1

~/.nvm ⌚ 20:59:23
$ tput
usage: tput [-V] [-S] [-T term] capname

~/.nvm ⌚ 20:59:23
$ tput
usage: tput [-V] [-S] [-T term] capname

~/.nvm ⌚ 20:59:23
$ tputtputtput
zsh: command not found: tputtputtput

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$ tput
usage: tput [-V] [-S] [-T term] capname

~/.nvm ⌚ 20:59:23
$ tputtputtputtputtputtputtput
zsh: command not found: tputtputtputtputtputtputtput

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$

~/.nvm ⌚ 20:59:23
$

How did you install nvm?

Tried both, first with install script in readme, and then through Homebrew. Both produced the same output.

What steps did you perform?

Normal nvm commands.

What happened?

NVM seems to be working fine, it could be that only the output is messed up.

What did you expect to happen?

Output to be colored and correct in a single return.

Is there anything in any of your profile files that modifies the PATH?

# Android Studio env variables
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
@ljharb
Copy link
Member

ljharb commented Nov 20, 2020

What is tput?

@tonykaram1993
Copy link
Author

Your guess is as good as mine.

In my frustration, I was googling the issue and found this http://linuxcommand.org/lc3_adv_tput.php and that's why I thought it was related, cause I saw 'tput' in the terminal being output by nvm.

@ljharb
Copy link
Member

ljharb commented Nov 20, 2020

Could you perhaps share your relevant profile file(s) (with secret things redacted, ofc)?

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Nov 20, 2020
@tonykaram1993
Copy link
Author

tonykaram1993 commented Nov 20, 2020

The following is my .zshrc file (functions and aliases removed as they make no difference), not sure what other file you would want. Let me know and I will provide them.

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/johndoe/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="amuse"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Let zsh know not to update everytime install is called
HOMEBREW_NO_AUTO_UPDATE=1

# Android Studio env variables
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

export EDITOR="/usr/local/bin/code"

# NVM env variables
export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

# Get a fortune quote told by the almighty cow
fortune | cowsay

# Customer color to spice up display message
RED='\033[0;31m'
BLUE='\033[0;34m'
NORMAL='\033[0m'

# Set personal aliases, overriding those provided by oh-my-zsh libs, plugins,
# and themes. Aliases can be placed here, though oh-my-zsh users are encouraged
# to define aliases within the ZSH_CUSTOM folder. For a full list of active
# aliases, run `alias`.

@ljharb
Copy link
Member

ljharb commented Nov 21, 2020

/usr/local/opt implies you installed nvm via homebrew, which is entirely unsupported. Even if the same thing happens, please brew uninstall, and reinstall through the proper curl/wget install script.

My guess is that this is related to OMZ. What's in your oh-my-zsh.sh file?

@tonykaram1993
Copy link
Author

@ljharb Alright I have uninstalled it from brew and reinstalled using the script.

Here are the contents of my oh-my-zsh.sh file:

# Set ZSH_CACHE_DIR to the path where cache files should be created
# or else we will use the default cache/
if [[ -z "$ZSH_CACHE_DIR" ]]; then
  ZSH_CACHE_DIR="$ZSH/cache"
fi

# Migrate .zsh-update file to $ZSH_CACHE_DIR
if [ -f ~/.zsh-update ] && [ ! -f ${ZSH_CACHE_DIR}/.zsh-update ]; then
    mv ~/.zsh-update ${ZSH_CACHE_DIR}/.zsh-update
fi

# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
  env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
fi

# Initializes Oh My Zsh

# add a function path
fpath=($ZSH/functions $ZSH/completions $fpath)

# Load all stock functions (from $fpath files) called below.
autoload -U compaudit compinit

# Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/
if [[ -z "$ZSH_CUSTOM" ]]; then
    ZSH_CUSTOM="$ZSH/custom"
fi


is_plugin() {
  local base_dir=$1
  local name=$2
  builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
    || builtin test -f $base_dir/plugins/$name/_$name
}

# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
  if is_plugin $ZSH_CUSTOM $plugin; then
    fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
  elif is_plugin $ZSH $plugin; then
    fpath=($ZSH/plugins/$plugin $fpath)
  else
    echo "[oh-my-zsh] plugin '$plugin' not found"
  fi
done

# Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then
  # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
  SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
else
  SHORT_HOST=${HOST/.*/}
fi

# Save the location of the current completion dump file.
if [ -z "$ZSH_COMPDUMP" ]; then
  ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi

if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
  source $ZSH/lib/compfix.zsh
  # If completion insecurities exist, warn the user
  handle_completion_insecurities
  # Load only from secure directories
  compinit -i -C -d "${ZSH_COMPDUMP}"
else
  # If the user wants it, load from all found directories
  compinit -u -C -d "${ZSH_COMPDUMP}"
fi


# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do
  custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
  [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
  source $config_file
done

# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
  if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
    source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
  elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
    source $ZSH/plugins/$plugin/$plugin.plugin.zsh
  fi
done

# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
  source $config_file
done
unset config_file

# Load the theme
if [[ "$ZSH_THEME" == "random" ]]; then
  if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
    themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
  else
    themes=($ZSH/themes/*zsh-theme)
  fi
  N=${#themes[@]}
  ((N=(RANDOM%N)+1))
  RANDOM_THEME=${themes[$N]}
  source "$RANDOM_THEME"
  echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
  if [ ! "$ZSH_THEME" = ""  ]; then
    if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
      source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
    elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
      source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
    else
      source "$ZSH/themes/$ZSH_THEME.zsh-theme"
    fi
  fi
fi

@tonykaram1993
Copy link
Author

tonykaram1993 commented Nov 21, 2020

Alright so I found the issue, output is now correct.

The issue was that I had a function in my .zshrc called type. I have scripts that auto types stuff for me:

# Keystroke Function
function type() {
  echo "$KEYSTROKE \"$1\"" | osascript
  echo "$KEYSTROKE return" | osascript
}

So calling type "cd ~" would actually simulate key presses on my keyboard that type cd ~ and then hits the enter key.
I changed the name of the above function to something else and now everything works, all output is correct. It appears that nvm uses type or something and my function was overwriting it hence the mangled nvm output.

nvm ls now outputs the following:

~ ⌚ 17:35:12
$ nvm ls
->     v14.15.1
        v15.2.1
default -> lts/* (-> v14.15.1)
node -> stable (-> v15.2.1) (default)
stable -> 15.2 (-> v15.2.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/fermium (-> v14.15.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.23.0 (-> N/A)
lts/erbium -> v12.19.1 (-> N/A)
lts/fermium -> v14.15.1

@ljharb
Copy link
Member

ljharb commented Nov 21, 2020

Aha, yes, type is a shell builtin. I’ll see about escaping it to ensure this doesn’t cause problems. Thanks for finding it!

@ljharb ljharb added pull request wanted This is a great way to contribute! Help us out :-D shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh shell: zsh: oh-my-zsh and removed needs followup We need some info or action from whoever filed this issue/PR. labels Nov 21, 2020
@ljharb ljharb changed the title tput is messed up in nvm output type alias conflicts with nvm Nov 21, 2020
@ljharb ljharb closed this as completed in d8f1d49 Nov 21, 2020
@ljharb
Copy link
Member

ljharb commented Nov 21, 2020

Ended up reverting this change since it broke some tests; i'll re-add it via PR.

@ljharb ljharb reopened this Nov 21, 2020
ljharb added a commit to ljharb/nvm that referenced this issue Nov 21, 2020
@ljharb ljharb linked a pull request Nov 21, 2020 that will close this issue
ljharb added a commit to ljharb/nvm that referenced this issue Feb 19, 2021
@sladyn98
Copy link
Contributor

sladyn98 commented Mar 1, 2021

@ljharb I guess this is solved right.

@ljharb
Copy link
Member

ljharb commented Mar 1, 2021

No; #2356 is still open, and the tests are failing. Feel free to post a link to a branch in the PR and I’ll pull in your changes.

ljharb added a commit to ljharb/nvm that referenced this issue Mar 18, 2021
ljharb added a commit to ljharb/nvm that referenced this issue Mar 18, 2021
ljharb added a commit to ljharb/nvm that referenced this issue Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request wanted This is a great way to contribute! Help us out :-D shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh: oh-my-zsh shell: zsh
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants