Skip to content

Instantly share code, notes, and snippets.

@hectorddmx
Last active October 25, 2023 16:39
Show Gist options
  • Save hectorddmx/805144a37c09d3cfe258783c9a9d7528 to your computer and use it in GitHub Desktop.
Save hectorddmx/805144a37c09d3cfe258783c9a9d7528 to your computer and use it in GitHub Desktop.
Remove homebrew cocoapods installation in catalina, and install directly from gem, zsh version
#! /bin/zsh
install_cocoapods () {
echo "Installing cocoapods with gem"
# Creating new gems home if it doesnt't exist
if [ ! -d "$HOME/.gem" ]; then
mkdir "$HOME/.gem"
fi
# Adding to current session
export GEM_HOME="$HOME/.gem"
export PATH="$GEM_HOME/bin:$PATH"
# Adding for future sessions
if test -f "$HOME/.zshrc"; then
echo 'Adding $GEM_HOME env var and then adding it to your $PATH'
echo '' >> "$HOME/.zshrc"
echo 'export GEM_HOME="$HOME/.gem"' >> "$HOME/.zshrc"
echo 'export PATH="$GEM_HOME/bin:$PATH"' >> "$HOME/.zshrc"
fi
# Installing cocoapods
gem install cocoapods
which pod
pod --version
}
uninstall_cocoapods_homebrew () {
which -s brew
if [[ $? != 0 ]] ; then
echo "Homebrew not installed, skipping uninstalling cocoapods from homebrew"
else
brew uninstall cocoapods
fi
}
if ! type "pod" > /dev/null; then
echo "You don't have cocoapods installed..."
else
echo "Trying to uninstall it from homebrew first"
uninstall_cocoapods_homebrew
fi
install_cocoapods
@kernelogic
Copy link

Trying to uninstall it from homebrew first
/usr/local/bin/brew -> /usr/local/Homebrew/bin/brew
Uninstalling /usr/local/Cellar/cocoapods/1.10.1... (13,132 files, 30.4MB)
Installing cocoapods with gem
Adding $GEM_HOME env var and then adding it to your $PATH
Fetching ffi-1.14.2.gem
Fetching ethon-0.12.0.gem
Fetching typhoeus-1.4.0.gem
Fetching netrc-0.11.0.gem
Fetching cocoapods-core-1.10.1.gem
Fetching public_suffix-4.0.6.gem
Fetching addressable-2.7.0.gem
Fetching claide-1.0.3.gem
Fetching cocoapods-deintegrate-1.0.4.gem
Fetching cocoapods-downloader-1.4.0.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching cocoapods-search-1.0.0.gem
Fetching cocoapods-trunk-1.5.0.gem
Fetching cocoapods-try-1.2.0.gem
Fetching molinillo-0.6.6.gem
Fetching atomos-0.1.3.gem
Fetching cocoapods-1.10.1.gem
Fetching colored2-3.1.2.gem
Fetching nanaimo-0.3.0.gem
Fetching xcodeproj-1.19.0.gem
Fetching escape-0.0.4.gem
Fetching fourflusher-2.3.1.gem
Fetching gh_inspector-1.1.3.gem
Fetching ruby-macho-1.4.0.gem
Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
	ERROR: Failed to build gem native extension.

    current directory: /Users/feiya200/.gem/gems/ffi-1.14.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210304-70399-l2ualq.rb extconf.rb
*** 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.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
	--with-ffi_c-dir
	--without-ffi_c-dir
	--with-ffi_c-include
	--without-ffi_c-include=${ffi_c-dir}/include
	--with-ffi_c-lib
	--without-ffi_c-lib=${ffi_c-dir}/lib
	--enable-system-libffi
	--disable-system-libffi
	--with-libffi-config
	--without-libffi-config
	--with-pkg-config
	--without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in `block in try_link0'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:672:in `try_ldflags'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1832:in `pkg_config'
	from extconf.rb:9:in `system_libffi_usable?'
	from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/feiya200/.gem/extensions/universal-darwin-19/2.6.0/ffi-1.14.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/feiya200/.gem/gems/ffi-1.14.2 for inspection.
Results logged to /Users/feiya200/.gem/extensions/universal-darwin-19/2.6.0/ffi-1.14.2/gem_make.out
pod not found
install_cocoapods:22: command not found: pod

@kingkarki
Copy link

how to use it?

@thiago7almeida
Copy link

thiago7almeida commented Dec 7, 2022

it worked for me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment