Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a "don't have write permissions" when installing cocoapod

I'm trying to put a google sign in for my ios app and to do that I need CocoaPods. But when installing it like there own website on terminal I get this:

$ sudo gem install cocoapods

[Password: (*Put in my admin password for my macbook*)
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.

This is being done on a Macbook Air running High Sierra 10.13.2 (Don't know if you need that info but I've never done anything with cocoapods or ruby before)

I also tried following this link and followed the awnser and installed RVM, or at least I think I did. I just put this in:

ruby -e "$(curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install)"

Well I tried installing CocoaPods after that but still got the same thing.

like image 400
Adam Zyluk Avatar asked Dec 29 '17 01:12

Adam Zyluk


Video Answer


1 Answers

You might try the following command

sudo gem install cocoapods -n /usr/local/bin


The problem is that gem install was trying to use /usr/bin for installing the binaries, which shouldn't be touched for the System Integrity Protection. Since:

A centerpiece is the protection of system-owned files and directories against modifications by processes without a specific "entitlement", even when executed by the root user or a user with root privileges (sudo)

Sudo is without any power in this situation.

Hence the solution uses -n, from gem help install it says:

-n, --bindir DIR Directory where binary files are located

in this way you will be able to move the binaries in a more comfortable destination: /usr/local/bin which stands for programs that a normal user may run.

like image 192
Andrea Mugnaini Avatar answered Oct 08 '22 01:10

Andrea Mugnaini