Give permissions for packages in /opt/homebrew/Cellar - homebrew

I'm using an Apple Silicon, thus having 2 different Homebrews running on my machine.
Here's an excerpt of my .zshrc:
#export PATH=$HOME/bin:/usr/local/bin:$PATH
if [ $(arch) = "i386" ]; then
alias python3="/usr/local/bin/python3"
alias brew86='/usr/local/bin/brew'
alias pyenv86="arch -x86_64 pyenv"
alias func="/usr/local/Cellar/azure-functions-core-tools#4/4.0.4915/func"
alias direnv="/usr/local/Cellar/direnv/2.32.2/bin/direnv"
export PATH="/usr/local/Cellar:$PATH"
fi
alias brew="/opt/homebrew/bin/brew"
export PATH="/opt/homebrew/Cellar:$PATH"
eval "$(direnv hook zsh)"
The issue is that when running a command that was installed with brew, I run into zsh: permission: denied errors.
That being said, I have noticed that the above PATH export was commented, and when uncommented it solved my problem.
Is what you're seeing the right way to configure when running 2 Homebrew installations?
Sorry if the question sounds trivial.
TIA!

Related

Adding homebrew to $PATH without sudo privileges

I've been trying to install homebrew without admin privileges on my school MacBook (Mojave 10.14.6) for the past 2 weeks. I've seen many things on the internet, saw some scripts, tutorials, but nothing seems to help.
I used this script (did some tweaking to it like changing to a new repository and setting absolute path)
https://gist.github.com/skyl/36563a5be809e54dc139
the repository I used is
https://github.com/Homebrew/brew
my path to brew is
/Users/as.gurban-zade/Desktop/homebrew/usr/local/bin/brew
I added this to the $PATH using
echo "export PATH=/Users/as.gurban-zade/Desktop/homebrew/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
also tried
echo "export PATH=/Users/as.gurban-zade/Desktop/homebrew/usr/local/:$PATH" >> ~/.bash_profile && source ~/.bash_profile
After everything I did, I still get
-bash: brew: command not found
Updating OS to Catalina is possible if that would help

nix-env and nix-build not found after installation (debian buster)

after the installation following the instructions with
curl https://nixos.org/nix/install | sh
and logout/login, nix-env and nix-build are not found.
I had the problem with debian stretch and now with buster. What am I doing wrong?
The nix manual instructs to execute
source ~/.nix-profile/etc/profile.d/nix.sh
but the instructions printed after the execution say to do (I do not remember exactly)
./~/.nix-profile/etc/profile.d/nix.sh
and the same command is inserted into ~/.profile. The cause of the problem is the difference between . and source (see this superuser question). The script is setting up the $PATH variable in the environment and has the desired effect wtih source but no effect with . (which operates in its own shell and closes it at the end).
Cure:
change the line in .profile (or better move it to .bashrc) to
if [ -e /home/xxx/.nix-profile/etc/profile.d/nix.sh ]; then source /home/xxx/.nix-profile/etc/profile.d/nix.sh; fi
(xxx is your user name),
You need to add this recommended script.
For me only setting $PATH like this worked (in .profile)
export PATH="$PATH:/nix/var/nix/profiles/default/bin"

How to uninstall Nix

I've installed Nix into an Ubuntu WSL installation.
I now want to uninstall it.
The manual states to simply "rm -rf /nix".
Nix adds itself to $PATH and the manual makes mention of a Nix daemon.
Surely there are other parts of my system that Nix has added itself to.
For one, I can see an entry in ~/.profile which is sourcing ~/.nix-profile/etc/profile.d/nix.sh
Is there anything else that needs to be done?
NOTE: This answer is about uninstalling Nix from a Linux or Linux-like system in 2018. Since then, Nix has started to support systemd unit installations and since Catalina, macOS installations have become more complex too. This answer is not official documentation.
The "curl | sh" installer for Nix on Linux does not install the Nix daemon, so the only things to delete are /nix, the line in ~/.profile and ~/.nix-profile.

'Zsh: command not found: valet' - unable to install Valet

