I removed cocoa pods because it claimed it had installed, but kept saying the command pod wasn't found afterward. When trying to reinstall cocoapods (sudo gem install cocoa pods -v) I get this error:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
Any ideas?
As it has been pointed out below by Ramesh Ramchandaran, this is a cleaner way of doing it, instead of getting around the Security features of OS X.
sudo gem install -n /usr/local/bin cocoapods
Original Answer
I'm assuming you're running OS X 10.11.
This is happening because Apple has enabled rootless on the new install.
If you type:
sudo nvram boot-args="rootless=0"; sudo reboot
in terminal.app, your computer will reboot with it disabled.
Once that is done, type:
sudo gem install cocoapods -V
the -V is for verbose and will spit out any errors if they happen.
As rootless does not affect /usr/local/bin, the following succeeds:
sudo gem install -n /usr/local/bin cocoapods
Any caveats?
Using home-brew or custom $GEM_HOME can help resolving the issue.
I did clean installation of ruby with brew:
brew install ruby
Now the gem stuff seem to happen relative to my /usr/local/bin*, which is exactly what I needed.
I recommend installing all your gems into your .gem folder in your home folder to avoid using sudo or a ruby version manager as other people suggest.
All you have to do is update your .bash_profile by adding these 2 lines. (Don‘t forget to restart your terminal after applying these changes)
export GEM_HOME=~/.gem
export PATH="$GEM_HOME/bin:$PATH"
After updgrading from Yosemite to El Capitan ( 10.11.4), I kept getting the below error message while trying to 'reinstall' Cocoapods ( after trying out pretty much all the solutions under different Stackoverflow threads and the Cocoapods issue-page itself, for the same issue)
"Could not find a valid gem 'cocoapods' (>= 0) in any repository"
However, quit terminal, restarted system, created new Xcode project from the scratch and then when i did 'pod install', it worked.
Note: I was trying to use Alamofire and SwiftyJson cocoapods
Related
Not working below commands on MacBook Terminal:
gem install cocoapods,
gem install cocoapods-art
Getting bellow error message:
ERROR: Could not find a valid gem 'cocoapods' (>= 0) in any repository
I have tried many solutions which are available on Google/Stackoverflow but not worked.
Thanks in advance.
If you have satisfied other conditions and you wish to install the latest version of cocoapods, you may wish to install using homebrew.
To do that, you can install with this command on your terminal;
brew install cocoapods
You will be required to link cocoapods after installing - to link, use;
brew link --overwrite cocoapods
Hope it works for you...
There can be different reasons for this.
Make sure you have Xcode installed on the system (its components too, Which it asks us to install on installation)
It can happen due to some network issues.try disabling IPv6, your can also try with a VPN connected and not connected both. ( you can also try this software, connect it and try:https://developers.cloudflare.com/warp-client/get-started/macos , it works for me on several network related issues on M1 chip macbook)
Try this command:
gem install cocoapods --source http://rubygems.org
What does it mean and how can I fix it:
pod install
/Library/Ruby/Site/2.0.0/rubygems.rb:250:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:278:in `activate_bin_path'
from /usr/local/bin/pod:22:in `<main>'
Using following commands, it worked for me.
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
cocoapods pod install
If you encounter this error on step 2:
ERROR: While executing gem ... (Gem::CommandLineError) Please specify at least one gem name (e.g. gem build GEMNAME)
Then try this as step 2 instead (step 3 is not needed):
gem install -n /usr/local/bin cocoapods
If you install cocoapod using brew like me
Reinstall cocoapods:
brew reinstall cocoapods
If you see this error message after you reinstall cocoapods by brew reinstall go to step 2.
>
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
rm '/usr/local/bin/pod'
To force the link and overwrite all conflicting files:
brew link --overwrite cocoapods
To list all files that would be deleted:
brew link --overwrite --dry-run cocoapods
Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj
To solve conflicting files:
brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.3.1... 2 symlinks created
Uninstall the existing cocoapods, if any, by following command:
gem list --local | grep cocoapods | awk '{print $1}' | xargs sudo gem uninstall
Then install it to /usr/local/bin instead of /usr/bin using following command:
sudo gem install -n /usr/local/bin cocoapods
For further query, check this link to uninstall and this link to install cocoapods.
In my case nothing helped, then I:
sudo gem uninstall cocoapods
cd /Users/nikkov/.rvm/rubies/ruby-2.4.1/lib/ruby; In Finder I searched for cocoapods and removed everything.
brew install cocoapods
brew link --overwrite cocoapods (if needed)
I had upgraded my ruby version 2.5.3 to 2.7.2. Then, I want to update cocoapods from 1.9.3 to 1.10.0 . I got the following error while executing pod install.
can't find gem cocoapods (>= 0.a) with executable pod
(Gem::GemNotFoundException)
There is two way to install cocoapods by using homebrew & gem. If you had install cocoapods using gem run following.
sudo gem uninstall cocoapods
sudo gem uninstall -n /usr/local/bin cocoapods
If you had used brew please using the following to uninstall
brew uninstall cocoapods
If you forgot which one you used earlier, please execute both commands. Please make sure all cocoapods instances are removed to check run pod --version.
If you find -bash: pod: command not found as output, all instances are removed properly. Else, you may need to remove cocoapods related files manually from this directory ~/.rvm/rubies/ruby-2.5.3/lib/ruby.
sudo gem update --system
gem install cocoapods
CREDIT: https://blog.csdn.net/develop_csdn/article/details/105053383
Thankfully i found solution after a hours.
As you know, newest Mac Operation System(Big Sur or oldest one) use ruby as a version system. So this ruby is private. You can not write/update some files that belong ruby.
So, we had a change to install rbenv for as a version control.
Firstly you should install rbenv via brew if you don't have
$ brew install rbenv
You need to know rbenv version number. You can see with below code snipped
$ rbenv version
Install Xcode's command line tools
xcode-select --install
Install rbenv via Homebrew
brew update
brew install rbenv ruby-build
Configure rbenv
eval "$(rbenv init -)"
Install and configure Ruby
rbenv install 3.1.1
rbenv global 3.1.1
rbenv rehash
source ~/.bash_profile
Install Cocoapods:
gem install cocoapods
In my case the reason of the issue was Gemfile file inside the folder with the project. When I removed this file, cocoapods started functioning as usual.
Try sudo gem update
After remove cocoapods
-Install cocoapods
When I tried #Aamir's solution, I ran into the error:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (https://api.rubygems.org/specs.4.8.gz)
This worked for my Mac:
sudo gem uninstall cocoapods
sudo gem install cocoapods
What finally worked for me was running rvm reset before reinstalling cocoapods
rvm reset
rvm --version
sudo gem install -n /usr/local/bin cocoapods
from here
In my case I was not able to install pod and cocoapods using gem, after changing command line tools I was able to run the commands
Running these commands worked for me:
brew update
brew install fastlane
fastlane install_plugins
React native has made several changes and this is how you install pods now
cd ios
bundle install
bundle exec pod install
https://reactnative.dev/docs/environment-setup
This helped me after I tried all these ways
xcode-select --install
If anyone stumbles upon this as a result of updating to react native 0.67.2+ from an older version (we were on 0.66.0) you have to make sure you re-install cocoapods via gem install cocoapods. Otherwise, your pod install will not work.
I'd installed Cocoapods using gem, so I reinstalled it again using gem. nothing happened.
so I removed it and install it using brew. it works.
I have also wrote on github, so I will copy it here, maybe it will be helpful for someone.
To be honest none of those solutions worked for me, just typing randomly commands will not help.
I don't know why, but my path was misconfigured. So first you should check if the path is good. I have used brew and installed rbenv in order to use safely libraries and after I ran pod install, I saw it was not targeting the right folder and always used the system version.
After I ran command
gem env
I saw that some paths are not correct.
"INSTALLATION DIRECTORY, RUBY EXECUTABLE, EXECUTABLE DIRECTORY, SYSTEM CONFIGURATION DIRECTORY AND GEM PATH"
should start something like this(depends of version) /Users/{username}/.rbenv/versions/3.1.2/lib/ruby/. ... otherwise it uses system version..
In order to fix this you need to set paths in ~/.zshrc and ~/.zprofile
my zshrc looks like this:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH=/opt/homebrew/bin:$PATH
export RBENV_ROOT=$HOME/.rbenv
export PATH=$RBENV_ROOT/shims:/versions:$PATH
zprofile:
eval $(/opt/homebrew/bin/brew shellenv)
in order to change /.zshrc: type nano ~/.zshrc
To relink, run:
brew unlink cocoapods && brew link cocoapods
So when I try running bundle install --without production it tells me that I am getting an error and that I need to Make sure that gem install unf_ext -v 0.0.7.2 succeeds before bundling. I have not gotten this error before while installing other gems, but only when I try and install gem stripe(which is used for receiving user payments and such).
Could someone explain what could be causing this kind of problem. All help is greatly appreciated.
Thanks,
-Aaron
EDIT
What I did to solve my problems was updating all of my gems to their current and latest version. Then when I ran bundle install --without production everything seemed to install perfectly fine after that.
This error can come across due to various reasons, so it's not easy to tell what might have really caused, preventing you from bundle install, so try the following fixes, if not worked please give more details on errors that appears :)
If the error was because of missing gmkdir, then run the following command:
brew install coreutils
If the error was due to missing C++ headers related then run the bellow command:
yum install gcc-c++
Also have a look at the developer's home page given below to check you meet all dependencies required:
unf_ext 0.0.7.2 : Unicode Normalization Form support library for CRuby
After updating to Mojave MacOS version, the ruby 'lost' the reference.
To solve
$ rvm list
In my case, the version listed was:
ruby-2.5.1 [ x86_64 ]
$ rvm use ruby-2.5.1
to change to 'current' version used
$ rvm list again
to see the current version
=> ruby-2.5.1 [ x86_64 ]
After that everything are okay running bundle install or bundle update or gem install or gem update
I just have the same problem when i try to install vagrant plugin, you need to install ruby-devel before.
Hope this help you.
I ran into this deploying to a remote box. As suggested in comments, I was able to fix it by opening a console session on the affected box and running:
gem update rails
gem install unf_ext -v '0.0.7.2'
And I was then able to deploy successfully.
I resolved this issue by upgrading bundler. Simply run:
gem install bundler
which fetches the latest bundler. Then, try running:
bundle install
I got same problem. It happens after I upgrading my macOS to newer version.
Somehows, upgrading mess up /usr/local/include. So that I removed it and run install. It worked
sudo mv /usr/local/include/ /usr/local/include.delete_me
Similar to the comment of Luke, xcode-select did the job for me. But instead of switching it to a different location, I just reverted the selected version to default, although I cannot remember to ever have changed it.
sudo xcode-select -r
After that bundle install and bundle update worked fine for me again.
I was having the exact same issue trying to install this specific gem and version as well. Turns out my VPS would run out of RAM while compiling and quit. I just killed off a few processes I could live without for a few minutes and it worked...
I solved this issue by running
sudo xcodebuild -license
I was working with docker and docker compose. similar issue arised to me. I deleted the image, removed all associated containers with the application and rebuilt the image with docker build . created the container with docker-compose up inside the working directory and it started working. this solution is specific to those using docker and docker-compose. Hope it helps someone. I am still not sure about the reason why is this happening.
this can be solved installing ruby-dev
and then gem install unf_ext -v 0.0.7.2
I ran into this issue getting
Installing unf_ext 0.0.8 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/jfn0296/.rvm/gems/ruby-3.0.0/gems/unf_ext-0.0.8/ext/unf_ext
/Users/jfn0296/.rvm/rubies/ruby-3.0.0/bin/ruby -I /Users/jfn0296/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0 -r
./siteconf20220120-59736-elnfu0.rb extconf.rb
checking for -lstdc++... yes
creating Makefile
current directory: /Users/jfn0296/.rvm/gems/ruby-3.0.0/gems/unf_ext-0.0.8/ext/unf_ext
make "DESTDIR=" clean
current directory: /Users/jfn0296/.rvm/gems/ruby-3.0.0/gems/unf_ext-0.0.8/ext/unf_ext
make "DESTDIR="
compiling unf.cc
make: *** [unf.o] Error 1
make failed, exit code 2
After trying many of these listed, using rvm I uninstalled and reinstalled my ruby-3.0.0 and tried bundling again and this time it worked. Did not see a solution like that here so I thought I'd share.
The Background
I am somewhat new to Unix coming from a .NET environment but I know enough now to get me in trouble.
I got an existing code I am working with that uses Cocoapods so I tried to install Cocoapods.
Initially when I installed it it failed saying it requires a newer version of Ruby.
To install Ruby I used an installer called rvm. With some effort I got RVM installed and got Ruby Version 2.1.0.
When I go to directory where the app is and i type pod install it responds with pod: command not found. The assumption is that there must be something wrong with the install of cocoa pods. If I try any command to install or uninstall Cocoapods
gem install cocoapods or gem uninstall cocoa pods
it returns the same response which is:
/Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:59:in `gem': uninitialized constant Gem::LOADED_SPECS_MUTEX (NameError)
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:46:in `require'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems.rb:601:in `load_yaml'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:328:in `load_file'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:197:in `initialize'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/bin/gem:21:in `<main>'
I am thinking that perhaps the failed attempts to install cocoa pods may have either corrupted something, put something in the wrong place. I want to completely uninstall cocoapods and reinstall it but install and uninstall are not doing anything.
UPDATE: Using gem list --local | grep cocoa pods just to see what version of CocoaPods I have installed gives me the same exact output.
The Question:
Does anyone know a way to either fix this issue or completely rip and rebuild CocoaPods?
I was brilliantly assisted with help from #Pedros (the currently accepted answer) but because there were so many comments back and forth I decided to clean up the answer that worked for me. I will keep his as the accepted answer since he really helped me tremendously on this one. If this is helpful to you and you choose to up vote, please also up vote the accepted answer since this is derived almost completely from his answer.
Here is what I found out :
In my case it was that RVM was not installed correctly so RubyGems wasn't installed correctly. That in turn made CocoaPods not install correctly.
To completely uninstall and remove RVM: try sudo rvm implode or you can do sudo rm -rf ~/.rvm
I did some checks to see if I had the correct versions. I will post what they should be right now but this can be different as versions keep getting updated.
ruby --version should be 2.1.2
which ruby should be the RVM ruby. (To see if there is no conflict with OSX`s ruby)
gem --version should be 2.2.2
Reinstall RVM by doing this: \curl -sSL https://get.rvm.io | bash -s stable --ruby
Reinstall CocoaPods like this: gem install cocoapods
I hope this saves someone some development hours and hair loss :)
gem env will tell you the installation path of your gems.
By the error you got on the first time you installed the gem it could be a PATH error. Maybe your gems folder is not properly set in the PATH and shell is not finding Cocoapods.
Try to print your PATH with echo $PATH and see if the - EXECUTABLE DIRECTORY: from gem env is there.
Also try gem pristine --all
If that doesn't work try to change to ruby 2.1.2 and reinstall cocoapods.
Try bundle install first, then you can run pod install again.
After updating to OS X 10.9 Mavericks I tried to start a Rails 3 app, but the connection to the PG database was not working. Checking on PGAdmin III, the database is still there and it works fine.
So I tried to reinstall the pg gem:
gem uninstall pg
gem install pg
But the last command doesn't succeed, and gives the following error:
Building native extensions. This could take a while... ERROR: Error
installing pg:
ERROR: Failed to build gem native extension.
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for pg_config... yes Using config values from
/usr/local/bin/pg_config
* extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check
the mkmf.log file for more details. You may need configuration
options.
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in
`try_do': The compiler failed to generate an executable file.
(RuntimeError) You have to install development tools first. from
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in
try_link0' from
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in
try_link' from extconf.rb:39:in `'
I guess the problem is related to the Xcode developer tools. I updated Xcode to the latest version, but that didn't solve the problem. Do you know how to fix it?
You're right that the problem is related to the Xcode developer tools. It's not a bad idea to make sure you have all the developer tools installed (as opposed to solely installing gcc as mentioned in the previous answer):
Open up Xcode
In the application menu item "Xcode" select Open Developer Tool > More Developer Tools...
This takes you to a site with a bunch of software. Go ahead and download and install "Command Line Tools (OS X Mavericks) for Xcode - Late October 2013".
You will now be able to properly install the gem.
For anyone else coming to this issue off of a fresh install of the Postgres 9.3.0 app on Mac OS X Mavericks (i.e. you're not using homebrew for your Postgres installation) you may notice that even though you can build the pg gem you cannot run rake because of a dylib issue:
rake aborted!
dlopen(/Users/[USERNAME]/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/pg-0.15.1/lib/pg_ext.bundle, 9): Library not loaded: #loader_path/../lib/libpq.5.dylib
Referenced from: /Users/[USERNAME]/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/pg-0.15.1/lib/pg_ext.bundle
Reason: image not found - /Users/[USERNAME]/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/pg-0.15.1/lib/pg_ext.bundle
Unfortunately this is a problem with the current release version of 9.3.0 of Postgres. Winding back to a previous version will fix it for you:
uninstall the pg gem: gem uninstall pg
delete your 9.3.0 Postgres app by dragging it to the trash and emptying the trash
install version 9.2.2.0 of the Postgres app here: http://postgres-app.s3.amazonaws.com/PostgresApp-9-2-2-0.zip
reinstall the pg gem: gem install pg
*Thanks to the comment by jhiro009 on this thread for pointing me in the right direction on this last Postgres app part of the issue although the 9.2.4.3 version that he mentioned didn't work for me.
Using homebrew fixed this for me:
gem uninstall pg
brew install apple-gcc42
gem install pg
EDIT: I also manually installed "devtools"
xcode-select --install
On OS X Mavericks
sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2
gem uninstall pg; gem install pg;
works with homebrew Postgresql (9.3.1) installation and Apple Command Line Tools installed (pg 0.17.0).
None of the previous solutions worked for me (I just upgraded to Mavericks and updated XCode). Instead, I installed Postgress.app. and called
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
None of the solutions worked for me, and I didn't want to use MacPorts. Try and download the Postgres App and put it into the Application directory.
Then, specify the location of newly downloaded pg_config, which resides inside the app:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
If you run in to missing headers problem, try specifying the include directory of the app:
gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/MacOS/include/'
If you are looking for just a quick fix, add the following to your database.yml file:
host: localhost
I had the exact problem, added that line, and now all is well.
I had luck following this post from the guys at New-Bamboo:
3 Quick Tips for Coding with OS X 10.9 Mavericks
After installing the xcode dev tools, the third step sorted everything out:
brew tap homebrew/versions && brew install apple-gcc42
brew link --force apple-gcc42
ln -nsf $(which gcc-4.2) /usr/bin/gcc-4.2
I had this problem the first time I tried to install pg. Through various trials and errors I found something that worked. Thankfully, my notes also worked when Mavericks broke everything.
Hope this helps:
Do not do any brewing.
download the enterpriseDB one-click installer, mount and run.
If it doesn't work, run it through the command line (unattended mode) and it will change the memory settings. Restart, run again.
Makes a user called postgres with the password you supply. Also installs pgadmin III.
run this in app directory:
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-include=/Library/PostgreSQL/9.2/include/ --with-pg-lib=/Library/PostgreSQL/9.2 sudo env ARCHFLAGS='-arch i386' gem install pg/lib/
Open pgadmin3 and create a user and password for rails, then add it to config.
psql [database_name] # to check on your db. Or use pgadmin III