Json ERROR: Failed to build gem native extension

I am quite new to rails and try now to set up a deployment
environment. However I do not have the experience to over come every
obstacle:

Centos 5.4 x86_64
apache 2.2.3
rvm 1.6.13
ruby 1.9.2-p0
passenger 3.0.7
capistrano 2.5.21

I have installed rvm as root. ruby 1.9.2-p0 installed and set as
default.
Installed passenger and adapted the apache config. Deployed the rails
app
with capistrano.

Then I pont the browser to https://localhost.localdomain/reg

The browser shows a passenger error:
Ruby on Rails application could not be started
Could not find json-1.5.1 in any of the sources (Bundler::GemNotFound)
Backtrace:
Frame 0:
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.13/lib/bundler/
spec_set.rb
Frame 9:
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.7/lib/
phusion_passenger/utils.rb

when i go to the rails app and run
bundle install
it fails while building json:
Installing json (1.5.1) with native extensions /usr/local/rvm/rubies/
ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in
`rescue in block in build_extensions’: ERROR: Failed to build gem
native extension. (Gem::Installer::ExtensionBuildError)

but $ gem install json
installs 1.5.1 without a probelm

I do all this as root. It seems to me that there is a mix up of
environments but do not know how to fix it. The error messge mentions /
usr/local/rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/
installer.rb Why 191 and not 1.9.2 ?

xp:/var/www/html/registration/current# gem env
/usr/local/rvm/rubies/ruby-1.9.2-p0/bin/gem:4: warning: Insecure world
writable dir /var/www/html in PATH, mode 040777
RubyGems Environment:

  • RUBYGEMS VERSION: 1.6.2
  • RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]
  • INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.2-p0
  • RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.2-p0/bin/ruby
  • EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.2-p0/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86_64-linux
  • GEM PATHS:
    • /usr/local/rvm/gems/ruby-1.9.2-p0
    • /usr/local/rvm/gems/ruby-1.9.2-p0@global
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

Generally how does one dignose the cause for Failed to build gem
native extension, I was not able to find a log file to find out what
went wrong.

Thank you
Ernst

On Fri, May 27, 2011 at 7:41 PM, eka [email protected] wrote:

Could not find json-1.5.1 in any of the sources (Bundler::GemNotFound)
it fails while building json:
Installing json (1.5.1) with native extensions /usr/local/rvm/rubies/
ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in
`rescue in block in build_extensions’: ERROR: Failed to build gem
native extension. (Gem::Installer::ExtensionBuildError)

but $ gem install json
installs 1.5.1 without a probelm

After you do this and you then run ‘bundle install’ do you still get the
error?

Also, are you using a gemset with rvm? And just to be sure have you
confirmed your rvm settings with ‘rvm current’?

I do all this as root. It seems to me that there is a mix up of

environments but do not know how to fix it. The error messge mentions /
usr/local/rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/
installer.rb Why 191 and not 1.9.2 ?

I wondered about this in the past and dont know the answer but this as
it
should be.

Running
gem install json (which is sucessful)
and then
bundle install
the same error occurs

On Fri, May 27, 2011 at 8:19 PM, eka [email protected] wrote:

Running
gem install json (which is sucessful)
and then
bundle install
the same error occurs

I am not sure if this will work (also to answer your question, to
diagnose
‘failed to compile native extensions’, usually just google and tends to
have
either to do with the OS or access rights)… I am guessing your
problem is
related to either the location that the gem is getting installed or due
to
the OS (i.e. such as 32 vs 64 bit)… that said, try this at the command
prompt and then try bundle install again:

rvmsudo gem install json

Thank you David
rvmsudo gem install json --> ok
bundle install --> same error remains
rvmsudo bundle install --> same error remains

I wonder if there is a OS package missing. However if I run this not
as root but in my own
user login then it works which suggests the OS has all packages
required.

It would be really helpfull if bundle install wrote to a log or stdout
what is missing. I do not
understand how the output of bundle install can be used to diagnose
what went wrong.

bundle help
shows there is a command viz to show dependencies.
xp:/var/www/html/registration/current# bundle viz
#<LoadError: no such file to load – graphviz>
Make sure you have the graphviz ruby gem. You can install it with:
gem install ruby-graphviz

After gem install ruby-graphviz it still gives the same LoadError

I think I make a wrong assumptions about execution environments and do
not know enough.

Ernst

On May 28, 10:49am, David K. [email protected] wrote:

capistrano 2.5.21
Ruby on Rails application could not be started
bundle install
error?
Yes still same.

Also, are you using a gemset with rvm? And just to be sure have you
confirmed your rvm settings with ‘rvm current’?
Using defaults (as out of the box)
rvm current
ruby-1.9.2-p0

Tried
gem install
rvm gem install
bundle install
rvm wrapper ruby-1.9.2-p0

and in the end rebooted linux.

Now
bundle install
works and I get much further

Sorry I do not know why and how

