When I type echo $PATH, I can see /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/bin:/opt/X11/bin so it means /usr/local/bin is in my PATH and I have executable files in this directory. But when I type whereis filename, which is under /usr/local/bin, it does not show the path. However, when I type whereis filename, which is under /usr/bin, it shows the PATH /usr/bin/filename. I want to run my executable files located in /usr/local/bin without typing the whole PATH, how can I do this? Right now, only the files in /usr/bin can run without typing the whole PATH.
Related
Can ZSH be configured so that, just like Bash, it disregards subdirectories contained in the directories listed in $PATH?
According to Bart Schaefer seemingly the subfolders contained in the folders listed in $PATH are handled like executables in ZSH (whereas Bash disconsiders them).
For example, if $PATH contains the folder /usr/local/bin and there is a subfolder md5 in /usr/local/bin (but no such executable in a path of $PATH after it), then typing md5 and Enter gives the response zsh: permission denied: (instead of command not found in Bash) because md5 is not a command, but a directory.
This can bite you, for example, when a script checks on Linux whether the command md5 is available (as it is, by default on MacOS), and zsh wrongly returns true (the proper command would be md5sum). This is a frequent issue on WSL which converts and appends all paths in %PATH% to $PATH.
Similar questions have been asked in "zsh: permission denied: gam" and "Weird rails error "permission denied: bin/rails" for old rails apps", but the answers did not get to the heart of the matter.
So I'm trying to add TeX Live to my PATH and I couldn't be more confused.
(For the record, I'm using iTerm and oh-my-zsh on Mac OS X)
In my .zshrc file, my path looks like this:
# Path to MAMP PHP
export PATH=/Applications/MAMP/bin/php/php5.5.10/bin
# Path to LaTeX
export PATH=/usr/local/texlive/2014basic/bin/x86_64-darwin:$PATH
After adding the last two lines, my iTerm starts with errors looking like:
/Users/zach/.zshrc:17: command not found: killall
/usr/bin/env: zsh: No such file or directory
box_name:1: command not found: hostname
and more...
My /etc/paths file looks like
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/texlive/2014basic/bin/x86_64-darwin
However, after ALL of this, echo $PATH just returns:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Please help me...I am getting so frustrated. All I want to be able to do is run tlmgr.
You did not included full .zshrc so hard to figured out what is going on, but I guess that in first line you rather want
PATH=$PATH:/Applications/MAMP/bin/php/php5.5.10/bin
Otherwise you wouldn't be able to call any commands directly from e.g. /usr/bin, and messages like "command not found" only confirm my suspicion.
I am installing software on my MacBook Pro in preparation for a Rails tutorial. One of the steps involves creating a symbolic link to Sublime Text 2 so that it can be used in Bash. To do this, Sublime Text advises
The first task is to make a symlink to subl. Assuming you've placed Sublime Text 2 in the Applications folder, and that you have a ~/bin directory in your path, you can run:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
When I run this command, I get
ln: /Users/nngrey/bin/subl: No such file or directory
My path seems to include ~/bin:
echo $PATH
/Users/nngrey/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin:/Users/nngrey/.rvm/gems/ruby-2.0.0-p247#global/bin:/Users/nngrey/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/nngrey/.rvm/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Any suggestions?
Thanks
Your $PATH does not, in fact, contain ~/bin. If you look closely, /Users/nngrey/bin is not there. The original ln -s ... command probably failed because ~/bin doesn't exist. To make it, run mkdir ~/bin from Terminal. Then, rerun the ln command. Finally, run ~/bin/subl ~/.profile to open your ~/.profile file in Sublime, and add the following line to the bottom:
export PATH=$PATH:~/bin
Save the file, then restart your Terminal session and you should be able to type subl filename from the command line in any directory.
I'm using Homebrew on Mac OS X 10.8.3. Homebrew wants the /usr/local/bin directory earlier in the PATH than /usr/bin, otherwise system-provided programs will be used instead of Homebrew managed replacements.
I'm using zsh, and in my .zshenv I reset the PATH, and then use path_helper to initialize it, like so:
if [ -x /usr/libexec/path_helper ]; then
PATH=''
eval `/usr/libexec/path_helper -s`
fi
Immediately following this, also in .zshenv, I prepend /usr/local/bin to the PATH.
export PATH="/usr/local/bin:$PATH"
There are various other additions to $PATH. RVM, /usr/local/sbin and my personal bin directory:
export PATH=$HOME/.rvm/bin :$PATH
...
export PATH=$PATH:/usr/local/sbin:$HOME/bin
Finally, I use typeset -u to remove any duplicates (although where they are coming from is a mystery to me) from the PATH.
typeset -U PATH
After all of this here is what my PATH looks like:
/Users/mark/.rvm/gems/ruby-1.9.3-p374/bin
/Users/mark/.rvm/gems/ruby-1.9.3-p374#global/bin
/Users/mark/.rvm/rubies/ruby-1.9.3-p374/bin
/Users/mark/.rvm/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/sbin
/Users/mark/bin
I know that /etc/paths sets these paths:
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
so I edited that file and removed the /usr/local/bin' option so that the only place it is being set is in.zshenv`.
All of this is contained in my dotfile repository on GitHub (https://github.com/zan5hin/dotfiles), and is being used on two laptops. On the first laptop the path is correct, with /usr/local/bin immediately following the RVM entries. On the second laptop it appears as I detailed above.
I am at a loss to explain why the path is incorrect on the second machine when the zsh configuration is an identical copy.
Can anyone suggest why the path would be out of order?
Thanks.
zsh reads the files in the following order (from man 1 zsh)
$ZDOTDIR/.zshenv
/etc/zprofile (if login)
$ZDOTDIR/.zprofile (if login)
/etc/zshrc (if interactive)
$ZDOTDIR/.zshrc (if interactive)
/etc/zlogin (if login)
$ZDOTDIR/.zlogin (if login)
If ZDOTDIR is unset, HOME is used instead. Files listed above as being in /etc may be in another directory, depending on the installation.
Your changes were to (1) which is before (2); the macOS default for (2) is:
% cat /etc/zprofile
# System-wide profile for interactive zsh(1) login shells.
# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
# and zshoptions(1) for more details.
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
thus, your changes are being overridden by the macOS default. You will need to make your PATH changes later in the pipeline in order to preserve order.
This line is wrong:
export PATH=$HOME/.rvm/bin :$PATH
It should be:
export PATH=$HOME/.rvm/bin:$PATH
The space before :$PATH is causing you to lose the previous contents of $PATH.
I am getting the following warning while installing any plugin in my rails application.
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/agnostics.rb:7: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Can someone please tell me how to solve this problem?
Thanks
Ruby (on all Unixes, including Cygwin) warns if you try to run an external program and your $PATH contains a world-writable directory. It doesn't just check the directories on $PATH: it checks each of their parents, too, because if /usr/local (say) is world-writeable, /usr/local/bin is subverted as easily as if it were writeable itself.
A work-around could be to remove "other" write permission from the relevant directories.
For instance:
chmod o-w /usr/local/bin
chmod o-w /usr/local
chmod o-w /cygdrive/c
This is due to the fact that /usr/local/bin is writable by your application when maybe it shouldn't. You can fix this by changing the permissions on this directory.