Git update on Mac - bashrc - macos

I'm trying to upgrade my Git on my Mac.
I went through the uninstall and install process, however, I think I must have something wrong with my .bashrc.
When I do git --version, it says it is using the old, uninstalled version. When I do which git, it references: /usr/local/bin/git
However, my .bashrc has the following:
PATH="/usr/local/git/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:$PATH"
$PATH=/usr/local/rvm/bin:$PATH
$PATH=/Users/mm/.rvm/gems/ruby-2.1.1
$PATH=/Users/mm/.rvm/gems/ruby-2.0.0-p247/bin
$PATH=Users/mm/.rvm/gems/ruby-1.9.3-p448/bin
$PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
"$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
When I cd into the usr/local/git/bin and then check the version, the new version is there. Does anyone know what I need to do in my .bashrc to make it pick up the new version and then why the old version which is supposed to have been uninstalled, is still showing as the version?
My .bash_profile is:
$PATH=/usr/local/git/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:$PATH
$PATH=/usr/local/rvm/bin:$PATH
$PATH=/Users/mm/.rvm/gems/ruby-2.1.1
$PATH=/Users/mm/.rvm/gems/ruby-2.0.0-p247/bin
$PATH=/Users/mm/.rvm/gems/ruby-1.9.3-p448/bin
$PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
"$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/binexport PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export PATH=/usr/local/bin:/Users/mm/.rvm/gems/ruby-2.0.0-p247/bin:/Users/mm/.rvm/gems/ruby-2.0.0-p247#global/bin:/Users/mm/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/mm/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export PATH=/usr/local/bin:/Users/mm/.rvm/gems/ruby-2.0.0-p247/bin:/Users/mm/.rvm/gems/ruby-2.0.0-p247#global/bin:/Users/mm/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/mm/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
I'm afraid Spellcheck just tells me not to put the $ in front of PATH at the beginning of the lines in my .bashrc. I have removed the $ from the left of the opening PATH in each line and I still get the old version of git and a reference to the path: /usr/local/bin/git when I ask 'which_git' in my terminal.

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.

RVM: Warning! PATH is not properly set up

I am on a Ubuntu 14.04 LTS machine running rvm 1.27.0.
When I run rvm list I receive the following warning:
Warning! PATH is not properly set up, '/home/asarluhi/.rvm/gems/ruby-2.3.1/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.3.1'.
The output of echo $PATH is:
/home/asarluhi/bin:/home/asarluhi/.rvm/gems/ruby-2.3.1/bin:/home/asarluhi/.rvm/gems/ruby-2.3.1#global/bin:/home/asarluhi/.rvm/rubies/ruby-2.3.1/bin:/home/asarluhi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin:/usr/local/heroku/bin:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin
As you can see, in effect /home/asarluhi/bin comes first and also /home/asarluhi/.rvm/bin is repeated 7 times.
The last two lines of my ~/.bashrc file are:
### Added by the Heroku Toolbelt
export PATH="$PATH:/usr/local/heroku/bin"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
The last lines of my ~/.profile file are:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
The content of my ~/.bash_profile is:
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
To remove the exceeding /home/asarluhi/.rvm/bin i might probably try to remove the duplicate lines in ~/.profile. However I do not know how to solve the Warning! PATH is not properly set up issue. I tried to change the order of $PATH in ~/.profile for my private bin and for rvm as follows:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$PATH:$HOME/bin"
fi
export PATH="$HOME/.rvm/bin:$PATH" # Add RVM to PATH for scripting
I also changed the order of $PATH in ~/bashrc as I did for ~/.profile.
However I keep receiving the same warning.
As you can see, now there is /home/asarluhi/.rvm/bin at first place:
~ $ echo $PATH
/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/gems/ruby-2.3.1/bin:/home/asarluhi/.rvm/gems/ruby-2.3.1#global/bin:/home/asarluhi/.rvm/rubies/ruby-2.3.1/bin:/home/asarluhi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin:/home/asarluhi/.rvm/bin:/usr/local/heroku/bin:/home/asarluhi/bin
The only necessary edit to the config dotfiles is to prepend $PATH to $HOME/bin in ~/.profile as follows:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$PATH:$HOME/bin"
fi

Correct $PATHs on .bash_profile for npm packages (Sublime)

So I think I somehow messed up my $PATH settings and now only some of my Sublime Text packages are working. For example, I just added Minify (globally), and I can see it in the packages dropdown menu but the commands don't do anything.
From what I can make out so far, there are discrepancies between what is in
./npm-packages/
and
/usr/local/bin
My .bash_profile currently looks like this:
source ~/.profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -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}"
PATH="/usr/local/bin:$PATH”
PATH="~/.npm-packages/bin:$PATH”
export PATH
I'm not so good when it comes to system operations so if anyone has an idea of what I've done wrong, it would be hugely appreciated.

