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.
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
I'm on Ubuntu 14.04 and I've been trying all possible methods to install Laravel to no avail. Error messages everything I try. I'm now trying the first method in the quickstart documentation, that is, via Laravel Installer, but it says to "Make sure to place the ~/.composer/vendor/bin directory in your PATH so the Laravel executable is found when you run the Laravel command in your terminal." so my question is, how do I do that? This may be a simple question but I'm really frustrated and would appreciate any help.
To put this folder on the PATH environment variable type
export PATH="$PATH:$HOME/.composer/vendor/bin"
This appends the folder to your existing PATH, however, it is only active for your current terminal session.
If you want it to be automatically set, it depends on the shell you are using. For bash, you can append this line to $HOME/.bashrc using your favorite editor or type the following on the shell
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
In order to check if it worked, logout and login again or execute
source ~/.bashrc
on the shell.
PS: For other systems where there is no ~/.bashrc, you can also put this into ~/.bash_profile
PSS: For more recent laravel you need to put $HOME/.config/composer/vendor/bin on the PATH.
PSSS: If you want to put this folder on the path also for other shells or on the GUI, you should append the said export command to ~/.profile (cf. https://help.ubuntu.com/community/EnvironmentVariables).
Detailed instructions:
in your ~/.bashrc add these lines:
export PATH="$PATH:~/.composer/vendor/bin"
Then reload:
source ~/.bashrc
Check if its added correctly:
echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/web/bin:~/.composer/vendor/bin
In Ubuntu 16.04 LTS with composer globally installed, this worked for me.
Edit the .bashrc file in your home directory puting the path to the composer bin folder that is located in /your/home/.config/composer/vendor/bin
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrc
If not works, verify the path to the composer bin directory and close and reopen the terminal. Otherwise, try to logoff and login in the Ubuntu.
Also works in ubuntu 18.04. Thanks #chifliiiii for your feedback.
For setting the PATH on Yosemite (OS X 10.10.5), use the command below:
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
To reload either quit terminal and start up again or use:
source ~/.bash_profile
Helped me, hope it helps someone else out there!
I did all of the above and it didn't work for me.
I just copied this into my terminal and it worked for me.
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
my path didn't have /.composer, just /composer so my path was:-
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
This worked for me on ubuntu 20.04
This is for setting PATH on Mac OS X Version 10.9.5.
I have tried to add $HOME because I use user profile :
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
When you do not use user profile:
echo 'export PATH="$PATH:~/.composer/vendor/bin"' >> ~/.bashrc
Then reload:
source ~/.bashrc
I hope this help you.
Open the Mac Terminal:
vi ~/.bashrc
If you haven't used vi, it may look a little funny at first, so enter the following code carefully, in order:
i
export PATH="$PATH:$HOME/.composer/vendor/bin"
PRESS ESC
:
w
PRESS ENTER
:
q
PRESS ENTER
Now you should have returned to the normal terminal view.
Check that composer now has the correct path:
cd ~/.composer
echo $PATH
If you see the path including your file directory, (e.g. /Users/JeffStrongman/.composer/vendor/bin), you're good to go.
cd
Then run your installation. I ran into this problem, while configuring my Mac to use Laravel Valet.
Example (optional)
valet install
For Linux Mint 18: edit ~/.bashrc and add this line to it at the bottom:
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
then resource .bashrc (type in console):
source ~/.bashrc (or close and reopen the terminal)
test it by typing in the console:
echo $PATH
or type in console:
laravel
In case someone uses ZSH, all steps are the same, except a few things:
Locate file .zshrc
Add the following line at the bottom export PATH=~/.composer/vendor/bin:$PATH
source ~/.zshrc
Then try valet, if asks for password, then everything is ok.
add environment variable into bashrc file
For Ubuntu 17.04 and 17.10:
echo 'export PATH="~/.config/composer/vendor/bin"' >> ~/.bashrc
For Ubuntu 18.04
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
to Check environment variable working or not first reload the bashrc file
source ~/.bashrc
if not working any method then First Check Where is install Composer to Check Run This Command :
locate composer -l 1
then Copy Output add output into this line and run again command.
echo 'export PATH="OUTPUTHERE/vendor/bin"' >> ~/.bashrc
After Successfully Laravel Command Work Give a Permission To Parent Folder (for example u are using apache server than give permission to apache web listing directory like that)
sudo chown $USER:$USER -R /var/www/html/
For me in Ubuntu 22.04, this works:
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
Adding export PATH="$PATH:~/.composer/vendor/bin" to ~/.bashrc works in your case because you only need it when you run the terminal.
For the sake of completeness, appending it to PATH in /etc/environment (sudo gedit /etc/environment and adding ~/.composer/vendor/bin in PATH) will also work even if it is called by other programs because it is system-wide environment variable.
https://help.ubuntu.com/community/EnvironmentVariables
MacOS Sierra User:
make sure you delete MAAP and MAAP Pro from Application folder if you have it installed on your computer
be in root directory cd ~
check homebrew (if you have homebrew installed) OR have PHP up to date
brew install php70
export PATH="$PATH:$HOME/.composer/vendor/bin"
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
source ~/.bash_profile
cat .bash_profile
make sure this is showing :
export PATH="$PATH:$HOME/.composer/vendor/bin"
laravel
now it should be global
The Composer bin directory is set and stored in bin-dir config variable and can be different depending on your setup. Running the command composer global config bin-dir --absolute will tell you the absolute path to your global composer bin directory. Using this command you can modify your .bash_profile to add it to your PATH exactly how it is configured.
# Add Composer bin-dir to PATH if it is installed.
command -v composer >/dev/null 2>&1 && {
COMPOSER_BIN_DIR=$(composer global config bin-dir --absolute 2> /dev/null)
PATH="$PATH:$COMPOSER_BIN_DIR";
}
export PATH
AWS Ubuntu 18.04 LTS
Linux ws1 4.15.0-1023-aws #23-Ubuntu SMP Mon Sep 24 16:31:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc && source ~/.bashrc
Worked for me.
On Fedora:
Some composer bins are not in the .composer directory
So you need to locate them using:
locate composer | grep vendor/bin
Then echo the the part into the .bashrc
echo 'export PATH="$PATH:$HOME/{you_composer_vendor_path}"' >> ~/.bashrc
Mine was "/.config/composer/vendor/bin"
Cheers!
For Ubuntu 16.04
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrc
I did this and it works on osx:
lunch your terminal
nano ~/.bash_profile
And paste
export PATH=~/.composer/vendor/bin:$PATH
press control + x
press the y key
press the return / enter key
this is what I added in my .bashrc file and worked.
export PATH="$PATH:/home/myUsername/.composer/vendor/bin"
To solve this problem make sure you find the path of composer.phar first
example mine is something like this
alias composer="php /Users/Your-username/composer.phar"
Go to cd Users > Your user > Command ls and see if composer.phar is there if yes then add the above line to your .bash_profile. Make sure you change the username to your own.
Hope this help you out
I've tried a lot of solutions, but on Ubuntu 20.04 only this worked for me:
export PATH="$HOME/.composer/vendor/bin:$PATH"
Goal: install Ruby 2.0.0
Brew Doctor says:
Warning: "config" scripts exist outside your system or Homebrew directories. `./configure`
scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/sm/pkg/active/bin/curl-config
/opt/sm/pkg/active/bin/ncurses5-config
/opt/sm/pkg/active/bin/ncursesw5-config
/opt/sm/pkg/active/bin/pkg-config
/opt/sm/pkg/active/bin/xml2-config
/opt/sm/pkg/active/bin/xslt-config
I found the answer here: Brew doctor gives out warnings but don't know how because he didn't tell us how to do it
I need to remove /opt/sm/pkg/active/bin/ from my path.
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
but when I open my file
touch ~/.bash_profile; open ~/.bash_profile
I get:
export PATH=${PATH}:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
##
# Your previous /Users/john/.bash_profile file was backed up as /Users/john/.bash_profile.macports-saved_2013-06-06_at_14:30:25
##
# MacPorts Installer addition on 2013-06-06_at_14:30:25: 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.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Notice the path I'm trying to remove is not in the file, but it's in my path. What do I do??
The /opt/sm is in the /etc/profile.d directory. Open it by entering
cd /etc/profile.d
in terminal and then
open .
Open sm.sh file in text editor and then
change
PATH="${PATH}:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin"
to
#PATH="${PATH}:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin"
and then quit and relaunch Terminal. Run brew doctor 'Warning' should be gone.
It seems that "sm" comes from RailsInstaller, at least in my case. Following the approach in this post, I commented out the line in /etc/profile.d/sm.sh and restarted Terminal. This solved the above brew doctor errors.
I installed the latest RVM - Ruby Version Manager - and installed Ruby 1.8.7 and 1.9.3 on OSX Lion with XCode 4.3.3 using clang rvm install 1.9.3 --reconfigure --debug -C --enable-pthread --with-gcc=clang as the regular way did not work due to a GCC error. I did get one error clang: error: unsupported option '--with-libyaml, but Ruby 1.9.3 worked and I could run WPScan that needs at least 1.9.2 .
But now every time I run a command to change folder such as cd I get a long Bash script printed related to RVM - see http://pastebin.com/UAm38Vcm and:
.
How can I stop it from doing that?
Update I
Added a comment at RVM at Github as well https://github.com/wayneeseguin/rvm/issues/1039 , but as that issue is not 100% related and as I need this solved as soon as possible I opened a thread here with more data.
Update II
I realized the RVM Initialization script is the one that is being printed: https://github.com/wayneeseguin/rvm/blob/master/scripts/initialize . No idea why though..
Update IV
My .bashrc
# define aliases
alias sudo='sudo '
#alias ruby='ruby1.9'
alias apacherestart='sudo apachectl -k restart'
# define hist properties
HISTFILESIZE=1000000000
HISTSIZE=1000000
# define path to programs
PATH=/opt/local/bin:opt/local/sbin:/opt/subversion/bin:/opt/local/apache2/bin/:/opt/local/lib/python2.4/site-packages/django/bin:$PATH
# define manpath
MANPATH=/opt/local/share/man:$MANPATH
# export env vars
export HISTFILESIZE HISTSIZE PATH MANPATH
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
My .bash_profile
source ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Your cd command has somehow become aliased or a function has been created named "cd".
You can undo those with either:
unalias cd
or
unset -f cd
You should be able to revert temporarily with
unalias cd
It appears that you will need to figure out what was changed in your .bashrc and revert all those changes. If the installation script is at all sanely written, it should have made backups, or document somehow what was changed.