React Native init fails on cocoapods install - ruby

I am facing a rather strange bug. If I react-native init through my terminal, cocoapods installs fine.
If I init a new project through vscode's integrated terminal, I get this error during pod install:
For help, see: https:/nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
[!] Invalid `Podfile` file: 859: unexpected token at ''.
# from /Users/XXXXX/Documents/test/ios/Podfile:7
# -------------------------------------------
# target 'test' do
> config = use_native_modules!
#
# -------------------------------------------
I have verified that my LANG variable is the same on both terminals: en_US.UTF-8
Ruby version: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21]
Cocoapods version: 1.11.3
I have tried installing ruby through brew, rbenv, rvm. The problem remains on all three.
I am on MacOS Monterey 12.1 on M1.

Related

Xcode Cloud error - `Invalid `Podfile` file: cannot load such file -- cocoapods-catalyst-support`

I encountered this error
2023-01-24T22:14:41.500565325Z Installing ri documentation for cocoapods-catalyst-support-0.2.1
2023-01-24T22:14:41.500827390Z Done installing documentation for colored2, concurrent-ruby, i18n, tzinfo, zeitwerk, activesupport, nap, fuzzy_match, httpclient, algoliasearch, ffi, ethon, typhoeus, netrc, public_suffix, addressable, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-trunk, cocoapods-try, molinillo, atomos, nanaimo, rexml, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods, cocoapods-catalyst-support after 50 seconds
2023-01-24T22:14:41.500997230Z 35 gems installed
2023-01-24T22:14:42.023353910Z [in /Volumes/workspace/repository]
2023-01-24T22:14:42.023798292Z
2023-01-24T22:14:42.024448317Z [!] Invalid `Podfile` file: cannot load such file -- cocoapods-catalyst-support.
2023-01-24T22:14:42.024714192Z
2023-01-24T22:14:42.024976712Z # from /Volumes/workspace/repository/Podfile:1
2023-01-24T22:14:42.025200239Z # -------------------------------------------
2023-01-24T22:14:42.025463448Z > require 'cocoapods-catalyst-support'
2023-01-24T22:14:42.025663811Z #
2023-01-24T22:14:42.025900158Z # -------------------------------------------
from my post-clone script in the Xcode Cloud temporary build environment, which is
#!/bin/sh
# ci_post_clone.sh
export GEM_HOME="$HOME/.gem"
gem install bundler
brew install cocoapods
gem install cocoapods-catalyst-support
# Install dependencies managed with CocoaPods.
pod install

Invalid `Podfile` file: when I try run "pod install"