Need to Fix PATH in my bashrc File for RVM

I did a clean install of my operating system recently and copied my old .bashrc file from a backup. I installed rvm version 1.26.10 (latest stable version). I installed ruby 2.2.0. When I source the .bashrc file I get the following error:
Warning! PATH is not properly set up, '/Users/myusername/.rvm/gems/ruby-2.2.0#mygemset/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.2.0#mygemset'.
Here are my PATH statements. The first line I included here is one that was in the new install of RVM in the .bash_profile file. I copied them into .bashrc. I'm also running postgres.app which requires the last statement in order to set it as the current PostgreSQL instance.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
export PATH="$PATH:$HOME/.rvm/bin"
export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH
I started with the .bashrc file recommended by the Ruby on Rails Tutorial by Michael Hartl (the version current in 2011 or 2012) and the settings used by RVM back then. I know things have changed a bit since then.
My bash knowledge is limited so any help would be appreciated.
UPDATE: 2/2/2015 2:40 pm CST
I changed my bash statements to the following and got rid of the warning:
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
UPDATE: 2/2/2015 5:14 pm CST
Here are my Bash statements:
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql"
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Here is the output for echo $PATH:
/Users/username/.rvm/gems/ruby-2.2.0#gemsetname/bin:/Users/username/.rvm/gems/ruby-2.2.0#global/bin:/Users/username/.rvm/rubies/ruby-2.2.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/Users/username/.rvm/bin:/Users/username:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql:/Users/username/.rvm/bin
My RVM wouldn't stop complaining about PATH even though the last thing in my .bashrc was this line:
# RVM
source ~/.rvm/scripts/rvm
So I just redirected the complaining to /dev/null:
# RVM
source ~/.rvm/scripts/rvm > /dev/null 2>&1
rvm use default > /dev/null 2>&1
The last line also makes sure RVM is first in PATH, so it doesn't really have anything to complain about.
rvm expects its $PATH stuff to come first in $PATH. You should add items to the $PATH before sourcing rvm, not after.
After dealing with this for several days I decided to go ahead and continue to proceed with my implementation of postgres.app with the warning message I got with RVM. I ran my original bash statements in a different order.
export PATH="$PATH:$HOME/.rvm/bin"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH
I was successful in implementing postgres.app. I still get the warning message but my Ruby on Rails applications are able to find the correct gems and run successfully.
You should add the line like this
export PATH= '/Users/myusername/.rvm/gems/ruby-2.2.0#mygemset/bin:other"
Maybe that can help you

Can't change Ruby Version using RVM

I'm running Lion DP4 with Ruby 1.8.7 preinstalled. For my new project I need the latest Ruby version though. Therefore installed rvm and the latest Ruby. Somehow when I try to use the new version it doesn't give me any errors, but the change just doesn't take effect.
~martin$ rvm use ruby 1.9.2 --default
Using /Users/martin/.rvm/gems/ruby-1.9.2-p180
~martin$ which ruby
/usr/bin/ruby
My .bash_profile file looks like this:
export PATH="/opt/local/bin"
export PATH="/opt/local/sbin"
export PATH="/usr/texbin:${PATH}"
export PATH=$PATH:/Users/martin/bin
export PATH=$PATH:/usr/local/mysql/bin
source ~/.git-completion.bash
alias mysql '/usr/local/mysql/bin/mysql'
alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
Can anyone tell me why me wanting to change the Ruby version is not working? Appreciate any help.
Thanks in advance!
Martin
EDIT (2011/06/28 - 1:08PM):
Ok, for some really odd reason everything works now.
I guess my .bash_profile file somehow was messed up. In the beginning I thought that I installed it as root therefore changed the rvm path to
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" # Load RVM function
But I guess my path declaration in general was totally messed up. Now my .bash_profile file looks like this:
export PATH=$PATH:/opt/local/bin
export PATH=$PATH:/opt/local/sbin
export PATH=$PATH:/usr/texbin
export PATH=$PATH:/Users/martin/bin
export PATH=$PATH:/usr/local/mysql/bin
source ~/.git-completion.bash
alias mysql '/usr/local/mysql/bin/mysql'
alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" # Load RVM function
#Mark
Yes, I installed Ruby using MacPorts and hope that now I've fixed the path.
I had the same problem, this is not a real solution but a hack:
sudo mv /usr/bin/ruby /usr/bin/_ruby
Note that this is not ideal since it might break scripts that start with:
#!/usr/bin/ruby
blablabla
Looking forward for a better answer in the meantime :)

Resources