I’m having this same problem, Mac OS X 10.6.7, running ruby-1.8.7-p334
(using RVM)

When I run bundle install, all these bundles work fine until it gets to
json , then it crashes. I tried different json versions 1.4.6 and 1.51
– all execute “with native extensions” and it looks like that’s what
makes it crash

Installing rake (0.9.0)
Installing abstract (1.0.0)
Installing activesupport (3.0.7)
Installing builder (2.1.2)
Installing i18n (0.5.0)
Installing activemodel (3.0.7)
Installing erubis (2.6.6)
Installing rack (1.2.2)
Installing rack-mount (0.6.14)
Installing rack-test (0.5.7)
Installing tzinfo (0.3.27)
Installing actionpack (3.0.7)
Installing mime-types (1.16)
Installing polyglot (0.3.1)
Installing treetop (1.4.9)
Installing mail (2.2.19)
Installing actionmailer (3.0.7)
Installing arel (2.0.10)
Installing activerecord (3.0.7)
Installing activeresource (3.0.7)
Installing addressable (2.2.2)
Installing xml-simple (1.0.13)
Installing aws-s3 (0.6.2)
Using bundler (1.0.14)
Installing columnize (0.3.1)
Installing crack (0.1.8)
Installing factory_girl (1.3.2)
Installing thor (0.14.6)
Installing railties (3.0.7)
Installing rails (3.0.7)
Installing factory_girl_rails (1.0)
Installing multipart-post (1.0.1)
Installing faraday (0.5.3)
Installing fastercsv (1.5.3)
Installing json (1.4.6) with native extensions
/Users/jason/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/installer.rb:533:in
`build_extensions’: ERROR: Failed to build gem native extension.
(Gem::Installer::ExtensionBuildError)

    /Users/jason/.rvm/rubies/ruby-1.8.7-p334/bin/ruby extconf.rb

checking for re.h… yes
creating Makefile

make
Makefile:128: warning: overriding commands for target
/Users/jason/Projects/' Makefile:122: warning: ignoring old commands for target/Users/jason/Projects/’
gcc -I.
-I/Users/jason/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-darwin10.7.0
-I/Users/jason/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-darwin10.7.0
-I. -DHAVE_RE_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -O3
-fno-common -pipe -fno-common -Wall -c generator.c
generator.c:322: warning: ‘fbuffer_free_only_buffer’ defined but not
used
cc -dynamic -bundle -undefined suppress -flat_namespace -o
generator.bundle generator.o -L.
-L/Users/jason/.rvm/rubies/ruby-1.8.7-p334/lib -L. -lruby -ldl
-lobjc

make install
Makefile:128: warning: overriding commands for target
/Users/jason/Projects/' Makefile:122: warning: ignoring old commands for target/Users/jason/Projects/’
mkdir -p /Users/jason/Projects/
mkdir -p (fb)/2/json/ruby/1.8/gems/json-1.4.6/ext/json/ext/json/ext
/bin/sh: -c: line 0: syntax error near unexpected token (' /bin/sh: -c: line 0:mkdir -p
(fb)/2/json/ruby/1.8/gems/json-1.4.6/ext/json/ext/json/ext’
make: *** [(fb)/2/json/ruby/1.8/gems/json-1.4.6/ext/json/ext/json/ext]
Error 2

Gem files will remain installed in /Users/jason/Projects/
(fb)/2/json/ruby/1.8/gems/json-1.4.6 for inspection.
Results logged to /Users/jason/Projects/
(fb)/2/json/ruby/1.8/gems/json-1.4.6/ext/json/ext/generator/gem_make.out
from
/Users/jason/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/installer.rb:486:in
each' from /Users/jason/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/installer.rb:486:inbuild_extensions’
from
/Users/jason/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/installer.rb:159:in
install' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/source.rb:101:ininstall’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/rubygems_integration.rb:78:in
preserve_paths' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/source.rb:91:ininstall’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/installer.rb:58:in
run' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/rubygems_integration.rb:93:inwith_build_args’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/installer.rb:57:in
run' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/spec_set.rb:12:ineach’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/spec_set.rb:12:in
each' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/installer.rb:49:inrun’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/installer.rb:8:in
install' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/cli.rb:222:ininstall’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/vendor/thor/task.rb:22:in
send' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/vendor/thor/task.rb:22:inrun’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/vendor/thor/invocation.rb:118:in
invoke_task' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/vendor/thor.rb:246:indispatch’
from
/Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/lib/bundler/vendor/thor/base.rb:389:in
start' from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/gems/bundler-1.0.14/bin/bundle:13 from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/bin/bundle:19:inload’
from /Users/jason/.rvm/gems/ruby-1.8.7-p334@global/bin/bundle:19

I figured this out – my project path had odd characters in it. The path
of my app had a space and parenthesis in it – like so:

/Users/jason/Projects/MyApp (fb)/

this was messing up the native extension compile, it was hiccuping on
this.