How to resolve "ERROR: Failed to build gem native extension." - ruby-on-rails

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.

Related

Could not find gem 'rails (= 4.2.4) x64-mingw32'

I was first developing my RoR application in Windows. Now since I've been founding a few problems regarding some gems, SSH and stuff I decided to move to Linux. I am trying to initate the application, but It seems I am not able to.
When I do bundle update rails I got the following error:
Could not find gem 'rails (= 4.2.4) x64-mingw32' in the gems available on this
machine.
This is my tzinfo-data gem:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
But I have already tried with this one too:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Any idea? Because when I just do bundle install I also got the following error:
You have requested:
rails = 4.2.4
The bundle currently has rails locked at 4.2.4.
Try running `bundle update rails`
Update:
Gemfile content
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'
gem 'devise'
gem 'bootstrap_form'
# 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-ruby", '~> 3.0.0'
gem 'google-api-client', '0.9'
gem 'letsrate'
gem 'will_paginate', '~> 3.0.6'
gem 'filterrific'
#gem 'ratyrate'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
If you’ve installed Rails using bundler and rubygems, make sure you have the latest version in your Gemfile:
rails '4.2.4'
there is Gemfile.lock which locks the version. You delete that and run again bundle install. it will work.
bundle install
Visit https://rubygems.org/gems
Search for your gem. Once found, copy the text from the box titled GEMFILE
Add the copied text in your Gemfile found inside your app
Run bundlefrom the console opened at the root of your app.
On successful installation of the gems your console will display the message:
Bundle complete! xx Gemfile dependencies, xx gems now installed.

An error occurred while installing eventmachine (1.0.3) [duplicate]

This question already has answers here:
gem eventmachine fatal error: 'openssl/ssl.h' file not found
(15 answers)
Closed 7 years ago.
I have Rails 4.2.5 and ruby 2.0.0 installed.
This is a Gemfile of a project :
source 'https://rubygems.org'
gem "whenever"
gem "therubyracer"
gem "less-rails"
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'geokit'
gem 'sequenced'
gem 'acts-as-taggable-on'
gem 'bcrypt', :require => 'bcrypt'
gem 'rack-cors', :require => 'rack/cors'
# Paperclip
gem "paperclip", "~> 4.2"
gem "thin"
gem "passenger"
gem 'geocoder'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use sqlite3 as the database for Active Record
gem 'mysql2'
# 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
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
When I make bundle install I receive the following error :
"An error occurred while installing eventmachine (1.0.3), and Bundler cannot continue. Make sure that gem install eventmachine -v '1.0.3' succeeds before bundling."
And if I make gem install eventmachine I have the following error
make "DESTDIR=" compiling binder.cpp
In file included from binder.cpp:20:
./project.h:116:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
^
1 error generated.
make: *** [binder.o] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/eventmachine-1.0.8 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/eventmachine-1.0.8/ext/gem_make.out
How Can I fix it?
I had this problem before and running the command below worked
gem install eventmachine -v '1.0.3' -- --with-cppflags=-I/usr/local/opt/openssl/include
I can't remember where I found it or the reason why this work. Maybe someone else can complement the answer.

Could not find gem 'rails (= 4.2.5) x86-mingw32' when running rails server

I'm trying to learn Ruby on Rails.
Currently been trying out Rails framework. I've installed it. Create new project in MyBlog folder, but when I try to run:
rails server
I get back an error:
Could not find gem 'rails (= 4.2.5) x86-mingw32' in any of the gem sources listed in your Gemfile or available on this machine. Run `bundle install` to install missing gems.
I've installed bundle as suggested. Had few problems with installing it as well, but I've found a soultion on the internet.
Before bundle install I was getting another error saying that it could not find gem 'sqlite3'
Did someone had similar problem? Can you help me with solving it?
Update:
Content of my Gemfile is:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Errors when try to run 'bundle install':
Try to install the following packages to succeed bundle install
sudo apt-get install build-essential
sudo apt-get install libgmp3-dev
These packages are for Linux environment. Find the alternatives for other environments. Let me know if you got any error.
open file Gemfile.lock, find and delete "x64-mingw32" then run the command:-
$bundle install
Late answer but this happened to me just now.
What worked for me was figuring out I accidently installed an older Ruby version.
In your last screenshot you received a line:
Make sure that `gem install json -v '1.8.3'` succeeds before bundling
This command probably failed due to an older Ruby version, get the latest version here (Assuming you're a windows user) https://rubyinstaller.org/downloads/
P.S
Make sure you remove any previous Ruby / Rails installations.
What you need is a "With DEVKIT" installer, preferably the one they recommend on (starts with "=>").

Ruby "bundle install" error on Openshift

I'am fairly new in Ruby and terms of deploying app through remote tools. I've tried to deploy my App on free openshift account. And I connot run application.
When I run application i get this error:
You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0.
Using bundle exec may solve this. (Gem::LoadError)
So I try to run bundle exec but i got another error:
Gemfile syntax error:
/var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/Gemfile:24:
syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0', group: :doc
I think it might be because I used Ruby 2.1.5 on local and Open shift runs Ruby 2.0 by default.
I had foud this topic How can I force a bundle install on OpenShift Online when my RAILS_ENV is set to development?
but i don't know if I am doing it right. I don't even know where to put this pre_build file. I tried to put it under /var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/.openshift/action_hooks/ . But I'm not sure if runtime is right repo.
EDIT 1:
This it my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.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.
group: :doc do
gem 'sdoc', '~> 0.4.0'
end
# 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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
SOLUTION:
As #Rajarshi Das said I had to change
gem 'sdoc', '~> 0.4.0', group: :doc
into
group: :doc do
gem 'sdoc', '~> 0.4.0'
end
I don know exactly why. Maybe some syntax issues as I was using Ruby 2.1.5 on local, and had to use 2.0.0 on production. And after that I had to run gem install rails even though I used rails quick start. Finally I had to manually add to Gemfile gem 'nokogiri'. Finally I could run bundle install and application started to work.
You can simply solve the error by following way
group :doc do
gem 'sdoc', '~> 0.4.0'
end
For platforms
platforms :jruby, :mingw, :mswin do
gem 'tzinfo-data'
end
Remove Gemfile.lock as You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0
Then check bundle install
I ssh to $app_root directory
gem install rack
it worked
Make sure your branch is being used for deployment
rhc app-configure --deployment-branch [BRANCH]
Then in your development environment update gems
# bundle install
It will change Gemfile.lock
$ git add -A
$ git commit -am "Updating gemfile"
$ git push
Wait until deployment is updated
I tried most of the solutions here, but I still got stuck. What the problem was is to install bundle for the current version of ruby being used. You will want to do a gem install bundler in app-root/runtime/repo.
Then RAILS_ENV=production bundle exec rails console
You can refer to this answer

Ruby Gemfile can not add the PostgreSQL gem

Here's my Gemfile:
source 'https://rubygems.org'
#my added gems
gem 'pg', '~> 0.17.1'
gem 'rails_12factor', '0.0.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# 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
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
You can see on the 4th line that I add the line for the pg gem. After saving and running bundle install in my terminal I get the following error with this error:
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
Anyone know how to get around this?
Did you try before bundle install what the message says?
gem install pg -v '0.17.1'
Also, If you are running this locally and you need postrgre just to deploy the app to a server like Heroku(you are using sqlite/mysql locally) add it to the production enviroment like this:
group :production do
gem 'pg'
end
and run
bundle install
again.

Resources