When I try to run “pod install" in the terminal, I get this same error for all my projects. Last time a complete brew update was performed.
robajz#Roberts-MacBook-Pro ios % pod install
[!] Invalid `Podfile` file:
[!] Invalid `RNGestureHandler.podspec` file: undefined method `exists?' for File:Class.
# from /Users/robajz/Projects/shop8-mobile-app/node_modules/react-native-gesture-handler/RNGestureHandler.podspec:5
# -------------------------------------------
#
> isUserApp = File.exists?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
# if isUserApp
# -------------------------------------------
.
# from /Users/robajz/Projects/shop8-mobile-app/ios/Podfile:10
# -------------------------------------------
# target 'Shop8App' do
> config = use_native_modules!
#
# -------------------------------------------
So after much pain, i found that if I added this line into the .podspec where the error was coming from
print RUBY_VERSION
It was printing out 3.2.0 which I believe has deprecated the "exists" method as mentioned in the error, but I was using a .ruby-version file and rbenv as suggested in the docs and ruby -v was printing out 2.7.5 as expected.
After hunting through my file system to find where this v3.2.0 could possibly be installed I tried downgrading cocoapods from 1.11.3 -> 1.11.2 and it instantly solved my issue and the print in the podspec was now printing 2.7.5

bundle failed whit exit code 16, jekyll-theme-chirpy build error

I want to apply this theme, but there is an error while building it.
It works in local, but it doesn't build.
https://github.com/rubygems/bundler/issues/4375
I saw it through this link, but I don't know how to match it because the server also says that using a fixed version of the bundler is the solution.
Error: The process '/opt/hostedtoolcache/Ruby/3.1.2/x64/bin/bundle' failed with exit code 16
at ExecState._setResult (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:6023:25)
at ExecState.CheckComplete (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:6006:18)
at ChildProcess.<anonymous> (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:5900:27)
at ChildProcess.emit (node:events:390:28)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
$ which jekyll
>>> /Users/GyeongminKim/.rbenv/shims/jekyll
$ which gem
>>> /Users/GyeongminKim/.rubies/ruby-3.1.2/bin/gem
$ which bundle
>>> /Users/GyeongminKim/.rubies/ruby-3.1.2/bin/bundle
$ bundle version
>>> Bundler version 2.3.7 (2022-09-15 commit unknown)
$ ruby --version
>>> ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
I was getting the same error. This command helped me to resolve my issue:
bundle lock --add-platform x86_64-linux
source

GitLab CI error: gem install bundler on MacOS

Using MacOS-10.14.3, there is a problem with my GitLab CI for an iOS project (using fastlane):
I try to create a gitlab-runner on my Mac and I get quite far with it, except the following error message occurs during CI-failure:
It seems that the error happens at the before_script for some reason.
Any idea what could be wrong here ?
From the fastlane page, I follow these instructions: Link
The Gitlab error seems to be related to a Ruby issue on Mac
I followed this suggestion here: I tried to re-install ruby, doing the following in a Terminal:
brew install ruby
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
But that did not help anything...
In case, interested, finding out what ruby is on my Mac:
ruby -v
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
which ruby
/usr/local/opt/ruby/bin/ruby
I use docker with image alpine:latest and I run my gitlab-runner from a Mac-Terminal with the following command:
sudo gitlab-runner run
Here is my Gemfile:
source 'https://rubygems.org'
gem 'fastlane'
gem 'cocoapods'
...and here is my gitlab-ci.yml file:
stages:
- unit_tests
- test_flight
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
before_script:
- gem install bundler
- bundle install
unit_tests:
dependencies: []
stage: unit_tests
artifacts:
paths:
- fastlane/screenshots
- fastlane/logs
script:
- fastlane tests
tags:
- ios
test_flight_build:
dependencies: []
stage: test_flight
artifacts:
paths:
- fastlane/screenshots
- fastlane/logs
script:
- fastlane testflight
tags:
- ios
only:
- /^release-.*$/
- master
Any idea on how to change this GitLab CI File (or do anything else) so that this annoying gem install bundler error goes away ?? Any help appreciated.

Ruby and compass path with yeoman project

I installed ruby, yeoman, and when I run my project, I have this error:
Warning: Running "compass:dist" (compass) task
Warning: You need to have Ruby and Compass installed
this task to work. More info: https://github.com/gru
Use --force to continue. Use --force to continue.
I have the path into the variable session target, but it doesn't work. Can anyone help me?
I had to run this:
gem install compass
Found here: Angular with Yeoman 1.0 and Grunt
(I thought I had Compass installed by following the instructions here but it wasn't sufficient.)
The problem comes from compass being called compass2.0
I solved the issue by symlinking compass to compass2.0
Here's the command: sudo ln -s /usr/bin/compass2.0 /usr/bin/compass
Hope this helps
I was getting the same error. Turns out it was masking the real error:
{ '0': [Error: Error: not found: bundle],
'1':
{ stdout: '',
stderr: 'Error: not found: bundle',
code: 127,
toString: [Function] },
'2': 127 }
Fixed with:
sudo gem install bundle --no-user-install
I had the same issue on Windows 7 too..
This is what I did.
Install Ruby with Ruby installer
Install the Compass with gem, (Installing the compass with npm didnt have any effect)
gem install compass

Resources