Error installing CocoaPods - macOS BigSur - xcode

I'm learning how to program, and I am trying to install Cocoapods, but I'm getting an error with sudo gem install cocoapods.
This is what I get:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/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 ./siteconf20201006-615-fryp4a.rb extconf.rb
checking for ffi.h... *** 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:585:in `block in try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header'
from extconf.rb:10: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:
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.13.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.13.1/gem_make.out
I know that there is a line where it says "You have to install development tools first", and at first it was true. I then installed the Xcode command line tools (I had to do it manually downloading it from Apple Developer because the xcode-select --install line didn't work), and tried to install cocoapods again. But I'm getting the same error, even after rebooting.
It also has the route for the log, and this is what it says:
package configuration for libffi is not found
"xcrun clang -o conftest -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -DUSE_FFI_CLOSURE_ALLOC conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.Internal.sdk/usr/local/lib -lruby.2.6 "
In file included from conftest.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks')
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
So, I'm stuck.
I'm currently using macOS Big Sur Beta 9, and Xcode 12.0.1 (non-beta).

I had the same issue (Catalina 10.15.7 & Xcode 12.3).
I used homebrew instead of the gem:
brew install cocoapods

XCode's ruby framework appears to have a problem. Reinstall Xcode.app cleanly with the latest version and running xcode-select --install or --select did not work for me.
This is how I managed to make it run with XCode 12.2 and Catalina (10.15.7): https://stackoverflow.com/a/65481787/1534182
TL;DR)
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby
ln -sf ../../../../Headers/ruby/config.h
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
ln -sf universal-darwin20 universal-darwin19
(edit fixed typo in symlink)

Solve by upgrading Xcode to 12.2 on macOS Big Sur.
Then run:
sudo gem install -n /usr/local/bin cocoapods
Wasted 5 hours because I thought it was a gem's issue.

or if you already installed the cocoa pods just run
brew install cocoapods
after its showing some warning message
Warning: cocoapods 1.10.1 is already installed, it's just not linked.
To link this version, run:
brew link cocoapods or
brew link --overwrite cocoapods
it was really helpful for me. thank you

Well, today I was able to finally install Cocoapods successfully, but it was a weird process.
When learning people usually tell you to stay away from betas, and while I was in the stable AppStore-version of Xcode, I was running Big Sur B9; and that could have been the problem.
I completely uninstalled Xcode 12.0.1 and then downloaded from Apple Developer Xcode 12.2 beta. I then downloaded and installed the command line tools also for 12.2 beta, and ran again the cocoapods installation in Terminal… and voila!
After installing and running Xcode beta I was able to install and now works fine.
Maybe when BigSur becomes public this will be solved? Because not everyone needs or has to run Xcode beta versions.

I've faced the exact same issue
$ sudo gem install cocoapods
...
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.
...
Fixed by upgrading ruby version to 2.7.2.
Credits for https://stackoverflow.com/a/65033418/4982169
I use rbenv to manage ruby versions.

This worked for me:
https://github.com/CocoaPods/CocoaPods/issues/10286#issuecomment-747512270
Quote:
Download Command Line Tools 11.5 from Apple Developer Downloads
sudo rm -rf /Library/Developer/CommandLineTools
Install Command Line Tools from .dmg/.pkg
sudo xcode-select --switch /Library/Developer/CommandLineTools
[sudo] gem install [--user-install] cocoapods
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Above sols. might or might not work for everyone, but just make sure to cross check command line tools.. It must be set and not blank.

I had the same error over and over again and tried several ways to fix it, including many described here, with no success.
As explained here: https://developer.apple.com/forums/thread/668456
, depending on some aspects this might work for you as it did for me!
run sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
Apparently the later cocoapads versions,specially latest (1.11.2) wont work!

Switching the default Xcode command-line tools from version 12.4 to 11.7 solved this problem for me.
I have both Xcode versions installed on Catalina (10.15.7), so I made the switch using Xcode Preferences (Locations/Command Line Tools:), selecting "Xcode 11.7" in the popup menu. Then I quit Xcode and ran the install command again:
sudo gem install cocoapods
Where before I was getting the same "missing header" error, now the install proceeded without incident.
Command-line tools can be installed separately, without having to install Xcode itself. Then you would use Terminal to switch versions. The path to the current default tools is returned by
xcode-select -p
and switching versions is done using
sudo xcode-select -s {path-to-tools}
After installing CocoaPods I switched back to the latest command-line tools and did 'pod install' on one of my current projects, which succeeded without incident. So the earlier version seems necessary only for CocoaPods install, not its operation.

update the latest version ruby:
https://www.delftstack.com/howto/ruby/update-ruby-version-in-macos/
and check version ruby:
ruby -v
and then:
sudo gem install cocoapods

Related

Unable to install any Ruby with RVM on MacOS 10.14.2 Mojave: Error running '__rvm_make -j4'

After upgrading MacOS to 10.14.2 Mojave, I'm not able to install any Ruby Version with RVM anymore. It always gives an error like this:
$rvm install 2.5.3
ruby-2.5.3 - #removing src/ruby-2.5.3..
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.5.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl#1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/jdinse/.rvm/rubies/ruby-2.5.3, this may take a while depending on your cpu(s)...
ruby-2.5.3 - #downloading ruby-2.5.3, this may take a while depending on your connection...
ruby-2.5.3 - #extracting ruby-2.5.3 to /Users/jdinse/.rvm/src/ruby-2.5.3.....
ruby-2.5.3 - #configuring....................................................................
ruby-2.5.3 - #post-configuration.
ruby-2.5.3 - #compiling....................
Error running '__rvm_make -j4',
please read /Users/jdinse/.rvm/log/1547136259_ruby-2.5.3/make.log
There has been an error while running make. Halting the installation.
Looking into make.log, the only errors are like this:
making srcs under enc
make[1]: Nothing to be done for `srcs'.
generating transdb.h
linking static-library libruby.2.5.3-static.a
libtool: object: dln.o malformed object (unknown load command 1)
libtool: object: localeinit.o malformed object (unknown load command 1)
libtool: object: loadpath.o malformed object (unknown load command 1)
libtool: object: array.o malformed object (unknown load command 1)
libtool: object: bignum.o malformed object (unknown load command 1)
libtool: object: class.o malformed object (unknown load command 1)
...
What I've tried so far:
reinstalled RVM
trying previous RVM 1.29.6 or master branch
reinstalled Homebrew
reinstalled XCode
reinstalled Command Line Tools
installed gcc, gcc#7 or gcc#8 with homebrew, or uninstalled all of them
installed openssl or openssl#1.1, or uninstalled all of them
Nothing of this nor any other tips of similar questions helped.
Any ideas? Or any idea what caused the error libtool: object: dln.o malformed object (unknown load command 1) and how to fix it?
I ran into this issue as well. In my case it was due to MacPorts being outdated after I upgraded to (MacOS) Mojave.
I followed the steps listed on MacPorts' migration guide here:
https://trac.macports.org/wiki/Migration
Closed and reopened Terminal (just b/c)
ran rvm install ruby and got Install of ruby-2.6.0 - #complete, hooray!
Do you have multiple versions of boost installed? I took the following steps to fix this (although I was using rbenv).
First I removed my xcode lib:
rm -rf /Library/Developer/CommandLineTools
Then I reinstalled it:
xcode-select --install
Then I ran brew ls and noticed I had two versions of boost. boost and boost#1.6.0. I removed boost#1.6.0 and boost and reinstalled boost and made sure it was linked via brew link boost.
Seemed to work after that.
I was finally able to fix it by completely removing (a very old version of) MacPorts. Everything else kept giving me the same issues.
Hope this works for you as well. It took me more than a day to find a hint that lead me to this point.

