Joe
Joe

Reputation: 720

Unable to install Ruby through Homebrew, Permission denied error

As someone brand new to programming, I am attempting to install Ruby using homebrew. The installation keeps getting stuck at the 'openssl' stage. This appears to be down to permissions on the directory:

/usr/local/etc/openssl/

Research on here and elsewhere online has pointed to attempting to install 'openssl' separately via Homebrew, which I have done and ended with the error:

==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2e.yosemite.bot
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2e.yosemite.bottle.tar.gz
==> Pouring openssl-1.0.2e.yosemite.bottle.tar.gz
Error: Permission denied - /usr/local/etc/openssl/certs
Warning: Bottle installation failed: building from source.
==> Downloading https://www.openssl.org/source/openssl-1.0.2e.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2e.tar.gz
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.2e --openssldir=/usr
==> make depend

==> make
==> make test
==> make install MANDIR=/usr/local/Cellar/openssl/1.0.2e/share/man MANSUFFIX=ssl
Last 15 lines from /Users/Joe/Library/Logs/Homebrew/openssl/05.make:
SSL_want_read.3ssl => SSL_want.3ssl
SSL_want_write.3ssl => SSL_want.3ssl
SSL_want_x509_lookup.3ssl => SSL_want.3ssl
installing man3/SSL_write.3ssl
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/certs: Permission denied
created directory `/usr/local/Cellar/openssl/1.0.2e/bin'
created directory `/usr/local/Cellar/openssl/1.0.2e/lib'
created directory `/usr/local/Cellar/openssl/1.0.2e/lib/engines'
created directory `/usr/local/Cellar/openssl/1.0.2e/lib/pkgconfig'
created directory `/usr/local/Cellar/openssl/1.0.2e/include'
created directory `/usr/local/Cellar/openssl/1.0.2e/include/openssl'
make: *** [install_sw] Error 13

So I used 'chown' to change the ownership of the /openssl/ directory and managed to get a little further but am now stuck with this error:

==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2e.yosemite.bot
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2e.yosemite.bottle.tar.gz
==> Pouring openssl-1.0.2e.yosemite.bottle.tar.gz
Error: Permission denied - /usr/local/etc/openssl/misc/c_hash
Warning: Bottle installation failed: building from source.
==> Downloading https://www.openssl.org/source/openssl-1.0.2e.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.2e.tar.gz
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.2e --openssldir=/usr
==> make depend
==> make
==> make test
==> make install MANDIR=/usr/local/Cellar/openssl/1.0.2e/share/man MANSUFFIX=ssl
Last 15 lines from /Users/Joe/Library/Logs/Homebrew/openssl/05.make:
            *DSO_WIN32*) sfx="eay32.dll"; pfx=;; \
            *) sfx=".bad";; \
            esac; \
            cp ${pfx}gost$sfx /usr/local/Cellar/openssl/1.0.2e/lib/engines/${pfx}gost$sfx.new; \
        fi; \
        chmod 555 /usr/local/Cellar/openssl/1.0.2e/lib/engines/${pfx}gost$sfx.new; \
        mv -f /usr/local/Cellar/openssl/1.0.2e/lib/engines/${pfx}gost$sfx.new /usr/local/Cellar/openssl/1.0.2e/lib/engines/${pfx}gost$sfx; \
    fi
installing gost
making install in apps...
installing openssl
installing CA.sh
cp: /usr/local/etc/openssl/misc/CA.sh.new: Permission denied
make[1]: *** [install] Error 1
make: *** [install_sw] Error 1

Again, to do with permissions on things in the openssl folder?

Does anyone know how to change this?

I guess the thing that has confused me MOST of all though is that I am the ONLY user on this computer and therefore the only admin as well, so I cannot get my head around why I would not have permission to access anything?

Two other things I have tried:

Thanks for any help in advance.

Upvotes: 1

Views: 3936

Answers (1)

Mike S
Mike S

Reputation: 11429

Simply being the only admin user on the machine does not mean that all the commands you run with that user will be run with root privilege. There is a still a separate root user inside the machine even though you don't get a GUI login for it. That would be a security risk and it also helps prevent you from accidentally hanging yourself by running a destructive command without slapping sudo in front of it.

You have two choices to resolve the issue:

  1. Adjust the permission of every directory that installer needs (in this case /usr/local/etc/openssl/misc). Looks like it needs write permission based on the error. But there may be many more directories once you get past that specific error.

You can make it fully open like this:

chmod -R 777 /usr/local/etc/openssl/misc

or chown everything to yourself:

chown -R "$USER":admin /usr/local
  1. Run brew as the root user (or with root privilege via sudo). This will require you to chown the brew executable to root instead of your user.

Upvotes: 7

Related Questions