I have never used CocoaPods before. I have installed CocoaPods gems and now I want to delete them but it won't allow me to.
I've attempted to uninstall them by running the command,
$ gem uninstall cocoapods
Then it asked me if I wanted to remove executables [Yn]. I selected Y. I expected it to remove the CocoaPods. Instead it gave me the error:
'ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/bin directory.'
What does this error mean and how can I remove the CocoaPods?
Your current user probably doesn't have write permissions to /usr/local/bin. If you want, you can check the permissions like so:
$ ls -ld /usr/local/bin
drwxrwxr-x 573 aaronbrager admin 18336 Dec 14 09:32 /usr/local/bin
And see who you're logged in as like so:
$ whoami
aaronbrager
In your case, I'm guessing they're different.
Anyway, you can
fix the permissions (using chown and chmod),
change users (login as someone else), or
just use sudo, assuming you have the admin password
I'm guessing this will be easiest for you:
sudo gem uninstall cocoapods
Related
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.
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.
With the latest version of bundler, I keep getting errors such as:
STDOUT: There was an error while trying to write to /home/user1/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47.
It is likely that you need to grant write permissions for that path.
I'm running sudo su - user2 bundle install synapse, where user2 has no HOME directory. I'm trying to install Airbnb Smartstack using Chef.
It seems that the latest version of Bundler insists on writing the new index cache files to $HOME/.bundle. This means that commands such as:
sudo su - homelessuser bundle install synapse
...fail when they try to write to the $HOME/.bundle of the user that called sudo ....
As a workaround, I'm pinning my bundler version to 1.11.2 for now.
Note The GitHub issue for this can be found here
I am using Amazon EC2 instance and when I run bundle install as ec2-user, it works fine but when I try the same as root user, it gives error.
bash: bundle: command not found
There is bundler gem exist when I run gem list for both users. I have installed ruby-devel rubygems ruby-libs as root user. Can anyone please help me understand this issue? I have searched and read for hours.
echo $PATH of both users are as below.
root:
/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin
ec2-user:
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin
I added /usr/local/bin and /usr/local/sbin to secure_path in /etc/sudoers
sudo visudo
Then change this line:
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
Changed this to
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
Explanation:
Gems were installed at /usr/local path and without adding this in secure_path, root user cannot run scripts from there. You can check your gems path by running gem env in shell.
I also had another issue. I installed gems as ec2-user using bundle and default rubygems path in Amazon Linux installed them only for ec2-user, something I did not like so I installed ruby and rubygems from source which has path to installed them at central location under /usr/local. I know it is not recommended by many but I like it this way. By the way, I tried to find a way to change rubygems path but I could not.
Try sudo -i -u $USER bundle install
where $USER is the correct username so : sudo -i -u root bundle install
If this does not work, consider giving a try to the rbenv-sudo plugin.
I installed ruby via \curl -L https://get.rvm.io | bash -s stable and did rvm install 1.9.2 doing this creates and error
Installing requirements for osx, might require sudo password.
fatal: Unable to create '/usr/local/.git/index.lock': Permission denied
Error: Failure while executing: git checkout -q master
Failed to update Homebrew, follow instructions here:
https://github.com/mxcl/homebrew/wiki/Common-Issues and make sure `brew update` works before continuing.
Upon doing a which git it shows it's installed in /usr/bin/git yeah homebrew keeps trying to reference /usr/local/.git. I tried unistalling homebrew so I can do a fresh install using what's listed at homebrew gist. All seemed well but doing a which brew still shows it as /usr/local/bin/brew so I tried to manually uninstall it by doing it one by one.
One thing to note is I never had a Cellar folder, why I don't know. While doing a brew prune I noticed a lot of macport items are starting to ask if I should override them.
Is it typical to of ran the uninstall script but still have the brew commands available or the dirs?
Why is it that homebrew needs root access to /user/local/ to work, this is extremely bad.
That /usr/local/.git it's referencing is not the git executable, but the config file for the repository it's trying to set up under /usr/local/. It's trying to write to that file.
To run homebrew you need write permissions to /usr/local as the user you'r going to run brew as. Homebrew's recommended method is to adjust the ownership and permissions on /usr/local to allow you to write to it from your regular user account or a dedicated homebrew account, instead of using sudo. This is done as part of the homebrew installation script, typically by putting you in the admin group and making /usr/local group-writable.
To fix this, check the owner and permissions on /usr/local/ and /usr/local/.git and make sure you can write to them (and the rest of the /usr/local/ hierarchy) as the user that you're running brew and RVM commands as.
Ended up just doing a sudo $USER as I really could not find any other approach to fixing this.
I'm just trying to setup my first rails server - on Ubuntu 12.04. I installed rbenv (as user: deployer with groups sudo and admin). Now trying to install passenger according to their docs.
I run passenger-install-nginx-module it starts but then I get
Please specify a prefix directory [/opt/nginx]:
--------------------------------------------
Permission problems
This installer must be able to write to the following directory:
/opt/nginx
But it can't do that, because you're running the installer as deployer.
Ok, I run sudo passenger-install-nginx-module then, and get sudo: passenger-install-nginx-module: command not found.
Does it mean I have to install it by loggin as root, installing whole rbenv for root user and then install passenger? Every tutorial I read they run it from not root user account :/, it doesn't work for me.
As I wrote in my comment, you have to run the passenger-install-nginx-module as root with the full path, because it is not in the $PATH var of your bash. To find out the path, run which passenger-install-nginx-module