React-Native init stuck when installing required cocoapods - react-native

I am trying to create a new project by using
react-native init <projectName>
But it's been stuck at this for 10min:
info Installing required CocoaPods dependencies
Before creating my project, I installed cocoapods using
sudo gem install cocoapods
Why is it getting stuck?

Installation
$ sudo gem install cocoapods
Sudo-less installation
If you do not want to grant RubyGems admin privileges for this process, you can tell RubyGems to install into your user directory by passing either the --user-install flag to gem install or by configuring the RubyGems environment. The latter is in our opinion the best solution. To do this open up terminal and create or edit your .bash_profile with your preferred editor. Then enter these lines into the file:
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
Note that if you choose to use the --user-install option, you will still have to configure your .bash_profile file to set the PATH or use the command prepended by the full path. You can find out where a gem is installed with gem which cocoapods. E.g.
$ gem install cocoapods --user-install
$ gem which cocoapods
/Users/eloy/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods.rb
$ /Users/eloy/.gem/ruby/2.0.0/bin/pod install
Updating CocoaPods
To update CocoaPods you simply install the gem again
$ [sudo] gem install cocoapods
Or for a pre-release version
$ [sudo] gem install cocoapods --pre

This command will get stuck if your internet connection is unstable. Make sure you have stable wifi when you create a react native project.

Related

Could not find 'ffi' (>= 1.3.0) among 85 total gem(s) (Gem::MissingSpecError) React native IOS on pod install

