Unable To Install 'therubyracer v0.12.3' gem in M1 Macbook Pro - ruby-on-rails-3

I am using M1 Macbook Pro and wants to install therubyracer and libv8 for a rails webapp. But I am unable to do so because of the errors described below. There are several solutions available on the internet but none of them is working for me.
Operating System: macOS Big Sur v11.1.
It would be very helpful if someone can help me with this.
Log:
❯ ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [-darwin20]
❯ bundle -v
Bundler version 1.17.3
❯ brew -v
Homebrew 2.7.5
Homebrew/homebrew-core (git revision e04a30; last commit 2021-01-20)
Homebrew/homebrew-cask (git revision d128de; last commit 2021-01-20)
❯ uname -a
Darwin Vaibhavs-MacBook-Pro.local 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:40:21 PST 2020; root:xnu-7195.60.75~1/RELEASE_ARM64_T8101 arm64
❯ brew search v8
==> Formulae
v8 ✔ v8#3.15
==> Casks
amitv87-pip
❯ brew install v8#3.15
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
Updated 3 formulae.
==> Updated Casks
Updated 3 casks.
Error: v8#3.15: no bottle available!
You can try to install from source with:
brew install --build-from-source v8#3.15
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.
❯ brew install --build-from-source v8#3.15
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
Updated 1 cask.
==> Cloning https://chromium.googlesource.com/external/gyp.git
Updating /Users/vaibhavgupta/Library/Caches/Homebrew/v8#3.15--gyp--git
==> Checking out revision f7bc250ccc4d619a1cf238db87e5979f89ff36d7
HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja.
HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja.
==> Downloading https://github.com/v8/v8-git-mirror/archive/3.15.11.18.tar.gz
Already downloaded: /Users/vaibhavgupta/Library/Caches/Homebrew/downloads/26ea05158c6c6ebb67cc42075858df9a986f9c615513933b1e62bb707f707854--v8-3.15.11.18.tar.gz
==> make native -j8 library=shared snapshot=on console=readline
Last 15 lines from /Users/vaibhavgupta/Library/Logs/Homebrew/v8#3.15/01.make:
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
^
In file included from ../src/conversions.cc:32:
In file included from ../src/conversions-inl.h:42:
In file included from ../src/platform.h:100:
In file included from ../src/lazy-instance.h:94:
../src/once.h:115:7: error: no matching function for call to 'Acquire_Load'
if (Acquire_Load(once) != ONCE_STATE_DONE) {
^~~~~~~~~~~~
../src/atomicops.h:125:10: note: candidate function not viable: no known conversion from 'v8::internal::OnceType *' (aka 'long *') to 'const volatile v8::internal::Atomic32 *' (aka 'const volatile int *') for 1st argument
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
^
5 errors generated.
make[1]: *** [/private/tmp/v8-3.15-20210120-4211-1soh8ig/v8-3.15.11.18/out/native/obj.target/preparser_lib/src/conversions.o] Error 1
make: *** [native] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
❯ brew install v8
==> Downloading https://homebrew.bintray.com/bottles/v8-8.8.278.14.arm64_big_sur.bottle.tar.gz
Already downloaded: /Users/vaibhavgupta/Library/Caches/Homebrew/downloads/457adba5b4da5d7cb7d6d896218ebc5d8f1453782321e97a3df424f4a4e8a821--v8-8.8.278.14.arm64_big_sur.bottle.tar.gz
==> Pouring v8-8.8.278.14.arm64_big_sur.bottle.tar.gz
🍺 /opt/homebrew/Cellar/v8/8.8.278.14: 80 files, 39.9MB
❯ brew --prefix v8
/opt/homebrew/opt/v8
❯ gem install libv8 -v '3.16.14.19'
Fetching libv8-3.16.14.19.gem
Building native extensions. This could take a while...
ERROR: Error installing libv8:
ERROR: Failed to build gem native extension.
current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6051-11xeqcl.rb extconf.rb
creating Makefile
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/disable-building-tests.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/disable-werror-on-osx.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/disable-xcode-debugging.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/do-not-imply-vfp3-and-armv7.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/do-not-use-MAP_NORESERVE-on-freebsd.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/do-not-use-vfp2.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/fPIC-for-static.patch
Compiling v8 for arm
Using python 2.7.16
Using compiler: c++ (clang version 12.0.0)
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Beginning compilation. This will take some time.
Building v8 with env CXX=c++ LINK=c++ /usr/bin/make arm.release vfp2=off vfp3=on hardfp=on ARFLAGS.target=crs werror=no
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
-Ibuild/standalone.gypi --depth=. \
-Dv8_target_arch=arm \
-S.arm -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=false -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' -Dv8_use_arm_eabi_hardfloat=true
CXX(target) /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/preparser_lib/src/allocation.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from ../src/allocation.cc:33:
../src/utils.h:33:10: fatal error: 'climits' file not found
#include <climits>
^~~~~~~~~
1 error generated.
make[1]: *** [/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [arm.release] Error 2
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `each'
from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `verify_installation!'
from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/libv8-3.16.14.19/gem_make.out
❯ gem install libv8 -v '3.16.14.19' -- --with-system-v8
Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.19
Parsing documentation for libv8-3.16.14.19
Installing ri documentation for libv8-3.16.14.19
Done installing documentation for libv8 after 0 seconds
1 gem installed
❯ gem install therubyracer -v '0.12.3'
Building native extensions. This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3/ext/v8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6195-ojni3j.rb extconf.rb
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** 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
--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/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/$(RUBY_BASE_NAME)
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.
However, your system version of v8 could not be located.
Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/gem_make.out
❯ gem install therubyracer -v '0.12.3' -- --with-v8-dir=/opt/homebrew/opt/v8
Building native extensions with: '--with-v8-dir=/opt/homebrew/opt/v8'
This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3/ext/v8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6214-10f7ru2.rb extconf.rb --with-v8-dir\=/opt/homebrew/opt/v8
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** 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
--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/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/$(RUBY_BASE_NAME)
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.
However, your system version of v8 could not be located.
Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/gem_make.out
❯ gem install therubyracer -v '0.12.3' -- --with-v8-dir=/opt/homebrew/opt/v8/libexec/
Building native extensions with: '--with-v8-dir=/opt/homebrew/opt/v8/libexec/'
This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3/ext/v8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6235-1hlxxtd.rb extconf.rb --with-v8-dir\=/opt/homebrew/opt/v8/libexec/
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** 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
--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/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/$(RUBY_BASE_NAME)
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.
However, your system version of v8 could not be located.
Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/gem_make.out

This works for me:
Ruby version: 2.6.1
OS version: macOS Big Sur 11.2
Install HomeBrew using Rosetta Termina
https://5balloons.info/correct-way-to-install-and-use-homebrew-on-m1-macs/
brew install v8#3.15
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8#3.15

I fixed this by installing V8 on Rosseta 2 as V8 not yet supported for ARM.
You can try this
gem install therubyracer -v '0.12.3' --
--with-v8-dir=/usr/local/opt/v8#3.15
Or install V8 on Rosseta 2.
Update: How to install ruby in x86_64 for M1.
Install homebrew in x86_64. Please refer to this guide How to install ruby on m1
Install ASDF using x86_64
Install all other dependencies on x86_64 only such as postgres, redis, and V8 using x86_64 only.

Related

Unable to install Cocoapods on Yosemite DP 7

I am having trouble installing Cocoapods on Yosemite DP 7 installed on a separate partition. I already attempted following the instructions found on Cocoapods with Xcode 6 and 10.10 Yosemite and in the issue(https://github.com/CocoaPods/CocoaPods/issues/2219) closed due to the same solution proposed on the Stack Overflow link.
I continue to get the following error:
Rasmuss-MacBook-Pro:~ rasmusth$ sudo gem install cocoapods
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
"/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby" -rubygems /Library/Ruby/Gems/2.0.0/gems/rake-0.9.6/bin/rake RUBYARCHDIR=/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext RUBYLIBDIR=/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for -std=c99 option to compiler... *** 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.0/usr/bin/ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434: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.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:502:in `with_werror'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
from extconf.rb:24:in `block in <main>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
from extconf.rb:23:in `<main>'
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext/xcodeproj/Rakefile:37:in `block in <top (required)>'
Tasks: TOP => default => ext
(See full trace by running task with --trace)
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext/xcodeproj/gem_make.out
I am suspecting that this may have to do with the fact that I have Yosemite on a separate partition, but otherwise I am clueless.
I ran into the same issue. After much hair pulling following the same steps as everyone else, the following worked.
$ xcode-select --install (to confirm command line tools are installed)
Installed nvm stable (and homebrew): $ \curl -sSL https://get.rvm.io | bash -s stable
close/reopen terminal
Installed ruby 2.1.2: $ rvm install 2.1
Switch to it: $ rvm use 2.1
Uninstall/reinstall xcodeproj and cocoapods
Xcode 6.0 GM is missing the 10.10 SDK and therefore the gem xcodeproj can't be compiled which has some C code in it which needs the 10.10 SDK.
This is going to be fixed in the future.
For now you can work around it like this:
Terminal: sudo gem uninstall cocoapods xcodeproj
Download Xcode 6.1 (right now Beta 2 is the current one)
Start it go to Settings -> Location -> Command Line Tools -> Change to Xcode 6.1 Beta
Terminal: sudo gem install cocoapods
Change your Command Line tools back to GM (if you want/need)
For more information see: https://github.com/CocoaPods/CocoaPods/issues/2432

Unable to install pg gem (Rails 3 - Cygwin) - sh: : command not found

When I run
$ gem install pg
I get the following
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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=/usr/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1/ext/gem_make.out
When I run
$ gem install pg -- --with-pg-config= /cygdrive/c/Program Files/PostgreSQL/9.0/bin/pg-config
I get the following
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb --with-pg-config= /cygdrive/c/Program Files/PostgreSQL/9.0/bin/pg-config
Using config values from
sh: : command not found
sh: : command not found
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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=/usr/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1/ext/gem_make.out
What does the "sh: : command not found" mean?
Is this the reason why the installation is failing?
Background:
I am using Cygwin
I used the one click installer of PostgreSQL
The pg_config.exe file is located at C/Program Files/PostgreSQL/9.0/bin/pg-config.exe
The libpq-fe.h file is located at C/Program Files/PostgreSQL/9.0/include/libpq-fe.h
You can't mix and match native Windows code and Cygwin code. If you want to link to libpq you'll need the cygwin build libpq and you'll need to make sure the version of pg_config found on the PATH is the cygwin one. The pg_config from the native Windows build will produce output the Cygwin tools cannot understand, and even if they could they wouldn't successfully link against the native library and run with it.
As I no longer use Cygwin I can't offer any advice on the current way to install libpq. Presumably there's a lib in Cygwin's package management that'll be called something like postgresql-client, libpq, etc.
Cygwin is a pretty low priority platform for PostgreSQL at this point. Given that Ruby+Rails and PostgreSQL both have native Windows versions, you're setting yourself up for a hard time here, and I'd advise you to use the native versions of both tools. You can still work within a unix-like shell environment using msys bash and can use MinGW's gcc to produce native Windows executables and libraries if MSVC++ isn't an option.
This worked for me:
sudo apt-get install postgresql
sudo apt-get install libpq-dev
Then
gem install pg

rdiscount "ERROR: Failed to build gem native extension."

This is interesting. I had rdiscount working within one rvm gemset, but when I tried to add it to another, I would get ERROR: Failed to build gem native extension. So I tried removing it from the original gemset and re-installing it only to get the same error. I'm not sure what is going on. I'm trying to use it with Jekyll and Octopress builds. I'm on OS X 10.7.5.
Here's what happens:
Using /Users/rachelnabors/.rvm/gems/ruby-1.9.2-p290 with gemset jekyll
Can-Opener:RachelNabors.com rachelnabors$ gem install rdiscount
Building native extensions. This could take a while...
ERROR: Error installing rdiscount:
ERROR: Failed to build gem native extension.
/Users/rachelnabors/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for random()... yes
checking for srandom()... yes
checking for rand()... yes
checking for srand()... yes
checking size of unsigned long... long
checking size of unsigned int... int
no int with size 4
*** 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/rachelnabors/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-rdiscount-dir
--without-rdiscount-dir
--with-rdiscount-include
--without-rdiscount-include=${rdiscount-dir}/include
--with-rdiscount-lib
--without-rdiscount-lib=${rdiscount-dir}/lib
Gem files will remain installed in /Users/rachelnabors/.rvm/gems/ruby-1.9.2-p290#jekyll/gems/rdiscount-2.0.7.1 for inspection.
Results logged to /Users/rachelnabors/.rvm/gems/ruby-1.9.2-p290#jekyll/gems/rdiscount-2.0.7.1/ext/gem_make.out
Same failure:
https://github.com/rtomayko/rdiscount/issues/48
Ruby 1.9.2 isn't supported. See also:
https://github.com/rtomayko/rdiscount/wiki/Support-Matrix
1.9.3 should do ya fine!

Can't install rmagick gem on Mountain Lion

Note: my situation is almost identical to this: Can't install pg gem on Mountain Lion.
I just upgraded from Snow Leopard to Mountain Lion and Rails is giving me all kinds of problems, especially trying to install the 'rmagick' gem. I'm running Ruby 1.9.3-p362 and Rails 3.2.11.
➜ git:(master) ✗ sudo gem install rmagick -v 2.13.1
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... yes
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/opt/local/bin/Magick-config reports version 6.6.6 Q8 is installed in /opt/local
/OPT/LOCAL/BIN/Magick-config reports version 6.6.6 Q8 is installed in /opt/local
/USR/LOCAL/BIN/Magick-config reports version 6.8.0 Q16 is installed in /USR/LOCAL/Cellar/imagemagick/6.8.0-10
Using 6.6.6 Q8 from /opt/local.
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.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=/Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
/Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:833:in `have_header'
from extconf.rb:193:in `<main>'
Gem files will remain installed in /Users/sscirrus/.rvm/gems/ruby-1.9.2-p320/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/sscirrus/.rvm/gems/ruby-1.9.2-p320/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
➜ applyco git:(master) ✗ brew install imagemagick --disable-openmp
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Error: imagemagick-6.8.0-10 already installed
➜ applyco git:(master) ✗ apt-get install libmagick9-dev
zsh: command not found: apt-get
I have tried:
Installing Xcode with command line tools
Reinstalling homebrew
Clearing out all my repo's gems (including Gemfile.lock) and running bundle install
Reinstalling the bundler gem
Reinstalling ImageMagick
Nothing, including answers elsewhere on SO, have been of any use. Can you point me in the right direction?
I had the same problem as you setting up my dev environment on Mountain Lion for RoR 3.2.11. Apparently the last version of RMagick (2.13.1 ) doesn't play nice compiling with the last version of ImageMagick (6.8.2-0). Disabling openmp and building from source worked like, ahem.. Magick.
brew uninstall imagemagick
brew install imagemagick --disable-openmp --build-from-source
gem install rmagick
I didn't need to edit the brew formula described in http://blog.paulopoiati.com/2013/01/28/installing-rmagick-in-mac-os-x-mountain-lion-with-homebrew/, but that would be the next step to try.
I am going through the same issue here...
But one difference, maybe your homebrew its linked to another version of Imagemagick.
So even though imagemagick-6.8.0-10 is installed is not being found.
Try something like
brew unlink imagemagick
then brew link imagemagick
and see what happens.
This fixed my problem
http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
It may be a permissions issue try running
sudo chown -R `whoami` /usr/local
and then try again.
I had the same issue while trying to use Paperclip with Rails 3 for the first time.
Just to sum up previous answers, what worked for me was the following:
sudo chown -R `whoami` /usr/local
brew link --overwrite imagemagick
Thanks!

Installing rmagick on osx 10.7.3 crashed

I got a problem to install rmagick on my osx 10.7.3 lion
I used rvm
Imagemagick is installed with homebrew
gem install rmagick
Fetching: rmagick-2.13.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension
/Users/lion/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.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
--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/lion/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
/Users/lion/.rvm/rubies/ruby-1.9.3-p0/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 /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:506:in
try_cpp'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:931:in
block in have_header'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:790:in
block in checking_for'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:284:in
block (2 levels) in postpone'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:254:in
open'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:284:in
block in postpone'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:254:in
open'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:280:in
postpone'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:789:in
checking_for'
from /Users/lion/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:930:in
have_header'
from extconf.rb:193:in'
Gem files will remain installed in /Users/lion/.rvm/gems/ruby-1.9.3-p0/gems/rmagick-2.13.1 for
inspection.
Results logged to /Users/lion/.rvm/gems/ruby-1.9.3-p0/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
Did anyone know what i can do to install rmagick correctly?
I'm going to take a guess that it's an upgrade and not pre-installed? I recently upgraded to Lion and had to do something like:
uninstall xcode 3 (there's a non-destructive version of the uninstall script in case you care)
install xcode 4 (free from the app store. big download).
i use macports. i had to uninstall and reinstall them all. you'll need to do the same for homebrew if you haven't already.
symlink or pass on command line the new gcc compiler (rmagick references gcc-4.2, but with xcode 4 it's called llvm-gcc-4.2. look up what that means if you're interested http://llvm.org/)
That pretty much sums up what I had to do. The clue was in the mkmf.log, so definitely look in there and update your question if my answer doesn't do it for you.