Mac OS 10.14 Mojave + qt5.5 + gem capybara-webkit

My config is MAC Mojave v10.14.
I try to install gem Capybara-webkit -v '1.15.0' which need qt5.5, but qt5.5 has been dropped of the homebrew and it is not compatible with Xcode v10.
I try this :
Uninstall Xcode v10
Install Xcode 9.4.1, found in developer.apple.com/
Install qt5.5, I have found it in the archives on qt.io/
Run bundle
But it fail, my error is with the gem capybara-webkit -v '1.15.0':
Fetching capybara-webkit 1.15.0
Installing capybara-webkit 1.15.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/capybara-
webkit-1.15.0
/Users/thomas/.rbenv/versions/2.4.4/bin/ruby -r ./siteconf20181005-763-1bppnfh.rb extconf.rb
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
*** 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=/Users/thomas/.rbenv/versions/2.4.4/bin/$(RUBY_BASE_NAME)
--with-gl-dir
--without-gl-dir
--with-gl-include
--without-gl-include=${gl-dir}/include
--with-gl-lib
--without-gl-lib=${gl-dir}/lib
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
Command 'qmake ' failed
extconf failed, exit code 1
Gem files will remain installed in
/Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/capybara-webkit-1.15.0 for inspection.
Results logged to /Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/extensions/x86_64- darwin-18/2.4.0-static/capybara-webkit-1.15.0/gem_make.out
An error occurred while installing capybara-webkit (1.15.0), and Bundler
cannot continue.
Make sure that `gem install capybara-webkit -v '1.15.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
capybara-webkit
Next, I did:
sudo xcodebuild -license agree
But the error persists...
Thank you for your help !
As described on the capybara-webkit wiki, capybara-webkit depends on Qt 5.5. "Qt 5.5 is the last version of Qt that capybara-webkit will support. The Qt project has dropped the WebKit bindings from binary releases in 5.6."
To install Qt 5.5 follow the instructions from the wiki. For Mojave, the instructions are the following.
brew update
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 Formula/qt#5.5.rb
brew install qt#5.5
echo 'export PATH="$(brew --prefix qt#5.5)/bin:$PATH"' >> ~/.bashrc
You can confirm this step worked by running:
$ which qmake
/usr/local/opt/qt#5.5/bin/qmake
Next, you need to install Xcode 9.4. Xcode 10 is not compatible with Qt 5.5. Xcode 9.4 can be downloaded from the Apple developer portal. This is a 4GB download and takes about 30 minutes to download and install. You can verify it's correctly installed by running the following:
$ /usr/bin/xcodebuild -version
Xcode 9.4.1
Build version 9F2000
If this doesn't work, it may be because you have only the Command Line Tools installed instead of Xcode, in which case you should make sure you downloaded the right version of Xcode. Or the Xcode folder may set incorrectly. If so, you can fix this using xcode-select, which will specifiy the folder in which xcodebuild runs:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
When Xcode is finally installed, locate it in your Applications folder, open it, and agree to the license. Then try reinstalling capybara-webkit.
Disclaimer: I came up with the above answer from compiling multiple questions and answers and trying to remember the order in which I ran commands on my local machine. I may have accidentally omitted some steps.
Here's what worked for me, found here:
Keep your xcode v10 installed
Manually download and install Qt 5.5 from their website
Add Qt's bin path to your PATH environment variable by adding this to your .bashrc, .zshrc or any other shell configuration that you have: (make sure to replace /Applications/Qt/5.5/clang_64/bin with your Qt bin path)
export PATH="/Applications/Qt/5.5/clang_64/bin:$PATH" # Add Qt bin to path for capybara webkit to work
Run gem install capybara-webkit
I think my problem was with xcrun. For fix I did :
sudo chown root:wheel /Applications/Xcode.app
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo ln -s xcodebuild xcrun
And it work (y) !
You need Xcode 9.4.1 to install qt#5.5 as it's not compatible with Xcode 10. Homebrew has deleted the qt#5.5 from their core tap so to install it you need to run the following before:
brew update
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 Formula/qt#5.5.rb
brew install qt#5.5
9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 is the parent commit of 360923286c0f1a6a1325ada578df030bf579009f where they removed qt#5.5 so this command rollbacks to the parent commit and checkout the needed formula file.
I could install qt#5.5 on Mojave with this:
brew install qt#5.5 --force-bottle
With capybara-webkit, I temporarily use this:
gem "capybara-webkit", git: "https://github.com/emilyst/capybara-webkit.git", ref: "9c9af833656f095667e8522004dae017d423d37d"

Gem installation error: You have to install development tools first (Windows)

this question is for Windows
I tried installing the gem 'sinatra-websocket', but when I ran gem install sinatra-websocket, I got this error...
ERROR: Failed to build gem native extension
... along with ...
C:/Ruby193/bin/ruby.exe extconf.rb
checking for main() in -lc... *** 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=C:/Ruby193/bin/ruby
--with-thin_parser-dir
--without-thin_parser-dir
--with-thin_parser-include
--without-thin_parser-include=${thin_parser-dir}/include
--with-thin_parser-lib
--without-thin_parser-lib=${thin_parser-dir}/lib
--with-clib
--without-clib
C:/Ruby193/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 C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
from extconf.rb:4:in `<main>'
Here's what the mkmf file in C:\Ruby193\lib\ruby\gems\1.9.1\gems\thin-1.6.3\ext\thin_parser looks like:
"gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048 -DFD_SETSIZE=2048 -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/Ruby193/lib -L. -march=i486 -lmsvcrt-ruby191 -lshell32 -lws2_32 -limagehlp -lshlwapi "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7: return 0;
8: }
/* end */
I'm using Windows 7.
Why am I getting the error? There's a line stating "could not create Makefile...", but is that relevant?
Also for Mac:
if you do not already have xcode dev tools installed on your system (perhaps you recently upgraded your OS or Xcode), run xcode-select --install
otherwise, a more invasive fix is to set the active directory using the --switch flag
sudo xcode-select --switch /
from the xcode-select manual:
-s <path>, --switch <path>
Sets the active developer directory to the given path, for example
/Applications/Xcode-beta.app. This command must be run with
superuser permissions (see sudo(8)), and will affect all users on
the system. To set the path without superuser permissions or only
for the current shell session, use the DEVELOPER_DIR environment
variable instead (see ENVIRONMENT).
If you already have Xcode installed, you may have a different problem, in which case, see this post Installing puma 5.6.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build
For a Mac:
Have you run:
xcode-select --install
To install the Xcode Developer tools?
I was having this issue on MacOS Mojave(10.14.1). Installing latest ruby via Homebrew and setting some env variables solved it for me:
(copied from brew info ruby instructions)
export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
I ran into this same problem on Ubuntu 18.04. The fix on Ubuntu was to install the ubuntu-dev-tools package:
$ sudo apt-get install ubuntu-dev-tools
edit: rubyinstaller now provides installs with the devkit included. These are labelled on the download page.
Sounds like you're missing the devtools for ruby.
You can get them here: http://rubyinstaller.org/downloads/ just scroll down to "Development Kit".
Download and extract that to anywhere you want. Open up the folder in command prompt and run ruby dk.rb init. This will create a config file detailing your ruby installations. Check this config file before continuing to confirm the paths to your ruby installation are correct.
Now run ruby dk.rb install. This will install the development kit.
Restart command prompt, and try to install the gem again.
Tried all previous answers but none worked.
Did this instead:
brew install cocoapods
If you're on Mac and recently upgraded your Xcode tools, run the following commands:
sudo xcode-select --install
sudo xcodebuild -license
My issue was that I updated to macOS Big Sur, and somehow, the command line tools were outdated.
I know this because, when I tried to run brew install rbenv, I received this error:
Error: Your Command Line Tools (CLT) does not support macOS 11.
It is either outdated or was modified.
Please update your Command Line Tools (CLT) or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/more/.
So I ran
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
and after it finished, the gem installed successfully.
If you're on Mac OS 10.14 (Mojave) try
cd /Library/Developer/CommandLineTools/Packages/;
open macOS_SDK_headers_for_macOS_10.14.pkg
Credit to Roy Huang
Reference: https://stackoverflow.com/a/55732339/1598551
This solution saved me:
Install homebrew via terminal.
After homebrew is successfully installed, type in the terminal
'$ brew install cocoapods'
And Finally Done!
update: You can install homebrew by this command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
from here
Here is my solution for mac OSX:
In the Terminal App:
Step 1: Make sure you have installed the Xcode developer tool by the following script:
xcode-select --install
Step 2: Upgrade your ruby by the script:
brew install ruby
Step 3: Try again.
This means you don't have compiler tools installed. For mac xcode-select --install installs them. For linux or other systems you can use package managers, for example apt install cmake should install the necessary build tools for systems having apt package manager.
Actually, the real problem is when one upgrades from a major version of macOS to another and installs a newer Xcode.
cd /Library/Developer/CommandLineTools
ls -l SDKs/
total 0
lrwxr-xr-x 1 root wheel 14 Feb 4 21:41 MacOSX.sdk -> MacOSX11.1.sdk
drwxr-xr-x 8 root wheel 256 Feb 4 21:43 MacOSX10.15.sdk
drwxr-xr-x 7 root wheel 224 Feb 4 21:43 MacOSX11.1.sdk
After going to Apple's developer site and downloading the CLI tools by hand, this is what the folder contains:
$> ls -l SDKs/
lrwxr-xr-x 1 root wheel 14 May 4 18:10 MacOSX.sdk -> MacOSX11.3.sdk
drwxr-xr-x 8 root wheel 256 May 4 18:10 MacOSX10.15.sdk
drwxr-xr-x 7 root wheel 224 Feb 4 21:43 MacOSX11.1.sdk
drwxr-xr-x 7 root wheel 224 Mar 16 10:03 MacOSX11.3.sdk
lrwxr-xr-x 1 root wheel 14 May 4 18:09 MacOSX11.sdk -> MacOSX11.3.sdk
You might still need to reset your Xcode with:
$> sudo xcode-select --reset
$> sudo xcodebuild -license
Verify with:
$> sudo xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
Lastly, if you still see errors compiling something, you will need to pay close attention to what the compiler error is and address it. For example, in my case, it was simply that in macOS Big Sur clang needs special arguments to add declarations (struct). It was fixed with:
export CFLAGS="-fdeclspec $CFLAGS"
This was the error if you're curious (or anybody looking for an answer for Ruby 3.0.x online):
/usr/local/Cellar/ruby/3.0.1/include/ruby-3.0.0/ruby/internal/fl_type.h:285:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
I had recently upgraded to MAC OS big sur, and started getting the error when running gem install...
Solution is to remove the CLT completely and run the installation again.
Optional :
brew upgrade
Run :
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
For Ubuntu 20.04.3 LTS (Focal Fossa) -- WSL
There are some dependencies to solve before, try with following sequence of commands:
# if ERROR: 'Gem installation error: You have to install development tools first'
# BEFORE installing the dev-tools, install dependencies:
# if ERROR: 'GCC fatal error: stdio.h: No such file or directory'
$ sudo apt-get install libc6
# https://stackoverflow.com/a/20150282/5078874
$ sudo apt-get install libc6-dev
$ sudo apt-get install libffi-dev
# Now, go for the development tools
# https://stackoverflow.com/a/63442072/5078874
$ sudo apt-get install ubuntu-dev-tools
# Finally, try again
$ bundle update --bundler
# ... enjoy :)
References:
#Doug's answer PLUS references below
https://stackoverflow.com/a/20150282/5078874
If you have multiple versions of Xcode installed, make sure you select the command line tools from the most recent one, otherwise gem will not be able to find them.
On macOS Catalina; After running $ brew install coreutils (credit) –– I followed an older article by Evan Hoffman, installing chef ( which embeds latest stable release of Ruby )
$ curl -L https://www.getchef.com/chef/install.sh | sudo bash
Then I can install any gems needed, with all the requisite development tools now installed;
$ sudo gem install -V <gem>
Your mileage may vary on Big Sur
In Mac, for me worked by doing a:
sudo xcode-select --reset
I had xcode-select previously installed, but it was not working anyway. Doing a --reset fixed this for me.
Try rvm install ruby --latest
If already installed try rvm reinstall ruby --latest
and $ sudo gem install -V <gem>
Works for me.

