sudo gem install compass - stuck at "checking for ffi.h..." - ruby

Im running terminal on Mac OSX 10.9.5 and had no problems installing the following:
Brew 0.9.5
Ruby 2.0.0p481
Sass 3.4.9
npm 2.20
Yeoman
Bower 1.3.12
Grunt-cli 0.1.13
After typing sudo gem install compass -V it installs a bunch of files but get's stuck here:
Building native extensions. This could take a while...
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150116-1042-1pd2lzv.rb extconf.rb
checking for ffi.h...
Any suggestions would be great.

Related

Unable to install ruby-filemagic 0.7.1 on Mac even though libmagic has been installed

Unable to install ruby-filemagic 0.7.1 on Mac even though libmagic has been installed.
The error is like :
checking for main() in -lgnurx... no
checking for magic_open() in -lmagic... no
*** ERROR: missing required library to compile this module
* extconf.rb failed *
Almost all answers fo ruby-filemagic installation are the brew install libmagic. However, it doesn't work.
In my case, on Monterey 12.0.1 helped this:
brew unlink libmagic && brew link libmagic
sudo chown -R $(whoami) $(brew --prefix)/* - in case you have Error: Permission denied # rb_sysopen
gem install ruby-filemagic -v '0.7.2' --source 'https://rubygems.org/' -- --with-magic-include=/opt/homebrew/include --with-magic-lib=/opt/homebrew/lib/
A few hours were cost before I found the problem. Let me write down the cause and solution here :
cause:
my ruby ($HOME/.rbenv/versions/x.x.x/bin/ruby) was under the control of rbenv, however my bundler was controlled by old ruby (/usr/local/ruby) .
The stupid bundler could not find the library for installing ruby_filemagic and wasted so much time.
solution:
$ rbenv exec gem install bundler
$ rbenv rehash
make bundler, gem, ruby under the same management.
Sorry for my poor English. I hope this may help more people.

Error on installing gem Nokogiri-1.8.4

OS: AMI 2018.03.0 (HVM)
Ruby version: 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux-gnu] - installed using yum install ruby23
gem install nokogiri throws:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /home/ec2-user/.gem/ruby/2.3/gems/nokogiri-
1.8.4/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20180801-6218-101te4s.rb extconf.rb
mkmf.rb can't find header files for ruby at
/usr/share/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /home/ec2-
user/.gem/ruby/2.3/gems/nokogiri-1.8.4 for inspection.
Results logged to /home/ec2-user/.gem/ruby/2.3/extensions/x86_64-
linux/2.3/nokogiri-1.8.4/gem_make.out
what am i missing here?
From the error output, it would seem it can't find the development dependencies for Ruby, which Nokogiri is trying to use in order to build the gem natively.
You can run yum -y install gcc ruby-devel rubygems to make certain the dependencies are installed.
Basing my answer somewhat from https://stackoverflow.com/a/4502672/1129980
Update
Tested this now on a new EC2 instance:
yum install -y ruby23-devel gcc libxml2 libxml2-devel libxslt libxslt-devel patch
gem install nokogiri --no-ri --no-rdoc
That works :)
Try running the below mentioned commands
sudo yum -y install ruby-dev ( or ruby-devel)
sudo yum -y install libgmp-dev libgmpxx4ldbl ruby-dev ruby2.3-dev

gem install compass won't work

When I try to install compass using sudo gem install compass it show me this :
Building native extensions. This could take a while...
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -r ./siteconf20141125-86718-gjziv3-0.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... no
checking for rb_thread_call_without_gvl()... no
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile
make clean
make
mkdir -p "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386; (if [ ! -f "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386/Makefile ]; then echo "Configuring libffi for i386"; cd "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386 && env CC=" xcrun cc" CFLAGS="-arch i386 " LDFLAGS="-arch i386" "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c/libffi"/configure --disable-static --with-pic=yes --disable-dependency-tracking --host=i386-apple-darwin > /dev/null; fi); env MACOSX_DEPLOYMENT_TARGET=10.4 make -C "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386
Configuring libffi for i386
configure: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used
configure: error: in `/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c/libffi-i386':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[1]: *** No targets specified and no makefile found. Stop.
make: *** ["/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386/.libs/libffi_convenience.a] Error 2
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/ffi-1.9.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/extensions/universal-darwin-11/1.8/ffi-1.9.6/gem_make.out
I have correctly install sass and xcode' tools but nothing change. I even try to upgrade ruby. What should I do?
It happens because you want to sudo install and probably environment variables are not configured to use your installed ruby, instead it uses the system ruby which probably is not what you want to use.
The easiest way to use Ruby on Mac is to install rbenv and ruby-build using homebrew.
To install homebrew just run this command which can be found on brew homepage:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To install rbenv and ruby-build you can run these commands which can be found on Github:
brew update
brew install rbenv ruby-build
Forgot to add that for sure, then you need to install a ruby version using rbenv and make it global.
rbenv install 2.1.5
rbenv global 2.1.5
And finally:
gem install compass
Just make sure that gem binary points to the version you've installed.
You can run gem env and checkout printed paths, if it doesn't point to newly installed ruby gem path, close the terminal and open a new one then install the gem.
Here is the first few lines of what's printed out on my machine:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin13.0]
- INSTALLATION DIRECTORY: /Users/jani/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
....

Failed to build gem native extension

I want to install in my Fedora 12 based planet lab nodes one OMF RC:
It requres ruby 1.9.3. So, I installed git, then ruby-devel then rvm. With rvm i installed:
rvm install 1.9.3
After all this when i want to install:
gem install omf_rc --pre --no-ri --no-rdoc
It gives me the following error:
Building native extensions. This could take a while...
ERROR: Error installing omf_rc:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.h... * extconf.rb failed *
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers
Please let me know how to solve this. Thanks
seems you need to install libxml, try:
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
Also it needs the following installation:
sudo yum install -y git make gcc-c++
and
sudo yum groupinstall development-tools development-libs

Failed to build gem native extension when install RedCloth-4.2.9 install Linux

I want to install Octopress in my computer.
I try to do it like
Octopress document.
When I run
bundle install
I got error message
An error occured while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
So, I run
sudo gem install RedCloth -v '4.2.9'
then, I got a error message again:
ERROR: Error installing RedCloth:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
I hadn't learn any knowledge about ruby.
My ubuntu 12.04 solution is install the ruby1.9.1-full version, that can resolve this issue.
sudo apt-get install ruby1.9.1-full
you can execute command:
sudo update-alternatives --config ruby
to select the altiernative ruby which you have installed.
and then, execute below commands to finish the octopress deploy:
git clone https://github.com/erizhang/octopress.git octopress
cd octopress/
sudo gem install bundler
sudo gem install RedCloth -v '4.2.9'
bundle install
rake install
below commands you can find from octopress deploy guideline page:
rake setup_github_pages
sudo rake setup_github_pages
sudo rake generate
sudo rake deploy
Hope it's helpful for you, thanks
I was installing Octopress too and got the same problem as yours. After checking the mkmf.log file I figured out that gcc-4.2 had not been found. I Even installed xcode with the command line tools. It worked when I made a symlink like this:
$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
$ bundle install
I fixed this issue by running
sudo apt-get install ruby-dev
as described in this blog post.
You've probably upgraded to Mountain Lion and have not rebuilt your ruby-1.9.2 install yet with the new development packages.
rvm --force install 1.9.2
gem install bundle --no-ri --no-rdoc
bundle install
If you don't have the Mountain Lion dev packages installed correctly, use the ThoughtBot instructions.
For Ubuntu 14.04 simply do this:
sudo apt-get install ruby1.9.3
Should work for 13.10 and 13.04 too. (Not tested)
it apears you are not using rvm for managing your ruby installation. I think best would be to try rvm, here's a very good guide, you can stop without installing rails: ruby with rvm
Then simply
$gem install RedCloth
Unmanaged ruby gems are a pain, I try to avoid them.
None of the answers worked on my Ubuntu 14.04.1 LTS. Upgrade to ruby 2.0 fixed the problem for me:
sudo apt-get install ruby2.0 ruby2.0-dev
sudo ln -s /usr/bin/ruby2.0 /usr/bin/ruby
sudo ln -s /usr/bin/gem2.0 /usr/bin/gem
sudo gem install bundler
Make sure you also have the build-essential package installed. You can check using
dpkg -l | grep build-essential
or simply install it without checking
sudo apt-get install build-essential
For me on Ubuntu 14.04.1 LTS, after making sure build-essential is installed, the bundle install command works/builds fine also with Ruby 1.9.3.

Resources