Using Brew to Install rbenv - ruby-on-rails

I'm trying to take a coursera class on Ruby from Johns Hopkins. The Mac OSX set up instructions require that I download homebrew and then install rbenv. I already have brew installed from stuff I had done a long time back, so perhaps this issue is because I screwed up installing ruby/brew a long time ago.
Here's the command that's giving me issues: brew install rbenv ruby-build
the response i get is this:
Warning: rbenv-0.4.0 already installed, it's just not linked
==> Installing dependencies for ruby-build: pkg-config, openssl
Error: Cannot link pkg-config
Another version is already linked: /usr/local/Cellar/pkg-config/0.28
Update: Here's what appeared after running brew doctor:
Warning: /usr/local/bin isn't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.
You should probably change the ownership and permissions of /usr/local/bin
back to your user account.
sudo chown -R $(whoami) /usr/local/bin
Warning: /usr/local/share isn't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.
You should probably change the ownership and permissions of /usr/local/share
back to your user account.
sudo chown -R $(whoami) /usr/local/share
Warning: Some directories in /usr/local/share/man aren't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a brew tries to add locale information to one of these
directories, then the install will fail during the link step.
You should probably `sudo chown -R $(whoami)` them:
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man5
/usr/local/share/man/mann
Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/bin/2to3-3.3
/usr/local/bin/apm
/usr/local/bin/atom
/usr/local/bin/idle3.3
/usr/local/bin/python3.3-32
/usr/local/bin/pythonw3
/usr/local/bin/pythonw3-32
/usr/local/bin/pythonw3.3
/usr/local/bin/pythonw3.3-32
/usr/local/bin/pyvenv-3.3
/usr/local/bin/subl
Warning: Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libMonoPosixHelper.dylib
/usr/local/lib/libSFFileMonitor.32.dylib
/usr/local/lib/libSFIPC.32.dylib
/usr/local/lib/libSFIPC.I.dylib
/usr/local/lib/libSFsqlite3.7.4.dylib
/usr/local/lib/libSFSyncEngine.I.dylib
/usr/local/lib/libtcl8.6.dylib
/usr/local/lib/libtk8.6.dylib
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/fakemysql.h
/usr/local/include/fakepq.h
/usr/local/include/fakesql.h
/usr/local/include/itcl.h
/usr/local/include/itcl2TclOO.h
/usr/local/include/itclDecls.h
/usr/local/include/itclInt.h
/usr/local/include/itclIntDecls.h
/usr/local/include/itclMigrate2TclCore.h
/usr/local/include/itclTclIntStubsFcn.h
/usr/local/include/mysqlStubs.h
/usr/local/include/node/ares.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/nameser.h
/usr/local/include/node/node.h
/usr/local/include/node/node_buffer.h
/usr/local/include/node/node_internals.h
/usr/local/include/node/node_object_wrap.h
/usr/local/include/node/node_version.h
/usr/local/include/node/openssl/opensslconf.h
/usr/local/include/node/uv-private/ngx-queue.h
/usr/local/include/node/uv-private/stdint-msvc2008.h
/usr/local/include/node/uv-private/tree.h
/usr/local/include/node/uv-private/uv-bsd.h
/usr/local/include/node/uv-private/uv-darwin.h
/usr/local/include/node/uv-private/uv-linux.h
/usr/local/include/node/uv-private/uv-sunos.h
/usr/local/include/node/uv-private/uv-unix.h
/usr/local/include/node/uv-private/uv-win.h
/usr/local/include/node/uv.h
/usr/local/include/node/v8-debug.h
/usr/local/include/node/v8-preparser.h
/usr/local/include/node/v8-profiler.h
/usr/local/include/node/v8-testing.h
/usr/local/include/node/v8.h
/usr/local/include/node/v8stdint.h
/usr/local/include/node/zconf.h
/usr/local/include/node/zlib.h
/usr/local/include/odbcStubs.h
/usr/local/include/pqStubs.h
/usr/local/include/tcl.h
/usr/local/include/tclDecls.h
/usr/local/include/tclOO.h
/usr/local/include/tclOODecls.h
/usr/local/include/tclPlatDecls.h
/usr/local/include/tclThread.h
/usr/local/include/tclTomMath.h
/usr/local/include/tclTomMathDecls.h
/usr/local/include/tdbc.h
/usr/local/include/tdbcDecls.h
/usr/local/include/tdbcInt.h
/usr/local/include/tk.h
/usr/local/include/tkDecls.h
/usr/local/include/tkPlatDecls.h
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
/usr/local/lib/pkgconfig/tcl.pc
/usr/local/lib/pkgconfig/tk.pc
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libtclstub8.6.a
/usr/local/lib/libtkstub8.6.a
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
rbenv
Warning: You have uncommitted modifications to Homebrew
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
cd /usr/local/Library && git stash && git clean -d -f
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
2to3
2to3-2.7
easy_install
easy_install-2.7
idle
idle2.7
info
infokey
install-info
makeinfo
pydoc
pydoc2.7
python
python-config
python2.7
python2.7-config
pythonw
pythonw2.7
smtpd.py
smtpd2.7.py
tclsh
tclsh8.5
texi2dvi
texi2pdf
texindex
wish
wish8.5
Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile`
New Update:
I did brew prune, changed ownership of the files that it suggested (some of them could not be found). Finally, when i run brew install rbenv ruby-build i get the following errors:
Warning: rbenv-0.4.0 already installed, it's just not linked
Warning: ruby-build-20151028 already installed
The next step would be to do rbenv install 2.2.3, but rbenv command is not found. Seems that the installation failed somehow. which rbenv also produced no output.

According to brew doctor, you can't edit the directories that it's trying to install files to. Try running
sudo chown -R $(whoami) /usr/local/bin
etc, like brew doctor is telling you:
You should probably change the ownership and permissions of /usr/local/share
back to your user account.
sudo chown -R $(whoami) /usr/local/share
EDIT:
You might want to take a look at this part of the output to list the things you need to run the command on.
You should probably `sudo chown -R $(whoami)` them:
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man5
/usr/local/share/man/mann

Related

Refusing to link macOS-provided software: libiconv

In an effort to follow the steps posted here to get nokogiri working, I seem unable to link iconv properly.
When I run the command
brew link libiconv
I receive the following error:
Warning: Refusing to link macOS-provided software: libiconv
If you need to have libiconv first in your PATH run:
echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.bash_profile
For compilers to find libiconv you may need to set:
export LDFLAGS="-L/usr/local/opt/libiconv/lib"
export CPPFLAGS="-I/usr/local/opt/libiconv/include"
I've added the above paths to my bash profile, reloaded the terminal, restarted the terminal and even tried restarting the computer as well but the error still persists. I've also tried reinstalling libiconv but to no avail (see output below).
$ brew reinstall libiconv
==> Reinstalling libiconv
==> Downloading https://homebrew.bintray.com/bottles/libiconv-1.16.mojave.bottle.tar.gz
Already downloaded: /Users/sam/Library/Caches/Homebrew/downloads/203933f4d9f3c2f0463012d85013a6c01bdb89fc4d435341315b4537de1dba78--libiconv-1.16.mojave.bottle.tar.gz
==> Pouring libiconv-1.16.mojave.bottle.tar.gz
==> Caveats
libiconv is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have libiconv first in your PATH run:
echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.bash_profile
For compilers to find libiconv you may need to set:
export LDFLAGS="-L/usr/local/opt/libiconv/lib"
export CPPFLAGS="-I/usr/local/opt/libiconv/include"
==> Summary
🍺 /usr/local/Cellar/libiconv/1.16: 30 files, 2.4MB
libiconv is keg-only.
❯ brew info libiconv
libiconv: stable 1.16 (bottled) [keg-only]
Conversion library
https://www.gnu.org/software/libiconv/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libiconv.rb
==> Caveats
libiconv is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
In the post link given by you, linking libiconv is unneeded. Cause only the real installation location is used but not the linked one. Just skip this link step and run following command,
# use the real installation location is not preferred, cause it will
# break you once the libiconv is upgraded to a new version
gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.16
# you'd better pass the dir "/usr/local/opt/libiconv",
# which serves as a link to the real installation location.
gem install nokogiri -- --with-iconv-dir=/usr/local/opt/libiconv

Homebrew aspell directory not writable

I am having some difficulties. This started with a broader question but I seem (with some help from this list) to have narrowed things down a bit. My original query is at Emacs - Kieran Healy's Emacs Starter Kit aspell English dictionery
(And, yes, I am embarrassed at the spelling error in the title).
I have narrowed (with some help from that question) to narrow my problem down to the Homebrew installation of aspell. The command brew install aspell gives the following error.
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink lib/aspell-0.60/american-variant_0.alias
/usr/local/lib/aspell-0.60 is not writable.
You can try again using:
brew link aspell
If I try brew link aspell I get the following error:
Linking /usr/local/Cellar/aspell/0.60.6.1_1...
Error: Could not symlink lib/aspell-0.60/american-variant_0.alias
/usr/local/lib/aspell-0.60 is not writable.
File permissions on aspell are
drwxr-xr-x 89 root wheel 2848 7 Nov 2016 aspell-0.60
brew doctor gives
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that
depend on
those kegs to fail to run properly once built. Run `brew link` on
these:
aspell
It also tells me I need to update from XCode 9.3 to XCode 10.1, but since I am still running MacOS 10.13.4, I think I do not need to do this.
Any help greatly appreciated.
The info at Homebrew: Could not symlink, /usr/local/bin is not writable was helpful. I had to sudo chown -Rwhoami:admin /usr/local/lib. Then after unintalling and reinstalling aspell with Homebrew, I had to brew link --overwrite aspell. Everything works now.

Can't install Homebrew on Yosemite: /usr/local/lib already exists

I tried installing Homebrew on Yosemite for the first time. I chose to install via Terminal, though I am no expert on it. And then this happened:
-e:161: warning: Insecure world writable dir /usr/local in PATH, mode 040777
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/lib
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /usr/local/lib
Password:
Then I entered my password. Then this happened:
mkdir: /usr/local/lib: Not a directory
Failed during: /usr/bin/sudo /bin/mkdir -p /usr/local/lib
And when I checked my /usr/local/ directory there was already a file named lib.
This is a screen-capture of my /usr/local/ directory.
I can't seem to install Homebrew with this. Can anyone please advise me on my next step? Thanks a lot in advance.
Well you need to, at least temporarily, rename /usr/local/lib because it doesn't belong to homebrew and is in the way:
sudo mv /usr/local/lib /usr/local/oldlib

brew installation error : Appears homebrew is already installed

unknown7cd1c37eb7ca:local shoaibali$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
-e:67: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
-e:96: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
unknown7cd1c37eb7ca:local shoaibali$ ls
CONTRIBUTING.md foreman hw_mp_userdata
Library git libexec
PortDetect.log heroku opt
bin hw_mobile_userdata share
unknown7cd1c37eb7ca:local shoaibali$
I have some problems with my brew when I was trying to install ffmpeg. I think I did the immature thing (note - after hours of trying) of uninstalling brew (through some article i read online) and trying to reinstall it. But the above output comes in my terminal when I try to install brew again. How can it say Homebrew is already installed when clearly the Cellar file isn't there ?
I had the same issue.
There was no directory called., /usr/local/Cellar but brew installation kept reporting it is already installed.
I resolved the issue by doing the following.,
Step 1 : run
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
(It reported error and didn't run successfully., but I believe it did cleanup)
Step 2 : Being from Windows world., restarted the terminal
Step 3 : Ran again
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
It ran successfully.,
A simple
sudo rm -rf /usr/local/.git
fixed my problem and I could re-install brew
I tried this solution but running "brew cleanup" when the system doesn't detect brew is not possible XD
I came up with a possible solution... I've tried to install MacPort and also didn't installed well, but it seems to uninstall (somehow) brew, so I could reinstall it from scratch
And this time it works! So, maybe it helps somebody!
PS: I think my original problem was that I had internet connection problem when I installed Brew for the first time, and didn't installed well

brew install nginx fails to link

I am attempting to install nginx using the brew package manager, but it fails to link. How can I fix this?
roc-web5537:Downloads cmuench$ brew install nginx
Warning: Your Xcode (4.3.3) is outdated
Please install Xcode 4.5.
==> Installing nginx dependency: pcre
==> Downloading ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.bz2
Already downloaded: /Library/Caches/Homebrew/pcre-8.31.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/pcre/8.31 --enable-utf8 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2
==> make test
==> make install
Warning: Could not link pcre. 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 pcre'
==> Summary
/usr/local/Cellar/pcre/8.31: 130 files, 3.2M, built in 18 seconds
==> Installing nginx
==> Downloading http://nginx.org/download/nginx-1.2.4.tar.gz
Already downloaded: /Library/Caches/Homebrew/nginx-1.2.4.tar.gz
==> Patching
patching file conf/nginx.conf
==> ./configure --prefix=/usr/local/Cellar/nginx/1.2.4 --with-http_ssl_module --with-pcre --with-ipv6 --with-cc-opt=-I/usr/local/include --with-ld-opt=-L/usr/local/lib --conf-path=/usr/loca
==> make
==> make install
==> Caveats
In the interest of allowing you to run `nginx` without `sudo`, the default
port is set to localhost:8080.
If you want to host pages on your local machine to the public, you should
change that to localhost:80, and run `sudo nginx`. You'll need to turn off
any other web servers running port 80, of course.
You can start nginx automatically on login running as your user with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/nginx/1.2.4/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Though note that if running as your user, the launch agent will fail if you
try to use a port below 1024 (such as http's default of 80.)
Warning: Could not link nginx. 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 nginx'
Warning: /usr/local/sbin is not in your PATH
You can amend this by altering your ~/.bashrc file
==> Summary
/usr/local/Cellar/nginx/1.2.4: 9 files, 952K, built in 9 seconds
I had this issue a few days ago with installation of Yeoman. It seems that some of the folders in /usr/local might not be owned by you and that can cause issues. In my case I had a couple of folders in /usr/local/ like that.
Go to /usr/local
cd /usr/local
Check who owns the folders
ls -l
Do the following for folders not owned by you (replacing sub-foldername with sub folders name obviously):
sudo chown $(whoami) /usr/local/<sub-foldername>
and then call
brew link pcre
It should link successfully.
Hope this helps.
This can sometimes happen if there area already files (or symlinks) with the same name. To force a link, you can use brew link -f pcre. If you want to see whether there are any files preventing the link, you can use brew link --dry-run pcre.
If there are no files listed by brew link --dry-run pcre, then it is likely that jwwishart's answer is the correct one.
I had to remove manually and reinstall pcre and openssl then nginx will work:
brew remove pcre
brew remove openssl
brew install pcre
brew install openssl
nginx
Was getting
erma4inapower#MacBook-Pro-Dmitrij  ~  brew services start php
Error: Permission denied # rb_sysopen - /Users/erma4inapower/Library/LaunchAgents/homebrew.mxcl.php.plist
Ended up:
sudo chown -R $(whoami) /Users/erma4inapower/Library/LaunchAgents/
I had the same issue and was causing problems while other services using brew.
how to fix run
brew doctor
remove all files which are causing the issue. might have to do
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
if warning comes up
make sure you are in master branch by
git -C $(brew --repo homebrew/core)
checkout Important is the brew doctor command which help me fix the issue.

Resources