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

nvm error after adding lines to .bashrc #1725

Closed
angryrobot opened this issue Feb 8, 2018 · 6 comments
Closed

nvm error after adding lines to .bashrc #1725

angryrobot opened this issue Feb 8, 2018 · 6 comments
Labels
shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions.

Comments

@angryrobot
Copy link

angryrobot commented Feb 8, 2018

  • Operating system and version: Arch Linux 4.14.3-1-hardened

  • nvm debug output:

nvm --version: v0.33.8
$SHELL: /bin/bash
$HOME: /home/raven
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
-bash: /b: No such file or directory
shell version: ''
uname -a: 'Linux 4.14.3-1-hardened #1 SMP PREEMPT Sun Dec 3 21:50:32 CET 2017 x86_64 GNU/Linux'
OS version: Arch Linux  ()
curl: /usr/bin/curl, curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.29.0
wget: /usr/bin/wget, GNU Wget 1.19.4 built on linux-gnu.
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: : command not found
git: , 
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: : command not found
grep: , 
awk: /usr/bin/awk, GNU Awk 4.2.0, API: 2.0 (GNU MPFR 4.0.0, GNU MP 6.1.2)
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: : command not found
sed: , 
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: : command not found
cut: , 
-bash: type: ba: not found
-bash: type: ba: not found
-bash: type: ba: not found
-bash: type: ba: not found
-bash: type: ba: not found
-bash: ba: command not found
basename: , 
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: type: : not found
-bash: : command not found
rm: , 
-bash: type: mk: not found
-bash: type: mk: not found
-bash: type: mk: not found
-bash: type: mk: not found
-bash: type: mk: not found
-bash: mk: command not found
mkdir: , 
-bash: type: xa: not found
-bash: type: xa: not found
-bash: type: xa: not found
-bash: type: xa: not found
-bash: type: xa: not found
-bash: xa: command not found
xargs: , 
nvm current: -bash: : command not found
which node: -bash: wh: command not found
which iojs: -bash: wh: command not found
which npm: -bash: wh: command not found
npm config get prefix: -bash: : command not found
npm root -g: -bash: : command not found
  • nvm ls output:
