zshrc outputing cryptic errors on iterm2 at loading - bash

I am a Mac user on osx 10.15.7 (Catalina).
I recently updated brew and upgraded formulas with it.
Since then, my terminal has become erratic and prints out these errors:
_zulu_init_setup_completion:9: compinit: function definition file not found
/user/path/.zulu/packages/tipz/tipz.zsh:86: add-zsh-hook: function definition file not found
_zulu_init:48: promptinit: function definition file not found
_zulu_init:50: command not found: prompt
/user/path/.zprezto/init.zsh:14: is-at-least: function definition file not found
prezto: old shell detected, minimum required: 4.3.17
/user/path/.zshrc:19: promptinit: function definition file not found
/usr/local/Cellar/zplug/2.4.2/autoload/init.zsh:16: colors: function definition file not found
polling.zsh:17: add-zsh-hook: function definition file not found
# the following line is repeated at least 20 times
__zplug::core::core::get_interfaces:49: regexp-replace: function definition file not found
__zplug::core::core::prepare:67: compinit: function definition file not found
[zplug] ERROR: The loading of zplug was discontinued.
/user/path/.nvm/bash_completion:87: bashcompinit: function definition file not found
/user/path/.nvm/bash_completion:88: compinit: function definition file not found
/user/path/.nvm/bash_completion:95: command not found: complete
/user/path/.zshrc:35: command not found: gcloud
/user/path/google-cloud-sdk/completion.zsh.inc:1: bashcompinit: function definition file not found
/user/path/google-cloud-sdk/completion.zsh.inc:4: compinit: function definition file not found
/user/path/google-cloud-sdk/completion.zsh.inc:37: command not found: complete
/user/path/google-cloud-sdk/completion.zsh.inc:62: command not found: complete
/user/path/google-cloud-sdk/completion.zsh.inc:63: command not found: complete
I am not very versed into bash I think my installation might have been way to complex also (oh-my-zsh, prezto, powerlevel10k).
I just would like to know how to weed out the error and fix this.
my zshrc looks as follow
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu#gmail.com>
#
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# Initialise zulu plugin manager
source "${ZULU_DIR:-"${ZDOTDIR:-$HOME}/.zulu"}/core/zulu"
zulu init
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Customize to your needs...
autoload -Uz promptinit
promptinit
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
# export PATH="$PATH:$HOME/.rvm/rubies/ruby-2.4.1/bin/"
# loading ZPLUG
export ZPLUG_HOME=/usr/local/opt/zplug
source $ZPLUG_HOME/init.zsh
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
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:/user/path/Library/Python/3.7/bin:$PATH"
export GOOGLE_PROJECT="$(gcloud config get-value project)"
export GOOGLE_APPLICATION_CREDENTIALS="/user/path/PROJECTS/personal/k8s/gcp-k8s-credentials.json"
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/user/path/google-cloud-sdk/path.zsh.inc' ]; then . '/user/path/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/user/path/google-cloud-sdk/completion.zsh.inc' ]; then . '/user/path/google-cloud-sdk/completion.zsh.inc'; fi
# iziwork key
export GITHUB_AUTH_TOKEN=xxx
EDIT
Bash Version : echo $BASH_VERSION gives a blank line.
Zsh Version : 5.7.1

prezto: old shell detected, minimum required: 4.3.17
Check your zsh version
zsh --version

In the end there were several issues, following the upgrade of brew some path did not get properly upgraded in the .zshrc file:
fpath in ~/.config/zulu was pointing to an older or incorrect version of zsh (particularly .../zsh/function)
path for zplug was incorrect
some gcloud command called before setting the path to gcloud
so
#this
/usr/local/Cellar/zsh/5.8/share/zsh/functions
#became
/usr/local/Cellar/zsh/5.8_1/share/zsh/functions
and
#this
export ZPLUG_HOME=/usr/local/Cellar/zplug/2.4.2/autoload/zplug
#became this
export ZPLUG_HOME=/usr/local/Cellar/zplug/2.4.2

Related

Terminal (zsh) command not found for global npm installs

