Installing Rails on Mac OS fails with several erro

2019-04-28 09:33发布

I am trying to install Rails on my Mac OS v10.10.4 system, and it fails when I run brew install rbenv ruby-build. The error is:

Error: Permission denied - /usr/local/etc/openssl
Warning: Bottle installation failed: building from source.

At the end of the process it says:

installing man3/d2i_SSL_SESSION.3ssl
i2d_SSL_SESSION.3ssl => d2i_SSL_SESSION.3ssl
installing man3/ssl.3ssl
Cannot create directory /usr/local/etc/openssl: Permission denied

Here is the complete log of all what I tried during this attempt:

Mac-213978b7b1793718b9:ROR developer$ brew install rbenv ruby-build
Warning: rbenv-0.4.0 already installed
==> Installing ruby-build dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2d_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2d_1.yosemite.bottle.tar.gz
Error: Permission denied - /usr/local/etc/openssl
Warning: Bottle installation failed: building from source.
==> Downloading https://www.openssl.org/source/openssl-1.0.2d.tar.gz
######################################################################## 100.0%
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.2d_1 --openssldir=/usr/local/etc/openssl no-ssl2 zlib-dynamic shared enable-cms darw
==> make depend
==> make
==> make test
==> make install MANDIR=/usr/local/Cellar/openssl/1.0.2d_1/share/man MANSUFFIX=ssl
installing man3/d2i_SSL_SESSION.3ssl
i2d_SSL_SESSION.3ssl => d2i_SSL_SESSION.3ssl
installing man3/ssl.3ssl
Cannot create directory /usr/local/etc/openssl: Permission denied
make: *** [install_sw] Error 13

READ THIS: https://git.io/brew-troubleshooting

These open issues may also help:
Installing Elixir fails due to OpenSSL errors. https://github.com/Homebrew/homebrew/issues/33218
Mac-213978b7b1793718b9:ROR developer$ rbenv install --patch 2.1.1
rbenv: no such command `install`
Mac-406c8f4772a8:ROR developer$ rbenv instal --patch 2.1.1
rbenv: no such command `instal`
Mac-406c8f4772a8:ROR developer$ brew install --HEAD ruby-build
==> Installing ruby-build dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2d_1.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2d_1.yosemite.bottle.tar.gz
==> Pouring openssl-1.0.2d_1.yosemite.bottle.tar.gz
Error: Permission denied - /usr/local/etc/openssl
Warning: Bottle installation failed: building from source.
==> Downloading https://www.openssl.org/source/openssl-1.0.2d.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2d.tar.gz
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.2d_1 --openssldir=/usr/local/etc/openssl no-ssl2 zlib-dynamic shared enable-cms darw
==> make depend
==> make
brew install rbenv ruby-build==> make test
==> make install MANDIR=/usr/local/Cellar/openssl/1.0.2d_1/share/man MANSUFFIX=ssl
installing man3/d2i_SSL_SESSION.3ssl
i2d_SSL_SESSION.3ssl => d2i_SSL_SESSION.3ssl
installing man3/ssl.3ssl
Cannot create directory /usr/local/etc/openssl: Permission denied
make: *** [install_sw] Error 13

READ THIS: https://git.io/brew-troubleshooting

