问题
I copied the application from production and did bundle install to install all the missing gems that are in production version and not on my local machine.
Gem.lock file has the rubyracer version '0.10.1'. So when it tried to install this version using bundle install following error appeared.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/user/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/user/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
extconf.rb:15:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)
Gem files will remain installed in /home/user/.rvm/gems/ruby-1.9.3-p392/gems/therubyracer-0.10.1 for inspection.
Results logged to /home/user/.rvm/gems/ruby-1.9.3-p392/gems/therubyracer-0.10.1/ext/v8/gem_make.out
I am not able to run the scaffolding commands on my production version of code from my local machine because of this error . Please help me out.
Can we edit the gemfile.lock to remove "therubyracer (0.10.1)" and then run the command generate scaffold and then place back the changes after my use of generate scaffold ?
EDIT :
*** 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/vsadhu/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
extconf.rb:14:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)
回答1:
In response to the following quote:
Can we edit the gemfile.lock to remove "therubyracer (0.10.1)"
No we cannot. Dependent on what OS you are on you can do the following:
$gem uninstall libv8
$gem install therubyracer
I have a rails application that I recently did and I too was running Rails 3.2.14 and had the following:
group :assets do
gem 'therubyracer', :require => 'v8'
gem 'less-rails'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
Should you go with this second method please before you add this asset block to your gemfile. Delete your Gemfile.lock
and then add the asset block to the Gemfile, save it and run bundle update
来源:https://stackoverflow.com/questions/18513309/failed-to-build-gem-native-extension-ruby-racer-gem-of-different-version