How to install ruby-debug when needing necessary libraries and/or headers

My Rails is 3.2.1.4, Ruby is 1.9.3p448.
I got an error when I install ruby-debug:
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug:
ERROR: Failed to build gem native extension.
/home/hxh/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
Can't handle 1.9.x yet
*** 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=/home/hxh/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
Gem files will remain installed in /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/linecache-0.46 for inspection.
Results logged to /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/linecache-0.46/ext/gem_make.out
Who can tell me where the error is?
The error is in the mkmf.log file. That file should be located at /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/linecache-0.46/ext/linecache/mkmf.log.
If not, you can use
sudo find / -name mkmf.log
to find it.
To troubleshoot further, see "How to install Nokogiri Ruby gem with mkmf.log saying libiconv not found?"
I am using Mac El Capitan. In my case it was caused by the missing developer tool. I solved it by installing the developer tool via xcode-select --install. After that bundle install worked fine again.
You're most likely missing some file headers (e.g. zlib or libiconv), so try installing them.
Linux: sudo apt-get install libz-dev libiconv-hook1 libiconv-hook-dev
OS X: brew install libiconv && xcode-select --install
Otherwise check your mkmf.log file for more specific details.
I was facing the same issue running MacOS Big Sur version 11.1 and Xcode Version 12.4 (12D4e). In my case there was no command-line tool selected in Xcode.
I just followed the following steps to fix the problem:
Start Xcode.
Open the preferences using ⌘+,.
Select the Locations tab.
Select command-line tool (Xcode 12.4 12D4E in my case).
Run sudo gem install cocoapods (in my case).
It seems to be a issue with permission of gcc.. however, if you're using OS X, you may encounter this issue if you've updated your XCode but haven't agree to their terms & conditions yet.. try typing gcc in your terminal would show you what if you've agreed.
My mkmf.log showed that gcc (4.8.2 I think) didn't like a specific argument that was being used by atomic on
$ gem install atomic
So I had a very similar situation. The answer for me was to upgrade gcc/gcc-libs and lib tool.
I use Arch linux, and only Arch linux. The proper way to do this is to run
$ sudo pacman -Syu
which upgrades all system packages.
I installed Rails and hadn't run a system update since, which is where the issue came from. In most other *nix distros, you would update to the latest version of these packages by name, i.e. with apt, it would be something along the lines of
$ sudo apt-get update
followed by
$ sudo apt-get upgrade {package-name}
For what it's worth, using Ruby 2.0.0 I was having this problem on OSX 10.10.
I ended up running brew update, which resolved some conflicts, then installed the gem and it was fine.
The answer of kenorb worked for me on Ubuntu 16.04 when I was trying installing rails! Thanks!
I followed these steps below for installing rails:
sudo apt-get install ruby-full
sudo apt-get install libz-dev libiconv-hook1 libiconv-hook-dev
sudo gem install rails
I had the issue because gcc wasn't available on my machine.
Fixed it by installing gcc.
sudo apt install build-essential
This worked for me. Nokogiri was the problem.
Try the following if you are using Alpine-Linux(or equivalent command for your OS):
apk add build-base
And then install Nokogiri using:
gem install nokogiri -- --without-pkg-config --with-libxml-2.0-config
Took me a while to successfully install it.
Install cocoapods with HomeBrew brew install cocoapods && brew link --overwrite cocoapods
Verify your cocoapods version pod --version
This is probably happening because your computer has an older version of Ruby, so first update Ruby. This worked for Ruby 2.6.3+.
Open terminal and enter:
curl -L https://get.rvm.io | bash -s stable
Then:
rvm install ruby-2.6
This will install Ruby for you if it wasn't already installed, then update Ruby to the new version:
rvm use ruby-2.6.3
This will possibly fix your issue. You can now enter:
sudo gem install cocoapods
pod setup
If RVM is not installed in your system, then use:
$HOME/.rvm/scripts/rvm
rvm
The problem is resolved with next command: sudo apt install build-essential
This worked for me:
sudo apt-get install libmysqlclient-dev
Install RVM and use it to install Ruby 2.6.x:
curl -sSL https://get.rvm.io | bash
rvm install 2.6.x
rvm use ruby-2.6.x
Now try and it should work:
sudo gem install cocoapods

