How do you update your "HOMEBREW_TEMP" environmental variable? - homebrew

I'm getting the following error when running "brew doctor":
Error: Your Cellar and TEMP directories are on different volumes.
OS X won't move relative symlinks across volumes unless the target file already
exists. Brews known to be affected by this are Git and Narwhal.
You should set the "HOMEBREW_TEMP" environmental variable to a suitable
directory on the same volume as your Cellar
How do I set this variable? And what should I set it to? I can't seem to find anything about this when googling.

You set your HOMEBREW_TEMP by editing your ~/.bash_profile and doing this:
export HOMEBREW_TEMP=/new/path
Then start a new shell.
Alternatively type that into any already open shell.
Google setting shell environment variables for further information.

I fixed this problem by setting the path of the temp folder manualy.
First i created a folder temp in /usr/local/ and then added the following to my zsh file nano ~/.zshrc
export HOMEBREW_TEMP=/usr/local/temp

Same problem occurred to me. I actually have configured separate disk in memory for /private/tmp. Hope that's why this error occurred.
To solve this issue, create a directory somewhere, like /usr/local/brew_temp
Then add following line to file ~/.profile. If file doesn't exist create that file
export HOMEBREW_TEMP=/usr/local/brew_temp
In each restart it will set the HOMEBREW_TEMP environment variable to that path. After setting these option either you can restart OS X or run following in command line if you don't want to restart
. ~/.profile

For anyone that runs into this in the future, try restarting your computer and then running brew doctor again. That fixed it for me.

Related

Adding path variable in wsl

I have added a path in bashrc, still, the command is not found. When tried in ubuntu it worked but not in WSL. Why this happen?.
export PATH=\wsl$\Ubuntu\usr\local\mbdyn\bin:$PATH
added same path in .bashrc
error: command not found
**Please see the attached image
As you have been told, the forward slash to use is / and if you use the command
PATH="$PATH:/folder/subfolder/"
that value will only last in the PATH for the duration of the session.
To include a value in the PATH permanently, edit the .bashrc file from your home
$ sudo vim ~/.bashrc
you add at the end
export PATH="$PATH:/folder/subfolder/"
you save and you will have that value in the PATH in each session
You will need to modify the PATH variable as follows:
PATH="$PATH:/usr/local/mbdyn/bin"

How to find the source of $PATH?

I'm using a Centos 7 server. I'm entering the command echo $PATH and trying to figure out where it's getting the path that it's putting out. The path doesn't match what's in my .bash_profile, and there is no .bashrc file. How do I find out where my current $PATH is being sourced from?
The Default values for .bashrc and $PATH are stored in files /etc/bashrc and /etc/profile. These files are used by shell and kernel for setting default values for proper functioning of the server.
I would advise not to change any values here, as it might cause abnormal behavior in the server.

PATH variable in .zshenv or .zshrc

My setup is zsh 5.0.5 in arch linux
I have set the PATH variable as below in .zshenv
typeset -U path
path=(~/bin $path)
DW=$HOME/Downloads
but it didn't work. print $PATH shows only
/usr/local/bin:/usr/bin:/usr/bin/vendor_perl:/usr/bin/core_perl
.zshenv was read, because I could see DW variable is set. Only PATH variable isn't set. And what I don't understand is, after rename the .zshenv to .zshrc, PATH variable just works as intended.
Need any special treatment setting environment variables in .zshenv?
I just encountered this problem myself, and the real answer is that Zsh on Arch sources /etc/profile – which overwrites and exports PATH – after having sourced ~/.zshenv.
See: https://wiki.archlinux.org/index.php/Zsh#Configuration_files
It seems that when you have macos or some linux distros there is a canonical solution to the problem which involves /etc/paths or /etc/paths.d. You should be letting /usr/libexec/path_helper construct your path for you using configuration files.
This immediately solved the problem in all places for me.
I've got the same problem. The cause was my .zshrc (fresh install of oh-my-zsh) override PATH (ignoring existing value):
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl"
To fix, I comment the line.

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.

How to permanently change sudo's $PATH variable (Ubuntu 9.x)

I want add some directory to the $PATH when running sudo, this is a (semi) permanent requirement, not something that needs to be added to the scripts themselves. I notice that Django has managed to do it, (my $PATH when running sudo is "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/django/django-trunk/django/bin") - so how did it do that?
This is the line in the sudoers file that resets:
Defaults env_reset
You can work around this by adding PATH to env_keeps or by adding this line:
Defaults env_keep = "PATH"
EDIT: meder, you do not disable env_reset, you simply bypass the path reset
Or you can remove the offending env_reset line.
Even better though, you can declare a secure_path that will replace PATH when sudo is run:
Defaults secure_path="/bin:/usr/bin"
That way you can control what specific directories to include in the path.
I think this should work out if you save it in /root/.bashrc:
export PATH=/www/foo:$PATH
I forget if it's PATH or PYTHONPATH and if it actually matters, this is based on my user's .bashrc:
export PYTHONPATH=/www/django:$PYTHONPATH
You can set the variable in /etc/environment, and then use "sudo -i" to run the script (works in ubuntu 10.10).

Resources