These open issues may also help:
Installing Elixir fails due to OpenSSL errors. https://github.com/Homebrew/homebrew/issues/33218
Mac-213978b7b1793718b9:ROR developer$ brew install rbenv ruby-build
Warning: rbenv-0.4.0 already installed
==> Installing ruby-build dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2d_1.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2d_1.yosemite.bottle.tar.gz
==> Pouring openssl-1.0.2d_1.yosemite.bottle.tar.gz
Error: Permission denied - /usr/local/etc/openssl
Warning: Bottle installation failed: building from source.
==> Downloading https://www.openssl.org/source/openssl-1.0.2d.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2d.tar.gz
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.2d_1 --openssldir=/usr/local/etc/openssl no-ssl2 zlib-dynamic shared enable-cms darw
^Z
[1]+  Stopped                 brew install rbenv ruby-build
Mac-213978b7b1793718b9:ROR developer$ curl https://gist.githubusercontent.com/andschwa/11334511/raw/563d5c2efb869cafb0c65404d12243822bba2817/ruby-2.1.1-readline.patch | rbenv install --patch 2.1.1
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0rbenv: no such command `install'
100  1713  100  1713    0     0   1499      0  0:00:01  0:00:01 --:--:--  1498
(23) Failed writing body
Mac-213978b7b1793718b9:ROR developer$

I have looked at the folllowing links so far:

3条回答
Luminary・发光体
2楼-- · 2019-04-28 09:56

I finally used this tutorial Setup Ruby On Rails on Mac OS X 10.11 El Capitan after updating my mac to EI caption few months back and this worked.

Here is log from console it will explain all what happens. And how finally I got to run my first ruby application. There are several mistakes that I made which a beginner might will, but I finally nailed it. Here is how it looks.

enter image description here

rptwsthi:~ developer$ $ gcc
-bash: $: command not found
rptwsthi:~ developer$ gcc
2016-06-27 15:16:33.881 xcodebuild[2150:87788] [MT] PluginLoading: Required plug-in compatibility UUID ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Unity4XC.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2016-06-27 15:16:36.662 xcodebuild[2153:87846] [MT] PluginLoading: Required plug-in compatibility UUID ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Unity4XC.xcplugin' not present in DVTPlugInCompatibilityUUIDs
clang: error: no input files
rptwsthi:~ developer$ $ xcode-select -p
-bash: $: command not found
rptwsthi:~ developer$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
rptwsthi:~ developer$ gcd
-bash: gcd: command not found
rptwsthi:~ developer$ gcc
clang: error: no input files
rptwsthi:~ developer$ xcode-select --install
xcode-select: note: install requested for command line developer tools
rptwsthi:~ developer$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
rptwsthi:~ developer$ git --version
git version 2.6.3
rptwsthi:~ developer$ --l --global
-bash: --l: command not found
rptwsthi:~ developer$ -l --global
-bash: -l: command not found
rptwsthi:~ developer$ git config -l -global
error: did you mean `--global` (with two dashes ?)
rptwsthi:~ developer$ git config -l --global
filter.media.clean=git-media-clean %f
filter.media.smudge=git-media-smudge %f
user.name=rptwsthi
user.email=awasthi.arp@gmail.com
core.excludesfile=/Users/developer/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
filter.hawser.clean=git hawser clean %f
filter.hawser.smudge=git hawser smudge %f
filter.hawser.required=true
color.ui=true
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
rptwsthi:~ developer$ brew
Example usage:
brew [info | home | options ] [FORMULA...]
brew install FORMULA...
brew uninstall FORMULA...
brew search [foo]
brew list [FORMULA...]
brew update
brew upgrade [--all | FORMULA...]
brew pin/unpin [FORMULA...]

Troubleshooting:
brew doctor
brew install -vd FORMULA
brew [--env | config]

Brewing:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md

Further help:
man brew
brew home
rptwsthi:~ developer$ brew install gpg
Warning: You are using OS X 10.11.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.

==> Downloading ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.19.tar.bz2

curl: (28) Connection time-out
Trying a mirror...
==> Downloading https://www.mirrorservice.org/sites/ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.19.tar.bz2
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/gnupg/1.4.19 --disable-asm
==> make
==> make check
==> make install
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/gpg
Target /usr/local/bin/gpg
already exists. You may want to remove it:
rm '/usr/local/bin/gpg'

To force the link and overwrite all conflicting files:
brew link --overwrite gnupg

To list all files that would be deleted:
brew link --overwrite --dry-run gnupg

Possible conflicting files are:
/usr/local/bin/gpg -> /usr/local/MacGPG2/bin/gpg2
==> Summary
                                                                    
查看更多
虎瘦雄心在
3楼-- · 2019-04-28 09:58

If a home brew install is causing problems your first reflex should be to run

brew doctor

This should diagnose most issues and even suggest remedies (such as the ones mentioned by other answers)

查看更多
Rolldiameter
4楼-- · 2019-04-28 10:05

Run this command first

sudo chown -R <your username>:admin /usr/local

Replace <your username> with whatever your username on your mac is. So, in my case, I would run

sudo chown -R Adrian:admin /usr/local

Then try installing rbenv and ruby-build.

Your problem is most likely caused by the use of package installers (.pkg files) as they tend to create files as root in places where they shouldn't.

Note: you can find out your username by running whoami

查看更多
登录 后发表回答