Issue with "ERROR: Failed to build gem native extension" - ruby-on-rails

I am attempting to run bundle install on a github file for a tutorial about Rails testing. When I attempt to run
bundle install
It installs most of my gems and then gives me this very long error. I've attempted to update both xcode and homebrew and it hasn't helped. Any advice would be very appreciated!
Here is the error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.7.6/ext/json/ext/generator
/Users/johnseabolt/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170209-69149-18f1540.rb extconf.rb
creating Makefile
current directory: /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.7.6/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.7.6/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:179:47: error: too few arguments provided to function-like macro invocation
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
/Users/johnseabolt/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/intern.h:797:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) __extension__ ( \
^
In file included from generator.c:1:
./../fbuffer/fbuffer.h:179:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned
long') with an expression of type 'VALUE (const char *, long)' (aka 'unsigned long (const char *, long)')
[-Wint-conversion]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^ ~~~~~~~~~~
1 warning and 1 error generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.7.6 for
inspection.
Results logged to
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/json-1.7.6/gem_make.out
An error occurred while installing json (1.7.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.6'` succeeds before bundling.
Johns-MacBook-Pro:expense_tracker johnseabolt$
Here is the gem file for the app I cloned from Github:
source 'https://rubygems.org'
gem 'rails', '3.2.11'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
group :development, :test do
gem "rspec-rails", "~> 2.0"
end
group :test do
gem 'factory_girl_rails'
gem 'capybara'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
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
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'

Try to run following command and then run bundle install
gem system --update

Related

"rake db:migrate" results in "The bundle currently has pg locked at 0.18.4"

I generated this scaffold in Rails. Then I did a "rake db:migrate". Then I got:
[31mYou have requested:
pg >= 0
The bundle currently has pg locked at 0.18.4.
Try running `bundle update pg`[0m
[33mRun `bundle install` to install missing gems.[0m
Then I did "bundle update" and "bundle install" which resulted in:
Installing pg 0.18.4 with native extensions
C:/jruby-9.0.4.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:39: warning: Tempfile#unlink or delete called on open file; ignoring
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/jruby-9.0.4.0/bin/jruby.exe -r ./siteconf20151205-6108-1bkqm97.rb >extconf.rb
NotImplementedError: C extensions are not supported
<top> at C:/jruby-9.0.4.0/lib/ruby/stdlib/mkmf.rb:1
require at org/jruby/RubyKernel.java:939
(root) at C:/jruby>9.0.4.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
<top> at extconf.rb:2
extconf failed, exit code 1
Gem files will remain installed in C:/jruby- 9.0.4.0/lib/ruby/gems/shared/gems/pg-0.18.4 for inspection.
Results logged to C:/jruby- 9.0.4.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.2.0/pg- 0.18.4/gem_make.out
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
In my Gemfile, I tried making "gem 'pg'" plain, then "bundle install"ing, but still got the error message.
Here's my Gemfile:
source 'https://rubygems.org'
group :production do
gem 'rails_12factor'
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'coffee-script-source', '1.8.0'
Looks like you're on a Windows machine running jRuby. Try using one of the following gems instead of pg:
https://github.com/jruby/activerecord-jdbc-adapter
https://github.com/headius/jruby-pg
This answer might also be of help:
unable to install pg gem

How do I get json gem 1.7.7 to Update?

I'm trying to run a rails app on my Windows 8.1 computer, but I need json gem version 1.8.1. I currently have json 1.7.7. Bundle install returns an error and asks for me to make sure "gem install json -v 1.8.1" succeeds. Running that command returns
E:\rails_projects\bookit>gem install json -v 1.8.2
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe -r ./siteconf20150212-3852-vjuo23.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
generating generator-x64-mingw32.def
compiling generator.c
make: x86_64-w64-mingw32-gcc: Command not found
make: *** [generator.o] Error 127
make failed, exit code 2
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/json-
1.8.2 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.
0/json-1.8.2/gem_make.out
E:\rails_projects\bookit>
I added the DevKit path to my list of environment variables. I find it odd that I am having a problem with DevKit because green_shoes installs and works fine, and it requires DevKit. What am I missing?
Note:
I am using Ruby 2.0.0, 64-bit, as well as the corresponding DevKit as recommended by rubyinstaller.org
EDIT: Gemfile for my rails app
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.1.4'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'barista'
gem 'jquery-rails'
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails', '2.14.0'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.0'
end
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
https://github.com/rails/turbolinks
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
group :doc do
gem 'sdoc', '~> 0.4.0', require: false
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
This is your error:
make: x86_64-w64-mingw32-gcc: Command not found
--
The error is caused because the gcc/gc++ compiler is not found on your computer.
You should refer to this page for more information on this.
You should download this build kit, install it and then run the following:
set PATH=c:/path/to/your/mingw64/installation;%PATH%
Then perform the build again - it should work.

How to resolve "ERROR: Failed to build gem native extension."

Hello please help me to resolve this error.I wanted to design a chat application using private_pub gem.i add the code gem private_pub in my gem file.when i run the command bundle in command prompt it gave the following error.
Errors:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20141218-3932-nyliv2.rb extconf.rb
creating Makefile
make clean
Makefile:165: *** target pattern contains no `%'. Stop.
make
Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/http_pars
er.rb-0.6.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/ht
tp_parser.rb-0.6.0/gem_make.out
An error occurred while installing http_parser.rb (0.6.0), and Bundler cannot
continue.
Make sure that `gem install http_parser.rb -v '0.6.0'` succeeds before bundling.
I already have all installation before my system.I am using ruby-1.9.3, rails-4 and i already installed the proper devkit for ruby 1.9.3.Please provide me the step by step process to solve the above error.
Here is my gemfile.
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'private_pub'
as Show in Error Report You Need To insatll "gem http_parser.rb (0.6.0)" before installing gem private_pub.
to install http_parser.rb (0.6.0),
add gem 'http_parser.rb', '~> 0.6.0' in your gem file.then run the command bundle.

When I run bundle install i'm getting error with bcrypt gem

I'm not able to install bcrypt
My environment - Mac Yosemite 10.10, Ruby - 1.9.3 p547, Rails - 3.2.15.
When I run bundle install i'm getting like this.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/mohit/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile
make clean
make
compiling bcrypt_ext.c
make: *** [bcrypt_ext.o] Segmentation fault: 11
make failed, exit code 2
Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p547/gems/bcrypt-3.1.9 for inspection.
Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/bcrypt-3.1.9/gem_make.out
An error occurred while installing bcrypt (3.1.9), and Bundler cannot continue.
Make sure that `gem install bcrypt -v '3.1.9'` succeeds before bundling.
Like
Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.15'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
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
#gem 'devise'
gem 'jquery-rails'
gem "sorcery"
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
Here's what I found that corrected my problem when I encountered the same error:
xcode-select --install
bundle install
Of note, I'm also on Yosemite but Ruby 2.1.3, Rails 4.1.6.
I made changes in the gem file by replacing gem 'bcrypt' instead of gem 'bcrypt-ruby' and did bundle install and worked for me!!
Finally I figured it out by copying the exact word of the bcrypt from the rubygems.org, then made slight changes in name, and then I did bundle install and it worked.

The system cannot find the path specified because of ExecJS::RuntimeError

I'm running Windows 7 x64, Ruby on Rails 3.2.13 from RailsInstaller.
When I run my thin server and reload the Local Host I run into this:
$ thin start
>> Using rack adapter
>> ......
>> Listening on 0.0.0.0:3000, CTRL+C to stop
The system cannot find the path specified.
This is because of the error:
ExecJS::RuntimeError at /
["ok","(function() {\n\n\n}).call(this);\n"]
(in C:/Users/..../assets/javascripts/info.js.coffee)
info.js.coffee being an empty file and recent one I created from rails g controller info. In my browser with the better_errors gem, I see I have an error with the application layout on this line:
6 <%= javascript_include_tag "application" %>
I've been trying to correct this issue and did everything that was done in this question yet none of it worked. I uninstall Node.js completely but then it won't even let me run the server since it tells me I need a javascript runtime script and the default Windows one doesn't work.
Just now I tried to do gem install coffee-rails but run into this error:
gem install coffee-rails
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
The system cannot find the path specified.
ERROR: Error installing coffee-rails:
ERROR: Failed to build gem native extension.
c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
creating Makefile
I think I'm on to something. Does anyone know how to install this?
EDITS
Gem File:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'jquery-rails'
gem 'devise'
gem 'execjs'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
group :development do
gem 'sqlite3'
gem 'better_errors'
gem 'thin'
gem 'eventmachine', '1.0.3'
end
group :test do
gem 'factory_girl_rails'
gem 'capybara'
gem 'shoulda-matchers'
end
group :test, :development do
gem 'rspec-rails'
end
You have to install an additional gem for javascript, just edit Gemfile and add
gem 'therubyracer'
or for windows
gem 'therubyracer', :platform => :ruby

Resources