Hi I'm trying to run my react native app on mac mini. I can run another app also this app to but when i write pod install in terminal it gives this error.
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1449:in `block in activate_dependencies'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'ffi' (>= 1.3.0) among 85 total gem(s) (Gem::MissingSpecError)
Checked in
'GEM_PATH=/Users/xx/.gem/ruby/2.6.0:/Library/Ruby/Gems/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0', execute `gem env` for more information
I tryed a lot like this code
sudo gem pristine --all, gem pristine --all
sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
delete and ini pod init/ which gave error
brew reinstall cocoapods
\curl -sSL https://get.rvm.io | bash -s stable --ruby
You can try this command
sudo gem uninstall -aIx
rm -rf ~/.gem
sudo gem install cocoapods
sudo chown -R $USER ~/Library/Caches/CocoaPods
For me, install a new version of ruby resolved this issue.
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm list known
rvm install 2.7.2
sudo gem install cocoapods
Same issue. Just updating gem package manager is works for me
gem update
Terminal will display installing 'ffi'
Successfully installed ffi-1.15.5
i solved the issue by installing the command line tool for XCode.
Just download the specific CLT from apple website
I just did a
bundle install
and that allowed me to do a pod install after upgrading (without asking me to Xcode 14).

cocoa pods error failed to build gem native extension on Mac

ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200728-45926-1h0nq8i.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/includ.e/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.18/gem_make.out
I'm just trying to install it and it doesn't work.
PS: I also already have cocoa pods. I am simply following the instructions on react native setting up your environment
The below steps would fix that issue:
Ensure ruby is installed and up to date: ruby -v
Update gem's sudo gem update --system
xcode-select --install
sudo gem install -n /usr/local/bin cocoapods
Solved it by updating the repo
sudo gem repo update

YAML safe loading is not available

When I want to install compass with gem install compass, I occurred with this error:
YAML safe loading is not available.
Please upgrade psych to a version that supports safe loading (>= 2.0).
what The cause of this error and how can I solve the problem?
It sounds like the psych gem needs to be updated. Try running gem install psych and then gem update psych.
Suggested by looking at the psych readme file here: https://github.com/ruby/psych/blob/master/README.md
EDIT: you might also have to update your version of ruby. This depends on how you have installed ruby, but #ewerx has one suggestion in their answer.
To resolve this I first upgraded Ruby from 2.0.x to 2.4.2 (https://gorails.com/setup/osx/10.12-sierra):
rbenv install 2.4.2;
rbenv global 2.4.2
Then updated gems:
sudo gem update --system;
gem update
It may be sufficient to just update gems.
The following part of the post on https://gorails.com/setup/osx/10.12-sierra solved my issue.
We will be setting up a Ruby on Rails development environment on macOS 10.12 Sierra.
Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them.
Installing Homebrew
First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source.
Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes.
Open Terminal and run the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
Choose the version of Ruby you want to install:
Now that we have Homebrew installed, we can use it to install Ruby.
We're going to use rbenv to install and manage our Ruby versions.
To do this, run the following commands in your Terminal:
brew install rbenv ruby-build
Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
Install Ruby
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v

Cannot install cocoapods 0.29

I successfully install cocoapods 0.29, and after attempting to run pod setup, it claims I must install 0.29.
Can someone please explain this to me??
Successfully installed cocoapods-0.29.0
Parsing documentation for cocoapods-0.29.0
1 gem installed
bash-3.2$ pod setup
Setting up CocoaPods master repo
Already up-to-date.
[!] The `master` repo requires CocoaPods 0.29.0 -
Update CocoaPods, or checkout the appropriate tag in the repo.
UPDATE:
After updating cocoapods, I am able to run pod setup, however still getting some error about 0.29 not being installed: (And also, when running pod --version, it says I'm on 0.22.3???)
bash-3.2$ sudo gem update cocoapods
Updating installed gems
Nothing to update
bash-3.2$ sudo pod setup
Setting up CocoaPods master repo
Already up-to-date.
Setup completed (read-only access)
bash-3.2$ pod install
Setting up CocoaPods master repo
Already up-to-date.
[!] The `master` repo requires CocoaPods 0.29.0 -
Update CocoaPods, or checkout the appropriate tag in the repo.
/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/claide-0.3.2/lib/claide/command.rb:210:in `rescue in run': undefined method `verbose?' for nil:NilClass (NoMethodError)
bash-3.2$ pod --version
0.22.3
navigate this file and delete it
/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/claide-0.3.2/lib/claide
then open ur terminal add this
sudo gem update
its worked for me 100%
Based on your comment
$ type -a pod
pod is /Users/me/.rvm/gems/ruby-2.0.0-p247/bin/pod
pod is /Users/me/.rvm/rubies/ruby-2.0.0-p247/bin/pod
pod is /usr/bin/pod
it appears you have multiple installations of Cocoapods: one with gem install cocoapods in /Users/me/.rvm/gems/ruby-2.0.0-p247/bin/pod and another with sudo gem install cocoapods in /usr/bin/pod (I don't know what /Users/me/.rvm/rubies/ruby-2.0.0-p247/bin/pod is).
So running gem install cocoapods should fix the problem by updating the install in /Users/me/.rvm/gems/ruby-2.0.0-p247/bin/pod.
I'd recommend cleaning up your install though by removing either the global (with sudo) one or the local (without sudo) one.
EDIT:
Here's my Jenkins install:
Installed Cocoapods with gem install cocoapods.
Running type -a pod yield:
$ type -a pod
pod is /Users/Shared/Jenkins/Home/gems/bin/pod
In the Jenkins global config, I added the following environment variables:
GEM_HOME = $JENKINS_HOME/gems
GEM_PATH = $JENKINS_HOME/gems:/usr/lib/ruby/gems/1.8/
PATH = $PATH:$HOME/gems/bin
I added a "Shell script" build step to each project with:
POD_PROJECT_DIRECTORY='MyProject' # Directory where the Podfile is. Probably the same as Xcode plugin's "Xcode Project Directory".
cd "$WORKSPACE/$POD_PROJECT_DIRECTORY"
# rm -rf ./Pods # Uncomment this line if you want to re-download all the Pods each time
pod install --no-color
I found the mismatch of version reported by 'pod --version' and what I was seeing when I updated to be mystifying. Then I realized I had more than one ruby installed on my machine. I changed my $PATH so that the ruby I needed to use came first (e.g. /usr/local/opt/ruby/bin):
In a new shell I found that 'pod --version' started reporting the '0.29.0' version I wanted.

Deploy Rails 3 with Phusion Passenger on Ubuntu WITH ALL GEMS INCLUDED

I need to deploy a Rails 3/Phusion Passenger/Apache2 app to an Ubuntu 12.04 server without installing ANY gems on the server.
I can install any Debian packages.
How can I include all needed gems (including Rails, a couple of gems installed from git projects on github, and a bunch of regular gems installed from rubygems.org) inside my project so that, after deployment, Passenger will find Rails and all the gems and be happy?
(I know many people will probably be curious WHY I would want to do this. I can't talk about that, unfortunately. Sorry.)
Here are some things that have not worked. One of them might work if revised a little, I don't know:
Failed method 1:
On Ubuntu 12.04 dev machine. Ruby 1.9.3. Bundler 1.3.5. bundle package --all. Git commit.
On Ubuntu 12.04 server machine (gem installation from Internet not possible). Deploy project files and install packages (apache2, ruby1.9.3, ruby-bundler, rubygems, libapache2-mod-passenger which brings ruby1.8 with it). bundle -v gives Bundler version 1.0.15 (from ruby-bundler package). Make sure .bundle/config file from dev machine is also deployed. bundle install --local tries to download git gems from github, so fail.
Try using bundle package --all, which should save your gems into ./vendor/cache. You could also unpack the gems on your local environment with gem unpack --target vendor to save them in the vendor directory. Then you can give a location in the Gemfile so that your application can find the gems. Can you just not use the network to install gems, or are you really not allowed to install gems in any way?
Sources:
1,
2
Try using the pkgr tool, which can convert your Rails app and all dependencies into a single installable Debian package.
Download the bundler 1.3.5 gem from http://rubygems.org/downloads/bundler-1.3.5.gem and put it in vendor/
In an Ubuntu 12.04 vm, do bundle package --all. Git commit and push.
Clone on the Ubuntu server.
apt-get install each of apache2, ruby1.9.3, etc. (not rubygems or ruby-bundler. Both provide an old version of Rubygems and Bundler. A newer version of rubygems is included in the ruby1.9.3 package.)
Follow ALL of the instructions in section 2.3 at http://www.modrails.com/documentation/Users%20guide%20Apache.html#install_on_debian_ubuntu
Make sure you have the right Ruby and Rubygems versions set to the ruby and gem commands:
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.3 200
update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.9.3 200
(Phusion Passenger doesn't care about this, but it's probably a good idea for the gems we are about to install and for debugging stuff with the Rails console or whatever in the future.)
gem install --local vendor/bundler-1.3.5.gem
bundle install --local
Set up all your other Apache config...
service apache2 restart