I'm trying to install node.js via Homebrew. Unfortunately, I get this error:
➜ ~ brew install node
==> Downloading http://nodejs.org/dist/v0.8.10/node-v0.8.10.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.8.10
==> make install
==> Caveats
Homebrew installed npm.
We recommend prepending the following path to your PATH environment
variable to have npm-installed binaries picked up:
/usr/local/share/npm/bin
Warning: Could not link node. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link node'
==> Summary
/usr/local/Cellar/node/0.8.10: 856 files, 13M, built in 103 seconds
So then I try to link node manually...
➜ ~ brew link node
Linking /usr/local/Cellar/node/0.8.10... Warning: Could not link node. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/node/0.8.10/lib/node_modules/npm/scripts/relocate.sh
Target /usr/local/lib/node_modules/npm/scripts/relocate.sh already exists. You may need to delete it.
To force the link and delete this file, do:
brew link -f formula_name
To list all files that would be deleted:
brew link -n formula_name
No luck, so I try forcefully linking node...
➜ ~ brew link -f node
Linking /usr/local/Cellar/node/0.8.10... Warning: Could not link node. Unlinking...
Error: Permission denied - /usr/local/lib/dtrace/node.d
I'm not familiar with dtrace in any regard and I'm afraid to mess with permissions, so I tried to sudo..
➜ ~ git:(master) sudo brew link -f node
Password:
Error: Cowardly refusing to `sudo brew link'
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
I've tried uninstalling node via brew uninstall node and retrying the install with no luck.
I run Mac OS X Mavericks. I tried to install node 0.10.25 and the top answer did not work for me.
natevw says to rm -rf /usr/local/lib/node_modules/npm but if the permissions on /usr/local/lib/node_modules look like this:
drwxr-xr-x 3 root admin 102 Feb 2 20:45 node_modules
then brew will not be able to create its npm symlink in that directory. Here's my solution:
Step 1: Update Homebrew
$ brew update
Step 2: Remove node/npm everywhere on your system
Some of these commands are not necessary depending on how you installed node/npm in the past.
$ brew uninstall npm
$ brew uninstall node
$ npm uninstall npm -g
$ sudo rm -rf /usr/local/lib/node_modules
Note: I had stray node files that I found by running brew -v link node (which gave me the verbose output of the linking errors brew was complaining about). You may need to:
$ sudo rm -rf /usr/local/include/node
$ sudo rm -rf /usr/local/lib/node
Step 3: Open a new terminal and install node
$ brew install node
The homebrew package for node.js now includes npm again, so this happened to me when I missed the homebrew package's message about removing the standalone version first.
Assuming, like me, you've already broken node/npm by attempting the upgrade before knowing to npm uninstall npm -g first, you can rm -rf /usr/local/lib/node_modules/npm and then brew link node. This removes the standalone self-hosted npm package (rather than the one brew would like to install) and lets brew symlink its bundled one from Cellar.
sudo chown -R $(whoami) /usr/local
would do just fine as mentioned in the brew site troubleshooting
https://github.com/Homebrew/homebrew/wiki/troubleshooting
You probably already installed an older version of node.js using a different method, so you need to manually remove the files that are getting in brew's way.
Do brew link -n node and manually delete those conflicting files and directories, then try brew link node again.
I'm a bit late, what worked for me was this:
* npm uninstall npm -g
* brew uninstall node
* brew install node
* sudo rm -rf /usr/local/lib/dtrace/node.d
* brew link node (caused error with permissions)
* sudo chmod 777 /usr/local/lib/dtrace/node.d
* brew link node
Everything was successful after this sequence
Try this. Got from another reference and worked for me.
brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) /usr/local
brew link --overwrite node
brew postinstall node
I had the same problem after transferring all my applications from my old Mac to my new one.
I found the solution by running brew doctor :
Warning: Broken symlinks were found. Remove them with brew prune
After running brew prune, Homebrew is finally back on track :)
My problem had a slightly different solution.
The directory in which brew wanted to create the symlinks were not owned by the current user.
ls -la /usr/local/bin/lib/node | grep node yielded:
drwxr-xr-x 3 24561 wheel 102 May 4 2012 node
drwxr-xr-x 7 24561 wheel 238 Sep 18 16:37 node_modules
For me, the following fixed it:
sudo chown $(users) /usr/local/bin/lib/node_modules
sudo chown $(users) /usr/local/bin/lib/node
ps. $(users) will get expanded to your username, went a little out of my way to help out lazy copy pasters ;)
thx #suweller.
I fixed the problem:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...
Error: Permission denied - /usr/local/lib/node_modules/npm
I had the same problem as suweller:
➜ bin git:(master) ✗ ls -la /usr/local/lib/ | grep node
drwxr-xr-x 3 24561 wheel 102 11 Okt 2012 node
drwxr-xr-x 3 24561 wheel 102 27 Jan 11:32 node_modules
so i fixed this problem by:
➜ bin git:(master) ✗ sudo chown $(users) /usr/local/lib/node_modules
➜ bin git:(master) ✗ sudo chown $(users) /usr/local/lib/node
after i fixed this problem I got another one:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
Target /usr/local/lib/dtrace/node.d already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name
To list all files that would be deleted:
brew link --overwrite --dry-run formula_name
So I removed node.d by:
➜ bin git:(master) ✗ sudo rm /usr/local/lib/dtrace/node.d
got another permission error:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
/usr/local/lib/dtrace is not writable. You should change its permissions.
and fixed it:
➜ bin git:(master) ✗ sudo chown $(users) /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
and finally everything worked:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... 1225 symlinks created
the ultimate answer: change the owner of that directory to whoever you are
sudo chown -R `whoami` /usr/local/include
which is also recommended by brew if you run brew doctor
Most brew install issues with node are caused by permission errors or having node previously installed and then trying to install it via brew. The solution that worked for me finally was:
WARNING: This will uninstall nodejs (multiple versions) use with caution:
Remove node via brew:
brew uninstall node
also did via force:
brew uninstall node --force
To use the script Source: Remove node:
curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh
Then:
chmod +x /path/to/terminatenode.sh
Then:
./terminatenode.sh .
Then make sure to do the following command:
chown $USER /usr/local
Then do a brew update (keep doing this until all things are updated):
brew update
Clean brew up and run update again (might be redundant) and run doctor to make sure things are in place:
brew cleanup; brew update; brew doctor
And finally install node via brew (verbose):
brew install -v node
I was getting an error while installation that not able to link node and /usr/local/include is not writable
Below solution worked for me :-
First create the include folder, note that this requires sudo privileges
cd /usr/local
sudo mkdir include
sudo chown -R $(whoami) $(brew --prefix)/*
brew link node
I also managed to mess up my NPM and installed packages between these Homebrew versions and no matter how many time I unlinked / linked and uninstalled / installed node it still didn't work.
As it turns out you have to remove NPM from the path otherwise Homebrew won't install it: https://github.com/mxcl/homebrew/blob/master/Library/Formula/node.rb#L117
Hope this will help someone with the same problem and save that hour or so I had to spend looking for the problem...
by the Finder, Delete this file:
/usr/local/lib/dtrace/node.d
in terminal:
$ brew link --overwrite --dry-run node
then:
$ brew link node
I have tried all of the methods and none of them works.
The easiest way is to reinstall node from https://nodejs.org/en/download/
Simply download the pkg and install it.
Now I have a working npm and node again.
Don't know, if it's a good idea or not: After trying all other solutions without success, I just renamed /usr/local/lib/dtrace, linked node and re-renamed the directory again. After that, node worked as expected.
I was struggling with this for a while. (for me "npm uninstall npm -g" did nothing)
I tried a bunch of things:
npm uninstall npm -g
brew uninstall node
brew install node
I was still having some issues and was getting errors when i tried to link the node files
Finally i tried this
brew link --overwrite node
That seemed to have fixed it. (it overwrites al the conflicting files and also links node and npm)
Hope this helps
I completely uninstalled brew and started again, only to find the same problem again.
Brew appears to work by symlinking the required binaries into your system where other installation methods would typically copy the files.
I found an existing set of node libraries here:
/usr/local/include/node
After some head scratching I remembered installing node at the date against this old version and it hadn't been via brew.
I manually deleted this entire folder and successfully linked npm.
This would explain why using brew uninstall or even uninstall brew itself had no effect.
The highest ranked answer puts this very simply, but I thought I'd add my observations about why it's necessary.
I'm guessing a bunch of issues with other brew packages might be caused by old non-brew instances of packages being in the way.
Had been wrecking my head on symlinking node .. and nothing seemed to work...but finally what worked is setting the right permissions . This 'sudo chown -R $(whoami) /usr/local' did the work for me.
I fixed this in El Capitan by using the following command. Honestly, no idea what it does, but thought I'd share since it fixed my problem.
brew link --overwrite node
You need to remove the npm package manually.
first unlink node: brew link -n node
remove npm folder: rm -R /usr/local/Cellar/node/0.8.10/lib/node_modules/npm
link again: brew link node
there will be a soft link to the new location of npm
Related
I'm installing LightGBM on OSX, following the installation guide. While installing cmake, Homebrew gives such warning message:
Warning: cmake-3.8.1 already installed, it's just not linked.
Then I try:
$brew link cmake
it gives:
Linking /usr/local/Cellar/cmake/3.8.1...
Error: Could not symlink share/man/man7/cmake-buildsystem.7
/usr/local/share/man/man7 is not writable.
The proposition of Mark Setchell to use sudo chown -R $(whoami):admin /usr/local/share/man is right. According to the Homebrew troubleshooting page:
If commands fail with permissions errors, check the permissions of /usr/local’s subdirectories. If you’re unsure what to do, you can run cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var Frameworks
but the proposition of Nano to use sudo is not a good one. According to the Homebrew FAQ:
Homebrew is designed to work without using sudo. You can decide to use it but we strongly recommend not to do so. If you have used sudo and run into a bug then this is likely to be the cause. Please don’t file a bug report unless you can reproduce it after reinstalling Homebrew from scratch without using sudo.
Just follow these 4 steps
sudo chown -R $(whoami) $(brew --prefix)/*
brew doctor
brew prune
brew link cmake
I'm trying to install paramiko on my MacBook Pro (OSX Sierra) without going through Xcode because I'm too lazy to install Xcode honestly.
When trying to run:
brew install paramiko
I get:
Error: No available formula with the name "paramiko"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
I've tried untapping home-brew via:
brew untap homebrew
And I get:
Error: No available tap homebrew/php.
Also tried:
brew tap --repair
brew update
Nothing besides:
Updated 1 tap (caskroom/cask).
No changes to formulae.
If I have to go through Xcode, that's fine but I feel the issue here is not the installation process but something weird with the taps...
This worked for me.
run brew doctor
Warning: Some taps are not on the default git origin branch and may
not receive updates. If this is a surprise to you, check out the
default branch with: git -C $(brew --repo homebrew/core) checkout
master
then run git -C $(brew --repo homebrew/core)
Run this command:
git -C $(brew --repo homebrew/core) checkout master
this will switch to master, then run
brew doctor
this should run without any error.
If there is no error you can install anything with brew install
ex: brew install wget
I ran:
brew doctor
which gave me as first warning:
Warning: Homebrew/homebrew-core was not tapped properly! Run:
rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
Running those 2 commands above solved the problem for me.
I was also facing the same issue when installing Node via brew.
I fixed it by running two commands:
$ brew doctor
This shows me this warning:
Warning: Homebrew/homebrew-core was not tapped properly! Run:
rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
Then I ran these two commands to fix the warning:
$ rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
$ brew tap homebrew/core
And then I tried installing Node:
$ brew install node
It worked.
See if the following approach in the following link helps.
Depending upon your pip/python/xcode version, brew may not work in installing python or python3.
I installed Python3 binary .pkg for Mac from their site, installed it on Mac.
Then, opened a new Terminal window and did:
which python3 && python3 --version && which pip3 && pip3 --version
pip3 install paramiko
brew or pip - install credstash - errors - No named formulae found in taps / OSErr six-1.4.1-py2.7.egg-info operation not permitted
Apparently, I also had this issue, I'm a developer.
I want to develop an OS with a command known as i686-elf-gcc, but with homebrew it doesn't work. So, use this:
brew doctor
And a warning will show up:
Warning: Homebrew/homebrew-core was not tapped properly! Run:
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
So run these:
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
After that, I tried installing my package:
brew install i686-elf-gcc
And, it worked, it should also work for you.
sudo ln -s /usr/lib/dart/bin/pub /usr/bin/pub
sudo ln -s /usr/lib/dart/bin/dart2js /usr/bin/dart2js
git -C $(brew --repo homebrew/core) checkout master
this command helps
I removed ALL content from /usr/local/bin folder (including 'brew'). Homebrew isn't working anymore and I seem to be stuck in a limbo. When I try to install it says:
It appears Homebrew is already installed. If your intent is to
reinstall you should do the following before running this installer
again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
When I run the given uninstall command it says:
Failed to locate Homebrew!
Background
The problem arose when I attempted to remove node.js by following this guide:
https://stackoverflow.com/a/11178106/1736012
To completely uninstall node + npm is to do the following:
go to /usr/local/lib and delete any node and node_modules
go to /usr/local/include and delete any node and node_modules directory
if you installed with brew install node, then run brew uninstall node in your terminal
check your Home directory for any local or lib or
include folders, and delete any node or node_modules from there
go to /usr/local/bin and delete any node executable
Especially 5 was bad! That's what led me to remove everything under /usr/local/bin. So brew doctor won't work (brew isn't recognized anymore). Brew worked fine before this.
What I tried
This does not work either as brew is missing:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
I tried various scripts like this one for example: https://apple.stackexchange.com/a/85481. And this: https://gist.github.com/SteveBenner/11254428. None of them is working (both assumes that brew command is there)...
What can I do to re install Homebrew so that it works as before??
This should bring back a working brew command:
cd /usr/local/Homebrew
git init
git remote add origin https://github.com/Homebrew/homebrew
git pull origin master
Next I would check the output of brew doctor and see if there are major problems. There is an official uninstalling guide on homebrew's github wiki in case you want to completely uninstall.
Try to move or remove the Homebrew file in the user/local file and then try the regular link from the homebrew homepage to install the brew!
By the way, I did not try moving but I am pretty sure it should work.
Note: While the operation you might have to use the sudo
I faced the same issue, the following link really worked for me
https://github.com/Homebrew/brew/issues/10368
especially comment from MrBenFTW commented on Feb 2021
I get this error when installing MongoDB on OSX, even though the second time I tried it with sudo command. Any thought?
==> Checking out tag r3.0.3
==> ./build.sh
==> /usr/local/opt/scons/bin/scons install --prefix=/usr/local/Cellar/mongodb/3.0.3 -j4 --osx-version-min=10.9 --cc=/usr/bin/clang --cxx=/usr/bin/clang++ --use-new-tools
Error: Permission denied - /usr/local/var/mongodb
Monas-MacBook-Pro:meanio mona$ sudo brew install mongodb
Password:
Error: Cowardly refusing to `sudo brew install`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
It's a permissions problem. The solution being:
sudo chown -R `whoami` /usr/local/var/mongodb
Per the comment:
Try creating the directory, prior to setting ownership:
sudo mkdir /usr/local/var/mongodb && sudo chown -R `whoami` /usr/local/var/mongodb
I just open /usr/local/ via finder and manually create folder with name var. Mac asked for a password. After that I successfully install MongoDB.
You shouldn't use brew with sudo. To check the overall brew sanity, run:
$ brew doctor
It will pinpoint potencial problems and it's corresponding solutions. If it really is a permission problem, as pointed by #hd1, you should fix the permissions of /usr/local/var/, where brew is trying to create the /mongodb folder.
Hi I just tried installing git via homebrew on my mac - something is wrong. I had the github for mac app installed, but I tried removing that. The current git version in my system is:
Nielsk#~: $ git --version
git version 1.9.3 (Apple Git-50)
This is what happens if I try to install git via homebrew:
Nielsk#~: $ brew install git
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-2.1.3.y
######################################################################## 100,0%
==> Pouring git-2.1.3.yosemite.bottle.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
/usr/local/bin/git-credential-osxkeychain
The 'contrib' directory has been installed to:
/usr/local/share/git-core/contrib
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
zsh completion has been installed to:
/usr/local/share/zsh/site-functions
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied - /usr/local/lib/perl5/site_perl/5.18.2
Error: Permission denied - /usr/local/lib/perl5/site_perl/5.18.2
How can I solve this?
I also met the same issue. I think we should change the readable permission to make sure any of the directories is readable by "all". So I tried the command: sudo chown -R $USER:admin /usr/local
and then: brew link --overwrite git It works for me, hope it will also work for you.
From High Sierra, chown of /usr/local is not allowed. However you can still change permission the sub directories in /usr/local.
In my case, I had to create Frameworks in /usr/local and sudo chown -R $(whom) Frameworks. After that follow what brew doctor says.
The better way is to create subdirectory whatever you need and run
sudo chown -R $(whoami) $(brew --prefix)/*
For those with the new El Capitan OS, you'll need to update your permissions:
Open Terminal and type the following commands:
$ sudo chown -R $(whoami):admin /usr/local
$ brew doctor
$ brew update
$ brew link --overwrite git
The above solution will work for other brew installs like node, etc. Just replace the last line if you started the installation but encountered errors during the brew installation.
I had a similar permission denied error on install of git until I cleaned things up:
$brew doctor
..... << long output of issues, so you run:
$brew prune
$brew doctor
..... << less issues now, so manually clean up
$brew update
$brew install git
Does that address your error as well?
I did what brew doctor recommended and it helped:
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
MacOS 10.14.4