Completely confused with my $PATH, iTerm, and ZSH setup - path

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.

Related

PIPX Install on MAC - Duplicate user/xxx/.local/bin in PATH

I have recently installed PIPX on MAC running Big Sur and ZSH shell. During the install it prompted for the following to be added to the .zshrc file....
# Created by `pipx` on 2021-03-20 14:22:23
export PATH="$PATH:/Users/xxxx/.local/bin"
eval "$(register-python-argcomplete pipx)"
Running echo $PATH showed /Users/xxxx/.local/bin added to the end of my PATH variable. However, when I close the terminal and open up a new session, running echo $PATH now shows the location duplicated at the end of the PATH :/Users/xxxx/.local/bin:/Users/xxxx/.local/bin
Opening and closing new terminal sessions doesn't seem to create any more additions to PATH it just remains at these 2 entries....
I have run typeset -U PATH path to remove the duplicate but each time I open up new terminal sessions it just duplicates again.
Does anybody know how I can stop this from happening.....I would really like to keep my PATH variable as clean as possible.
Add the following path to your .zshrc file :
export PATH="${PATH}:$(python3 -c 'import site; print(site.USER_BASE)')/bin"
Reference: [command not found: pipx]: https://github.com/pipxproject/pipx/issues/283

Atom linter-erb failing with "Error: /usr/bin/env: ruby: No such file or directory"

I have the linter set to check on save and it throws this error every time I save a .erb file. In the settings for the package I have both the following settings specified:
Erb Executable Path
/home/jason/.rvm/rubies/ruby-2.3.0/bin/erb
Ruby Executable Path
/home/jason/.rvm/rubies/ruby-2.3.0/bin/ruby
I was having a similar issue with the linter-ruby package, but setting the ruby executable path seemed to fix it. Here's what my path looks like:
$ echo $PATH
/home/jason/.nvm/versions/node/v5.10.0/bin:/home/jason/.rvm/gems/ruby-2.3.0/bin:/home/jason/.rvm/gems/ruby-2.3.0#global/bin:/home/jason/.rvm/rubies/ruby-2.3.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/jason/.rvm/bin:/home/jason/.rvm/bin
Here's the full output of the error.
Error: /usr/bin/env: ruby: No such file or directory
at parameters.exit (/home/jason/.atom/packages/linter-erb/node_modules/atom-linter/lib/helpers.js:47:27)
at triggerExitCallback (/opt/atom/resources/app.asar/src/buffered-process.js:213:47)
at /opt/atom/resources/app.asar/src/buffered-process.js:220:18
at Socket.<anonymous> (/opt/atom/resources/app.asar/src/buffered-process.js:98:18)
at emitOne (events.js:82:20)
at Socket.emit (events.js:169:7)
at Pipe._onclose (net.js:469:12)
It seems even though I've specified where it should be looking for ruby, it's still looking in /usr/bin/env.
Here's a bit more output that's hopefully helpful:
$ which erb
/home/jason/.rvm/rubies/ruby-2.3.0/bin/erb
$ which ruby
/home/jason/.rvm/rubies/ruby-2.3.0/bin/ruby
I'm not sure this would have any effect, but for the sake of trying to cover all my bases, I also have this in ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
Ubuntu: 15.10
kernel: 4.2.0-34
Atom: 1.6.0
linter-erb: 1.0.2
I've restarted Atom several times but the error keeps popping up. Any help would be much appreciated.
EDIT
I found that if I start Atom from the terminal, I don't have this problem, but when I launch it from the icon in the launcher, the issue crops up again.
Try pointing the linter to RVM wrappers instead of direct binaries in RVM which work OK only in interactive shells. RVM wrappers make the binaries run correctly even in other environments and shells.
Simply choose a wrapper directory under $HOME/.rvm/wrappers/ for your desired version of ruby and gemset and use the binaries from there.
See this answer for more explanation.

Setting zsh PATH not producing desired order

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.

Using the Command-line Command to launch Sublime Text 2 on OS X

I just started reading Michael Hartl's book on Rails and I've run across a problem in the setup phase. Hartl keeps referring to making a file in my home directory, but I'm not quite sure how to do this. For example, when I try to setup the command line for sublime text the instructions tell me to do this: 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
My problem is that I don't know how to put a ~/bin directory in my path. I know this is real basic but any help would be greatly appreciation.
create or edit ~/.profile (works with both bash and zsh)
add the following
export PATH=$PATH:$HOME/bin
The line above is saying, overwrite the PATH environment variable and set it to the previous path plus ~/bin
Now when you try to run a command, bash will look in all the colon separated paths in your PATH environment variable for an executable.
To see your entire PATH, type echo $PATH in a terminal. Or better yet, type env to see all environment variables.
On your terminal
$ mkdir ~/bin
$ sudo ln -s "/Applications/Sublime Text2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
Edit ~/.base_profile
export PATH=$PATH:~/bin
usage:
open current directory:
subl .
In your ~/.bashrc file add to the end:
PATH="$HOME/bin:$PATH"

Trying to set up bash command

I was trying to set up a bash command in Terminal on a Mac.
The scripts run correctly when I execute them directly.
I set up symlinks in /usr/local/bin/ to the current location of the scripts. When I try to run it off the symlink, it doesn't work. I don't believe the issue is the $PATH, because pip, git, ipython all exist in this location. When I edit the $PATH setting, these fail.
Suggestions?
ls -l /usr/local/bin/foo and see where your symlink is actually pointing. Betcha it's broken.
If not, try running /usr/local/bin/foo. If that works, it was your PATH that's wrong, despite what you said in the OP.
The only other thing that would cause this behavior is if the script is reading $0 (its own name as executed). With a symlink, that will have a different value.
I found my own answer... The symlinks were created by an automated file which was gabbing my pwd. I was also using virtualenv, so to get it to work, I had to activate the virtualenv and be inside the folder that had the script that created the symlinks.
I install my commands in $HOME/bin instead of /usr/local/bin, but it does not matter much. As hinted in the comments, one question is whether the symlinks are set correctly.
Check which command the shell thinks you should execute: which command
Check that the link in /usr/local/bin points to the correct file (and has execute permission, etc):
ls -l /usr/local/bin/command
ls -lL /usr/local/bin/command
Check that the interpreter path in the shebang is correct:
file /usr/local/bin/command
Check that /usr/local/bin is actually on your PATH: echo $PATH
If none of that shows up a problem, show us the results of the commands above.

Resources