Ruby gem rmagick won't install on Mac OS X

I understand that this question has been asked a lot earlier, but none of the solutions worked for me and I'm really desperate right now.
I'm trying to get rMagick to install using gem for an installation of diaspora. I already installed imagick via homebrew and when trying to run gem install rmagick I receive this error:
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/bin:/Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#global/bin:/Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin:/Users/tobischweiger/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
*** 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=/Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin/ruby
Gem files will remain installed in /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
I'm not very experienced with gem and homebrew and I'm wondering if somebody could help me out.
Run this (using homebrew) before attempting to install the gem.
brew install imagemagick
This is the less destructive version using homebrew, rmagic also doesn't work with imagemacigk version 7
ImageMagick Version 6.4.9 or later (6.×.x). Version 7 is NOT yet
supported; ETA April 2019 (https://github.com/rmagick/rmagick/pull/299 )
(from Readme)
. You can get ImageMagick from www.imagemagick.org., so with brew try this
brew install imagemagick#6
PKG_CONFIG_PATH=/usr/local/opt/imagemagick#6/lib/pkgconfig gem install rmagick
I'm using OS X Lion.
I ran brew doctor and saw that imagemagick was unlinked so it told me to run brew link imagemagick.
Then I closed and re-opened my terminal and everything worked thankfully.
On Mavericks, you can do it:
brew install pkgconfig
brew uninstall imagemagick
brew install imagemagick
brew link imagemagick
bundle install
It's enough. I think.
I had a similar issue and this worked for me:
$ cd /usr/local/Cellar/imagemagick/6.8.0-10/lib
$ ln -s libMagick++-Q16.7.dylib libMagick++.dylib
$ ln -s libMagickCore-Q16.7.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.7.dylib libMagickWand.dylib
Hope this helps.
Credit: https://coderwall.com/p/wnomjg
Make sure when you do these:
$ cd /usr/local/Cellar/imagemagick/6.8.0-10/lib
$ ln -s libMagick++-Q16.7.dylib libMagick++.dylib
$ ln -s libMagickCore-Q16.7.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.7.dylib libMagickWand.dylib
that you change the file names to reflect your version: you can see the filenames by looking in the lib folder here: cd /usr/local/Cellar/imagemagick/VERSION/lib
ex:
ln -s libMagickWand-6.Q16.1.dylib libMagickWand.dylib
and so on
There are different scenarios we need to check while installing RMagick. Please check following and confirm:
Check if you are not installing latest version of RMagick with older version of ruby. i.e. ruby 1.8.7 or so. You can not install latest version of RMagick with older version of Ruby. If so, you will probably get this error message.
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/user/.rbenv/versions/1.8.7-p375/bin/ruby extconf.rb
Make sure you have installed imagemagick before you install RMagick.
brew install imagemagick
Also make sure you are installing RMagick with compatible version of imagemagick. RMagick is not compatible with latest version of imagemagick.
More to this:
instead of using RMagick you can use MiniMagick if you just need to resize, sharpen, transform existing images. RMagick is required when we need to create image, graphs, drawings and typography. It’s easier to work with and much lighter on system resources than RMagick. RMagick consumes huge amount of memory.
The main issue seems to be getting imagemagick properly installed and linked.
This page was very helpful for me:
http://sethvargo.com/20110726/install-imagemagick-on-mountain-lion/
I'm running homebrew, and getting the brew doctor command to run clean was the key to getting this to install.
I found that updating my Xcode to the latest version (4.6.1) on OSX 1.8.2 fixed this problem and I Successfully installed rmagick-2.13.2
For me, I had to look at the output which in your case is
/Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385#diaspora/gems/rmagick-2.13.2/ext/RMagick
In there is a file called mkmf.log that lists exactly what it is trying to compile and the error. For me, the linker was failing with this command:
ld: library not found for -lMagickCore
Reviewing the command it was running it looked good except for the very end, see this snippet:
-lMagickCore-6.Q16 -lMagickCore-6.Q16 -lruby-static -framework CoreFoundation -lMagickCore -lpthread -ldl -lobjc -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
Note that it got the output from Magick-config and used those by adding -lMagickCore-6.Q16 but it was still trying to link -lMagickCore. I think this is a byproduct of the have_library extconf is using. Important for me, was that there was no libMagickCore.dylib library provided by Homebrew. It could be an old version of rubygems and I think the correct fix would be to update the have_library function but I fixed it by making a symlink called libMagickCore.dylib that pointed to libMagickCore-6.Q16.dylib.

Resources