This is driving me nuts! I did a lot of googling and tried various things. (I do not consider this to be a superuser topic)
I'm having a lot of troubles with terminal lately. I must have messed up somewhere, because it used to work just fine and now I can't get it to recognize my commands anymore neither nvm or global npm packages like expo. It just gives me errors like this:
▶ expo
zsh: command not found: expo
▶ nvm ls
zsh: command not found: nvm
(BTW: npm, brew and j commands are found 🤔)
If I do echo $PATH I get:
/Users/norfeldt/Library/Android/sdk/tools/bin:/Users/norfeldt/Library/Android/sdk/tools:/Users/norfeldt/Library/Android/sdk/platform-tools:/Applications/anaconda/bin:~/Library/Python/2.7/bin:~/.npm-global/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
(strange behavior is that if I do echo $PATH again it returns two times the same output in one line)
A readable version of it (replacing : with :\n
/Users/norfeldt/Library/Android/sdk/tools/bin:
/Users/norfeldt/Library/Android/sdk/tools:
/Users/norfeldt/Library/Android/sdk/platform-tools:
/Applications/anaconda/bin:
~/Library/Python/2.7/bin:
~/.npm-global/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin
My .zshrc file looks like this:
# Node & NPM
#PATH="/usr/local/bin:$PATH"
PATH="~/.npm-global/bin:$PATH"
#PATH="~/.npm-global/lib/node_modules:$PATH"
# Git
alias master="git checkout master"
alias dev="git checkout develop"
alias hotfix="git flow hotfix"
alias feature="git flow feature"
alias tags="git push --tags"
# Pip - https://gist.github.com/haircut/14705555d58432a5f01f9188006a04ed
PATH="~/Library/Python/2.7/bin:$PATH"
# added by Anaconda2 4.4.0 installer
PATH="/Applications/anaconda/bin:$PATH"
# Android
export ANDROID_HOME=/Users/norfeldt/Library/Android/sdk
PATH="${ANDROID_HOME}/platform-tools:$PATH"
PATH="${ANDROID_HOME}/tools:$PATH"
PATH="${ANDROID_HOME}/tools/bin:$PATH"
alias emu="pushd ${ANDROID_HOME}/tools;emulator -avd Pixel_2; popd"
# Path to your oh-my-zsh installation.
export ZSH=/Users/norfeldt/.oh-my-zsh
ZSH_THEME="avit"
# Autojump
[[ -s `brew --prefix`/etc/autojump.sh ]] && . `brew --prefix`/etc/autojump.sh
# shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# Load zsh-autosuggestions.
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# zsh-syntax-highlighting
source /Users/norfeldt/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
export PATH
ANY help would be HIGHLY appreciated!
UPDATE
Reading the kind answer from #l'L'l and this answer I did the following:
Updated my .bash_profile to
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
(it's the only thing in that file)
created a .bashrc by $touch .bashrc (Might have deleted the old one.. But this is just an empty file..)
Added the following lines to .zshrc
PATH="$PATH:$HOME/.npm-global/bin/" # Changed ~ to $HOME
PATH="$PATH:$HOME/.npm-global/lib/node_modules" # Changed ~ to $HOME
...
# Bash stuff
source ~/.bashrc
source ~/.bash_profile
Did a source ~/.zshrc and restarted my terminal.
NOW the nvm AND expo works! THANKS
There are a few things you might try, the first would be to source ~/.bash_profile from your .zshrc file. It's possible the nvm command was setup there and your zsh shell simply doesn't know it exists.
Note: On OS X, if you get nvm: command not found after running the
install script, one of the following might be the reason:-
your system may not have a .bash_profile file where the command is
set up. Simply create one with touch ~/.bash_profile and run the
install script again you might need to restart your terminal instance.
Try opening a new tab/window in your terminal and retry. If the above
doesn't fix the problem, open your .bash_profile and add
the following line of code:
source ~/.bashrc
For more information about this issue and possible workarounds, please
refer here
↑ Since you are using zsh instead at source ~/.bash_profile & ~/.bashrc in .zshrc.
If you used homebrew to install, then you might want to add the following into .zshrc:
export/source nvm installed with homebrew:
# source nvm
export NVM_DIR=~/.nvm
if hash brew 2>/dev/null; then
source $(brew --prefix nvm)/nvm.sh
source `brew --prefix`/etc/profile.d/z.sh
fi
npm not installed via homebrew:
export NVM_DIR="~/.nvm"
source ~/.nvm/nvm.sh
[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" # load nvm
[[ -s "$NVM_DIR/bash_completion" ]] && \. "$NVM_DIR/bash_completion" # load nvm bash_completion
↳ https://github.com/nvm-sh/nvm
I have no OSX to try... but the paths for zsh might belong into there:
/etc/paths, /private/etc/paths or into /private/etc/paths.d
Beside that, there's an auto-complete plugin for npm.

PATH error: "not a valid identifier"

I had to get a new hard drive on my Mac and in setting up my developer environment, I'm getting this error/message in the terminal (iTerm2):
-bash: unset: `PATH=/usr/local/opt/icu4c/bin:/usr/local/share/npm/bin:/Users/(mycomputername)/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/(mycomputername)/bin': not a valid identifier
From what I've been able to research myself so far, it might be related to installing node using brew. (I could be wrong.)
FYI:
which ruby
/usr/bin/ruby
which node
/usr/local/bin/node
which python
/usr/local/bin/python
Also, I'm using these instructions to set up. I'm aware a few things in this list are out of date:
https://github.com/nicolashery/mac-dev-setup
EDIT:
Contents of ~/.bash_profile:
# Add Homebrew /usr/local/bin and User ~/bin to the $PATH
PATH=/usr/local/bin:$PATH PATH=$HOME/bin:$PATH
export PATH
# Load the shell dotfiles, and then some: # * ~/.path can be used to extend $PATH.
# * ~/.extra can be used for other settings you don’t want to commit.
for file in ~/.{path,bash_prompt,exports,aliases,functions,extra};
do [ -r "$file" ] && source "$file"
done
unset fileexport PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
The issue is this line in your ~/.bash_profile:
unset fileexport PATH="/usr/local/opt/icu4c/bin:$PATH"
comment it out with # and restart iTerm2

Using 'cd' in terminal prints syntax error

I'm getting extra output on the command line when changing directories in terminal. The output is:
Casey-MacBook-Pro:~ casey$ cd Envs
-bash: command substitution: line 9: syntax error near unexpected token `done'
-bash: command substitution: line 9: ` done'
Caseys-MacBook-Pro:Envs casey$
Any idea on what is causing this? Could it be something in my bash profile? This is what my bash profile looks like when I run subl ~/.bash_profile:
# MacPorts Installer addition on 2013-03-02_at_20:37:40: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/activate.sh
# MacPorts Installer addition on 2015-09-24_at_12:31:24: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
export STORMPATH_API_KEY_ID=""
export STORMPATH_API_KEY_SECRET=""
export SENDGRID_API_KEY=""
export SECRET_KEY=""
export FLASK_CONFIG=""
export DEV_DATABASE_URL=""
export TEST_DATABASE_URL=""
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
Sounds like the problem is that virtualenvwrapper.sh is redefining cd into something broken.
Try commenting these out from ~/.bash_profile and opening a new Terminal window.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
source /usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/activate.sh

-bash: : command not found when launching the shell in Mac OSX

Lately I tried to made some changes to paths in my .bash_profile.
After I tried to validate these changes with source .bash_profile and got -bash: : command not found, I have also noticed that when I open the shell, before the execution of any command, it stands already "-bash: : command not found"...
Obviously, changes made to .bash_profile weren't taken into consideration by the system niether...
Please, help! I guess that I messed with the .bash_profile too much, have no idea how to fix it...
Contents of .bash_profile:
cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH=/Users/usrname/TreeTagger/cmd:$PATH
export PATH= /Users/usrname/TreeTagger/bin:$PATH
export UIMA_HOME= $/Users/usrname/apache-uima
export PATH=$PATH:$UIMA_HOME/bin
export HEIDELTIME_HOME='/Users/usrname/Downloads/heideltime-kit/'
export TREETAGGER_HOME='/Users/usrname/TreeTagger'
source $HEIDELTIME_HOME/metadata/setenv
Updated contents of .bash_profile:
cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH=$PATH:$UIMA_HOME/bin
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
source $HEIDELTIME_HOME/metadata/setenv
Full shell output after last quotes' correction:
Last login: Thu Jul 31 19:07:05 on ttys000
-bash: : command not found
usr:~ usrname$ cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH="$PATH:$UIMA_HOME/bin"
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
source $HEIDELTIME_HOME/metadata/setenv
usr:~ usrname$ source .bash_profile
-bash: : command not found
Edit with echo commands:
cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH="$PATH:$UIMA_HOME/bin"
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
echo before
source $HEIDELTIME_HOME/metadata/setenv
echo after
usr:~ usrname$ source .bash_profile
-bash: : command not found
usr:~ usrname$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
Edit +bash version:
echo $BASH_VERSION
3.2.51(1)-release
usr:~ usrname$ source ./.bash_profile
-bash: : command not found
Edit +after set -x was added to .bash_profile:
usr:~ usrname$ source ./.bash_profile
++ $'\016'
-bash: : command not found
++ update_terminal_cwd
++ local 'SEARCH= '
++ local REPLACE=%20
++ local PWD_URL=file://usr.local/Users/usrname
++ printf '\e]7;%s\a' file://usr.local/Users/usrname
This line:
export PATH= /Users/usrname/TreeTagger/bin:$PATH
is the problem. In a variable assignment, including an export, you can't have spaces around the =. With the added space, it sets $PATH to the empty string.
Change it to:
export PATH=/Users/usrname/TreeTagger/bin:$PATH
For safety, you should add double quotes:
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
just in case there are any special characters in the value of $PATH.
You have the same problem with UIMA_HOME.
UPDATE :
Based on later comments, you appear to have a stray control character in your .bash_profile. With set -x it's displayed as $'\016'. bash tries to treat that as a command name, and not surprisingly is unable to find it. Edit your .bash_profile and delete that character.
(The other errors needed to be corrected anyway.)

Error upgrading Ruby to 1.9.3 on OS X 10.7.5 using zsh - Command not found: rvm

I've been trying to follow this tutorial to upgrade Ruby but I'm getting "Command not found: rvm" in Terminal.
➜ ~ rvm
zsh: correct 'rvm' to 'rvim' [nyae]? n
zsh: command not found: rvm
I'm getting stuck after Step 2: Load RVM into the Shell. I've actually added
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
into the .zshrc file with some additional lines I've found in other answers to similar question. The file contents now:
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# For Ruby 1.9
__rvm_project_rvmrc
alias rvm-promt=$HOME/.rvm/bin/rvm-prompt # added 2013/09/13
source $ZSH/oh-my-zsh.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment to change how many often would you like to wait before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
I've download XCode 4.6.3 and installed the Command Line tools. How do I get this upgrade to work? Thanks.
Edit: I relaunched Terminal before trying the rvm command.

Resources