I just tried installing valet for a very long time, - and I couldn't find any help anywhere. No matter what I tried, then it kept saying:
Zsh: command not found: valet
I'm running Zshell (instead of Bash) and OSX. I've had Brew installed for quite a while.
I'll answer this myself, - so hopefully people in the same situation can find this in the future.
I had a very similar problem under Zsh, but my solution was easier. Rather than adding ~/.composer/vendor/bin to my $PATH, I needed to use the full directory name; i.e., /Users/[your-user-name]/.composer/vendor/bin.
Everywhere it says to 'Check that your path is right'. And yup - if you haven't done that, then you should start there. The easiest way is to go to your terminal and write:
echo $PATH
... And then you should see ~/.composer/vendor/bin in between two colons in there. If that isn't there, then you should go to your ~/.bashrc-file (or ~/.zshrc-file) and add this line:
export $PATH=~/.composer/vendor/bin:$PATH
And then it may be fixed.
My problem had deeper roots, though. Even though my path was right, then I still got the error:
Zsh: command not found: valet
And if I wrote: which valet - then it (obviously) just responded with valet not found.
Removal of Composer
What fixed it was to remove all my composer-installations. Composer can be located in several different locations (and installed by brew). So in order to remove it, then do this (inspired by this post, but it lacks a couple of steps):
Remove your composer- or -composer.phar-file. You can find them by running which composer and/or which composer.phar.
Remove your .composer-folder (usually located here: ~/.composer).
Then make sure that there isn't an installation done with Homebrew (this was what I think made the collision for me). You do it by running brew unlink composer followed by brew remove composer.
Then, - if you want to be 100% sure that it's all gone, then go to your root (cd /) and run this command: find ./* -name 'composer.phar' and this find ./* -name 'composer'. That should tell you of all the locations where the Composer-installation can be installed.
When all that's removed, then you should be rid of Composer (entirely).
... Then install it again, - and see if you can get valet to work (it did for me).
The solution was adding composer bin to the path. You can use the following commands
From the terminal
export PATH="$PATH:$HOME/.composer/vendor/bin"
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
source ~/.bash_profile
valet install
Issue Ubuntu: no command valet
Valet on Ubuntu:
sudo apt install libnss3-tools jq xsel
composer global require cpriego/valet-linux
.composer/vendor/cpriego/valet-linux/valet install
Now command valet should work, but if still not:
sudo cp .composer/vendor/cpriego/valet-linux/valet /usr/local/bin/

RVM not found, after installing RVM

I've found a couple similar posts regarding this same problem, but none of the solutions seem to apply, here.
On a fresh Ubuntu 10.10 install, I follow the instructions for installing RVM:
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Then I create .bash_profile and add the following line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
I restart the terminal and check RVM:
$ type rvm | head -1
-bash: type: rvm: not found
As the RVM installation guide explains to do so, I replaced the first line (below) in .bashrc with the second one, then indented everything in the rest of the file and added a fi.
[ -z "$PS1" ] && return # original
if [[ -n "$PS1" ]]; then # replaced with this
Restarted terminal and still, no luck.
Then, I removed the line I added to .bash_profile in the beginning and added it to .bashrc, even though that isn't what the guide said to do. Still, no luck. I also entered it directly on the command line, with no change in behavior. When I run .rvm from ~/.rvm/bin/rvm it complains that there is no such file or directory as /.rvm/scripts/rvm and that the command was not fund.
Of course, there isn't any such "scripts" directory inside of ./rvm, either -- so I'm not sure why it's looking for one? The only directories inside of .rvm are
archives
bin
config
gems
gemsets
log
man
rubies
src
tmp
user
The only thing I've found while googling for answers are other people complaining of similar problems and people telling them to add the instructed line to .bash_profile (which I obviously already did). At this point, I have nothing more to go on and am at an impasse.
Regards.
Resolution:
As Andrew Marshall advised in his comments, below, I did an 'rm -rf .rvm' and reinstalled rvm. I had actually attempted this two times before posting here, with the same results every time. No odd messages in the install log, but no /scripts/ directory, either. Just so I could say I had, I did it a third time at Andrew's urging. This time, I checked and the /scripts/ directory existed. Running 'type rvm | head -1' confirmed it as a 'function' and I can now move on.
Make sure that you restart a session after reinstalling, so that rvm is in your path.
You can try to logout/login.
You can also open your shell as a login shell. Under ubuntu 12.04:
Open a terminal
Edit > Profile Preferences
Under tab Title and Command, check run Command as a login shell
Open new terminal (ctrl+alt+t) and type rvm
If there's no scripts directory inside .rvm, it would seem that RVM failed to successfully complete installation. Delete the .rvm directory, try reinstalling, and look at the installation output closely to see if it's complaining about anything.

Resources