-bash: [: : integer expression expected
-bash: [: too many arguments
        v6.11.4
          v8.7.
         system
-bash: [: : integer expression expected
-bash: [: too many arguments
default -> 8.7.0 (-> v8.7.0)
-bash: [: too many arguments
node -> stable (-> N/A) (default)
-bash: : command not found
-bash: : command not found
-bash: : command not found
-bash: : command not found
-bash: [: too many arguments
-bash: [: too many arguments
lts/* -> lts/boron (-> N/A)
-bash: [: too many arguments
lts/argon -> v4.8.5 (-> N/A)
-bash: [: too many arguments
lts/boron -> v6.11.5 (-> N/A)
-bash: return: : numeric argument required
  • How did you install nvm? (e.g. install script in readme, homebrew):
    Install script using cURL

  • What steps did you perform?
    Cloned the repository then added the source lines to .bashrc
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion

  • What happened? It worked but now every time I open a new terminal or source ~/.bashrc it outputs three lines before the bash prompt, they are as follows:
    -bash: [: : integer expression expected
    -bash: [: too many arguments
    -bash: [: too many arguments

  • What did you expect to happen? I expected my bash prompt to be unchanged.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH? Yes, here is a copy of my .bashrc file:

 #!/bin/bash

export PATH=~/bin:$PATH
export EDITOR="nano"
export PAGER="more"

force_color_prompt=yes

# Disable BIOS beep on delete and backspace
xset -b

#history length settings see bash(1) in man bash
HISTSIZE=100000
HISTFILESIZE=200000

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '

# 
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

#Neofetch (Command Line System Information Script)
#config file locted at /home/raven/.config/neofetch/
#source /etc/neofetch/config
neofetch

#Vim Configuration File
PATH=$PATH:~/.vimrc
export PATH

#Nano Configuration File
PATH=$PATH:~/.nanorc
export PATH

#Git Configuration File
PATH=$PATH:/usr/bin/git
#PATH=$PATH:~/.gitconfig
export PATH

#Ccache used for Android Building, set to min. of 50GB
#export USE_CCACHE=1

#Java PATH
#export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/bin/java
#export PATH=$PATH:$JAVA_HOME/bin

#export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_131

#Python
#alias python='/usr/bin/python2.7'
alias python='/usr/bin/python3.6'

#Golang PATH
GOPATH=/usr/local/go
export GOPATH="$HOME/go_projects"
export GOBIN="$GOPATH/bin"
export PATH=$PATH:/usr/local/go/bin

#DartSDK PATH
export PATH="$PATH":/opt/dart-sdk/bin/
export PATH=/usr/bin/dart:$PATH

#Lua PATH
#export LUA_PATH=$my_path/usr/bin/lua5.3

# Scala is a general-purpose programming language
# providing support for functional programming
# and a strong static type system
# Filename Extensions: .scala, .sc

#Flutter PATH
#export PATH=$HOME/gitsync/flutter/bin:$PATH

#Scala Path
#export PATH="$PATH":/usr/bin/scala
#export PATH=/usr/bin/scala:$PATH

#Cabal PATH
#export PATH="$HOME/.cabal/bin:/opt/cabal/1.22/bin:/opt/ghc/7.10.3/bin:$PATH"

#Crystal Language PATH
#export PATH="$PATH:/usr/bin/crystal"

#CARGO PATH (Rust Package Manager)
#export PATH=/home/raven/.cargo/bin:$PATH
#export PATH="$HOME/.cargo/bin:$PATH"

#DEVELOPMENT > ANDROID

#Android Development PATH (sdk)
export ANDROID_HOME=/home/raven/android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

#Android Development PATH (ndk)
export ANDROID_HOME_DEV=/home/raven/android/ndk
export PATH=$PATH:$ANDROID_HOME_DEV/toolchains:$ANDROID_HOME_DEV/toolchains

#DEVELOPMENT PATHS > WEBDEV | CODE | SANDBOX
#Paths to frequently used development folders

#WebDev PATH
export WEBDEV=/home/raven/webdev
export PATH=$PATH:$WEBDEV/home/raven/webdev/

#Code PATH
export CODE=/home/raven/code
export PATH=$PATH:$CODE/home/raven/code/

#Sandbox PATH
export SANDBOX=/home/raven/sandbox/
export PATH=$PATH:$SANDBOX/home/raven/sandbox/

#Package Management

#Bower PATH
export PATH="$PATH:/usr/lib/node_modules/bower/bin/bower"

#Yarn PATH
#export PATH="$PATH:/usr/bin/yarn"

#NPM (Node Package Manager)
#export PATH="$PATH:./node_modules/.bin"
export PATH="$PATH:./node_modules/.bin:/usr/local/bin"

#NVM (Node Version Manager)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

#NVM (Node Version Manager)
#source /usr/share/nvm/init-nvm.sh

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

# Path to the bash it configuration
export BASH_IT="/home/raven/.bash_it"

# Lock and Load a custom theme file
# location /.bash_it/themes/
export BASH_IT_THEME='powerline-plain'

# (Advanced): Change this to the name of your remote repo if you
# cloned bash-it with a remote other than origin such as `bash-it`.
# export BASH_IT_REMOTE='bash-it'

# Your place for hosting Git repos. I use this for private repos.
export GIT_HOSTING='git@git.domain.com'

# Don't check mail when opening terminal.
unset MAILCHECK

# Change this to your console based IRC client of choice.
export IRC_CLIENT='irssi'

# Set this to the command you use for todo.txt-cli
export TODO="t"

# Set this to false to turn off version control status checking within the prompt for all themes
export SCM_CHECK=true

# Set Xterm/screen/Tmux title with only a short hostname.
# Uncomment this (or set SHORT_HOSTNAME to something else),
# Will otherwise fall back on $HOSTNAME.
#export SHORT_HOSTNAME=$(hostname -s)

# Set Xterm/screen/Tmux title with only a short username.
# Uncomment this (or set SHORT_USER to something else),
# Will otherwise fall back on $USER.
#export SHORT_USER=${USER:0:8}

# Set Xterm/screen/Tmux title with shortened command and directory.
# Uncomment this to set.
#export SHORT_TERM_LINE=true

# Set vcprompt executable path for scm advance info in prompt (demula theme)
# https://github.com/djl/vcprompt
#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt

# (Advanced): Uncomment this to make Bash-it reload itself automatically
# after enabling or disabling aliases, plugins, and completions.
# export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1

# Load Bash It
source "$BASH_IT"/bash_it.sh
@ljharb
Copy link
Member

ljharb commented Feb 9, 2018

What is source "$BASH_IT"/bash_it.sh? What happens if you comment out that line?

@angryrobot
Copy link
Author

It's a bash framework. It doesn't matter if it's commented or not I still get the same error. I have removed everything and added things back to my bash script one a a time and doing a source ~/.bashrc after each one. There is nothing in my bash script that is causing the error except the 2 NVM lines. If I leave the first one and remove the other 2 the error goes away. I'm very meticulous about how I do things and asking for help here is a last resort. I've tried everything I can think of to fix this to no avail.

@ljharb
Copy link
Member

ljharb commented Feb 9, 2018

Is your home dir, or $NVM_DIR, a symlink? Can you share the contents of . ~/.bash_aliases?

The issue here is because nvm is a sourced shell function, so it could conflict with literally any other line in your bash sourcing path, such that commenting out the "source nvm" line would work, but also commenting out "the conflicting line" would work - we only have to find it :-) Once we do, I can see if there's a way for nvm to work around it.

@PeterDaveHello
Copy link
Collaborator

@ljharb what do you think about adding a issue label like waiting for response for issues like this one?

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Feb 18, 2018
@angryrobot
Copy link
Author

Sorry so long to respond. I've been on vacation. Anyway I figured out why it was causing the error. In my ~/.bash_aliases I had an alias - alias="tr=tree" and that was causing the error. I renamed it and everything works fine now. @ljharb thank you for all of your help.

@PeterDaveHello
Copy link
Collaborator

PeterDaveHello commented Feb 19, 2018

okay, I know how to fix it now, something like what I guess, PR #1735 sent now, with that fix, you should be able to keep your personal aliases :)

PeterDaveHello added a commit to PeterDaveHello/nvm that referenced this issue Feb 19, 2018
@ljharb ljharb added bugs Oh no, something's broken :-( shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. and removed needs followup We need some info or action from whoever filed this issue/PR. bugs Oh no, something's broken :-( labels Feb 19, 2018
@ljharb ljharb closed this as completed in f290ccf Feb 19, 2018
edwmurph pushed a commit to edwmurph/nvm that referenced this issue Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions.
Projects
None yet
Development

No branches or pull requests

3 participants