Use Sudo for Gem Install Cocoapods

Use sudo for gem install cocoapods

It seems you are not using any package manager. Since, you don't have write permission to this directory, there is nothing wrong in using sudo for gem install.

However, I prefer changing ownership of that directory, so that I don't have to use sudo every time.

i.e. sudo chown -R [login name] /Library/Ruby/Gems/2.0.0

and ensure that I have write permission. sudo chmod -R u+w /Library/Ruby/Gems/2.0.0

Consider using rvm (ruby version manager) or rbenv

Do I need to type every time : sudo gem install cocoapods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.

If you don't have installed cocoa pods earlier, to install cocoa pods into your machine execute the following command.
sudo gem install cocoa pods

To add the installed dependency manager to your project use the following command.
pod init.

This will create a file called podfile in your project directory. Include the dependencies in the file appropriately and execute pod install to install the dependencies.

Error installing cocoapods sudo gem install cocoapods MacOs Catalina

Seems like you don't have access to usr/bin directory. i have been there!!

please try below command.

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

this should work. Thanks!!

Please refer this post more information about access rights.

How to run CocoaPods on Apple Silicon (M1)

EDIT: I recently disabled Rosetta, and Cocoapods runs just fine with the addition of the ffi gem.

For anyone else struggling with this issue, I just found a way to solve it. In addition to running terminal in Rosetta:

  1. Right-click on Terminal in Finder
  2. Get Info
  3. Open with Rosetta

I installed a gem that seems to be related to the symbol not found in the error:

sudo gem install ffi

After doing this, cocoapods runs as expected.

Errors when installing cocoapods with gem

The answer for this can be found here here although it is unrelated to this question. Below is a snippet of the answer which works best.

For Xcode 11 on macOS 10.14, this can happen even after installing Xcode and installing command-line tools and accepting the license with

sudo xcode-select --install
sudo xcodebuild -license accept

The issue is that Xcode 11 ships the macOS 10.15 SDK which includes headers for ruby2.6, but not for macOS 10.14's ruby2.3. You can verify that this is your problem by running

ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

which on macOS 10.14 with Xcode 11 prints the non-existent path

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

However, Xcode 11 installs a macOS 10.14 SDK within /Library/Developer/CommandLineTools/SDKs/MacOS10.14.sdk. It isn't necessary to pollute the system directories by installing the old header files as suggested in other answers. Instead, by selecting that SDK, the appropriate ruby2.3 headers will be found:

sudo xcode-select --switch /Library/Developer/CommandLineTools
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

This should now correctly print

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

Likewise, gem install should work while that SDK is selected.

To switch back to using the current Xcode 11 SDK, use

sudo xcode-select --switch /Applications/Xcode.app

Error To set up CocoaPods for ARM macOS, run: arch -x86_64 sudo gem install ffi Unable to solve error

Run this commands in terminal

arch -x86_64 sudo gem install ffi

Then inside the ios folder of your project run this command

arch -x86_64 pod install

How can solve this problem? Error: To set up CocoaPods for ARM macOS, run: arch -x86_64 sudo gem install ffi

try with this

sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc

source

sudo gem install cocoapods --pre error

What the error says is that you can't write to: /usr/bin. Try this and see if it makes any difference:

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


Related Topics



Leave a reply



Submit