Cannot install Puma gem on Ruby on Rails - ruby-on-rails

I'm trying to install the puma gem, but when I run
gem install puma
I get this error message:
Temporarily enhancing PATH to include DevKit
Building native extensions. This could take a while...
ERROR: Error installing puma:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
generating puma_http11-i386-mingw32.def
compiling http11_parser.c
ext/http11/http11_parser.rl: In function 'puma_parser_execute':
ext/http11/http11_parser.rl:111:3: warning: comparison between signed and unsigned integer expressions
compiling io_buffer.c
io_buffer.c: In function 'buf_to_str':
io_buffer.c:119:3: warning: pointer targets in passing argument 1 of 'rb_str_new' differ in signedness
c:/Ruby193/include/ruby-1.9.1/ruby/intern.h:653:7: note: expected 'const char *' but argument is of type 'uint8_t *'
compiling mini_ssl.c
In file included from mini_ssl.c:3:0:
c:/Ruby193/include/ruby-1.9.1/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
mini_ssl.c:4:25: fatal error: openssl/bio.h: No such file or directory
compilation terminated.
make: *** [mini_ssl.o] Error 1
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/puma-2.6.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/puma-2.6.0/ext/puma_http11/gem_make.out
Adding gem 'puma' to my Gemfile and running bundle install isn't an option, because that just doesn't work with any gem and gives me an error message (which is a separate issue, one that I've circumvented with the other gems I've used by installing them via gem install).

Came across very same issue.
sudo apt-get install libssl-dev
fixed it for me.

I ran bundle update before bundle install and that solved the issue for me.
I'm not sure if that was the only thing that helped, as I manually updated puma before that, using these steps:
Checked which version of openssl Ruby is using by running ruby -v -ropenssl -e "puts OpenSSL::OPENSSL_VERSION"
Downloaded the right openssl version from
http://packages.openknapsack.org/openssl/openssl-1.0.0o-x86-windows.tar.lzma
(got the link from https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows and edited it based on the output of #1).
Extracted openssl using http://www.7-zip.org to C:\RailsInstaller\openssl
gem install puma -- --with-opt-dir=C:/RailsInstaller/openssl

Figured out the solution to the puma bundle. Followed directions from https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows
First you need to download:
DevKit compatible with your ruby version
OpenSSL Developer Package (contains header files and binaries)
And then:
Install DevKit, e.g. in c:\devkit
Unpack the OpenSSL Package, e.g. in c:\openssl (use 7Zip or PeaZip)
You need to copy the ddls from the bin directory (libeay32.dll and ssleay32.dll) to your ruby/bin directory.
Open a windows console
Initialize the DevKit build environment: c:\devkit\devkitvars.bat (except here, I used this in command prompt instead: ruby dk.rb init)
Now it’s possible to install the puma gem with the OpenSSL packages:
gem install puma -- --with-opt-dir=c:\openssl

I think you hit issue #430
https://github.com/puma/puma/issues/430
Re-installing Ruby might help you as well as it closed this issue on GitHub.

Related

ERROR: Failed to build gem native extension Windows 7 32 Bit

I am trying to install json ruby gem on Windows 7 32 System.
The local environment details are
D:\Environment\DevKit32Ruby200>gem -v
2.0.14
D:\Environment\DevKit32Ruby200>ruby -v
ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
D:\Environment\DevKit32Ruby200>rails -v
Rails 4.0.4
I have already tried following things
Downgrading system ruby gems version to 2.3.0 using
gem update --system 2.3.0
I have done proper setting of devkit and manually I added proper ruby directory path in config.yml file.
D:\Environment\DevKit32Ruby200>ruby dk.rb init
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.
D:\Environment\DevKit32Ruby200>ruby dk.rb install --force
[WARN] Updating (with backup) existing gem override for 'D:/Environment/ruby200new'
[WARN] Updating (with backup) DevKit helper library for 'D:/Environment/ruby200new'
I have also tried putting platform=ruby
gem install json --platform=ruby --verbose
The error I am getting while installing json is bellow.
D:\Environment\DevKit32Ruby200>gem install json
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.
D:/Environment/ruby200new/bin/ruby.exe extconf.rb
creating Makefile
make "DESTDIR="
generating generator-i386-mingw32.def
compiling generator.c
linking shared-object json/ext/generator.so
make "DESTDIR=" install
/usr/bin/install -c -m 0755 generator.so ./.gem.20170109-8336-qvgvzc/json/ext
make: execvp: /usr/bin/install: Permission denied
make: *** [install-so] Error 127
Gem files will remain installed in D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2 for inspection.
Results logged to D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2/ext/json/ext/generator/gem_make.out
There are 10's of questions are already tagged on this issue but none resolved.
Kindly help me to identify whats missing and why the error coming.
i386-mingw32 is a mountain of pain that'll never be fully supported, when I spent time on Windows I used to use a VirtualBox VM with ubuntu installed which shares a folder with the Windows host. I would edit the files with netbeans in windows and run the code in putty, the VM would basically be headless.
I actually did a lot of real work that way. If you want to do a "Hello World" rails app - OK - good luck even with that. How about an online development environment such as https://c9.io/ ?
But if you want to work, not just play around, set yourself up with an Ubuntu VM at the very least, or work in Ubuntu/MacOS at the very best.
Try this out:
Why don't you download the json .gem file from rubygems.org and install it directly using command
gem install json-x.x.x.gem

Running Rails application in docker container

I want to run a Rails 4.2.1 application in a docker container on a debian machine.
When I run bundle exec rails s I got this error:
Could not find json-1.7.7 in any of the sources
Run `bundle install` to install missing gems.
When I run bundle install I got this error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150604-137-10l84fa. rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function 'fbuffer_to_s':
../fbuffer/fbuffer.h:175:47: error: macro "rb_str_new" requires 2 arguments, but only 1 given
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
Makefile:237: recipe for target 'generator.o' failed
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/www/test/xyz/vendor/bundle/ruby/2 .2.0/gems/json-1.7.7 for inspection.
Results logged to /var/www/test/xyz/vendor/bundle/ruby/2.2.0/extensions/x 86_64-linux/2.2.0/json-1.7.7/gem_make.out
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.7'` succeeds before bundling.
Whats going wrong? what can I do now?
docker-rails is a project I just created to make rails with docker (and CI) very easy. I think it can help you and reduce the amount of configuration necessary to get up and running with rails on docker.
It creates a global shared gem volume (to speed up bundler), and has a sample Dockerfile for use.
Given that native error, I'm guessing your Dockerfile is missing a needed package, you may need to update your apt-get statements.
I got the same error. This error is because of the versions of ruby softwares (gems) that we uses doesn't match at some point.
You are using ruby version 2.2.1. Your Gemfile contains the gems of older versions and it depends on json version 1.7.7.
You should install the following ruby version:
ruby-1.9.3-p448
to get rid of the error, OR updating your gems that compatible with ruby version 2.2.1 will do the trick.

Errors installing Mongrel 1.2.0_pre2 on Ruby 2.1.x installed via PPA from Brightbox

I have inherited a Ruby on Rails application codebase as part of a new gig. The code is currently live in production but I have been charged with assessing and cleaning up. As such the code includes Mongrel dependencies; specifically Mogrel 1.2.0_pre2 which might have last been updated in 2010 but that is what this code uses.
The local development environment is running in Ubuntu 12.04 and have successfully installed all Ruby GEMs via bundle install when I install Ruby 2.1.x from source code.
But I recently learned about the Ubuntu ready packages from Brightbox I was thrilled! I don’t mind installing form source but would rather deal with the cleanliness of a package install. So, on a completely clean Ubuntu 12.04 system I started to rebuild my Ruby development box I added the PPA to my repo:
sudo add-apt-repository ppa:brightbox/ruby-ng
Updated the local sources list:
sudo aptitude update
And installed their Ruby 2.1 package like so:
sudo aptitude install ruby2.1 ruby2.1-dev
And things went well until during bundle install up until Mogrel died with compilation errors:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 extconf.rb
checking for main() in -lc... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling http11.c
http11.c: In function ‘http_field’:
http11.c:193:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c:194:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘request_uri’:
http11.c:235:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘fragment’:
http11.c:246:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘request_path’:
http11.c:257:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘query_string’:
http11.c:268:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘HttpParser_execute’:
http11.c:439:5: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [http11.o] Error 1
make failed, exit code 2
Gem files will remain installed in /tmp/bundler20141208-21746-1qez12a/mongrel-1.2.0.pre2/gems/mongrel-1.2.0.pre2 for inspection.
Results logged to /tmp/bundler20141208-21746-1qez12a/mongrel-1.2.0.pre2/extensions/x86_64-linux/2.1.0/mongrel-1.2.0.pre2/gem_make.out
An error occurred while installing mongrel (1.2.0.pre2), and Bundler cannot
continue.
Make sure that `gem install mongrel -v '1.2.0.pre2'` succeeds before bundling.
But running gem install mongrel -v '1.2.0.pre2' doesn’t seem to help; it goes through the expected motions and then fails with the exact same http11.c errors as when doing it via bundle install.
I have read a few threads Stack Overflow related to issues folks have had installing any version of Mongrel in Ruby 1.9.2 onwards such as in this thread and in this thread.
All of the solutions that are not focusing on “You should just use Thin instead.” talk about manually patching http11.c. But the references—like this page—are to Ruby 1.9.1 and Mongrel 1.1.5 and the line numbers referenced definitely don’t correspond to equivalents in Mogrel_1.2.0pre2.
And ironically some solutions actually direct a user to install Mogrel version 1.2.0pre2 instead of 1.1.5 to get around the issue; but I am trying to install version 1.2.0pre2 and can’t seem to get that done.
Of course I would like to know how to get past this Mongrel error, so help on that would be appreciated. But why is it that when I install Ruby 2.1.x via the Brightbox PPA this error pops up while if I compile Ruby 2.1.x directly from source this error just doesn’t appear at all?
Okay, so after some hunting around I stumbled across a solution which allows me to cleanly—without a need for manual patching—install Mogrel 1.2.0_pre2 on Ruby 2.1.x. The solution is to do a direct Ruby install of the GEM with --with-cflags like this:
sudo gem install mongrel -v 1.2.0.pre2 -- --with-cflags=\"-O2 -pipe -march=native -w\"
Once I did that compilation was completed without issue and the GEM was successfully installed:
Building native extensions with: '--with-cflags="-O2 -pipe -march=native -w"'
This could take a while...
Successfully installed mongrel-1.2.0.pre2
Parsing documentation for mongrel-1.2.0.pre2
Installing ri documentation for mongrel-1.2.0.pre2
Done installing documentation for mongrel after 1 seconds
1 gem installed
But I am still wondering why a Ruby 2.1.x install via the Brightbox PPA causes an issue when a pure source code install of Ruby 2.1.x has no problems at all.
And not 100% clear on how --with-cflags=\"-O2 -pipe -march=native -w\" factors into this, but it seems to be a common --with-cflags option used to get some stubborn (perhaps outdated?) Ruby GEMs installed on versions of Ruby higher than 1.9.2.

event machine gem bundle install is not working

I am following a tutorial and had to do a bundle install following the forking & cloning of a repository. Subsequently we are instructed to run bundle install. However, it is not working and I am getting the following error message:
make
generating rubyeventmachine-i386-mingw32.def
compiling binder.cpp
In file included from binder.cpp:20:0:
project.h:85:0: warning: "FD_SETSIZE" redefined
<command-line>:0:0: note: this is the location of the previous definition
compiling cmain.cpp
In file included from cmain.cpp:20:0:
project.h:85:0: warning: "FD_SETSIZE" redefined
<command-line>:0:0: note: this is the location of the previous definition
cmain.cpp: In function 'int evma_send_file_data_to_connection(long unsigned int,
const char*)':
cmain.cpp:752:6: error: 'fstati64' was not declared in this scope
make: *** [cmain.o] Error 1
Gem files will remain installed in c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0
.0/gems/eventmachine-0.12.10 for inspection.
Results logged to c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/eventmach
ine-0.12.10/ext/gem_make.out
An error occurred while installing eventmachine (0.12.10), and Bundler cannot
continue.
Make sure that `gem install eventmachine -v '0.12.10'` succeeds before bundling.
I'm rather stuck on what to do at this point. I am on a Windows machine, any advice on how to troubleshoot this?
Try gem install eventmachine -v '0.12.10' Or sudo gem install eventmachine -v '0.12.10' and then retry bundle install.
Some gem needs sudo privileges to install.
For windows gem install eventmachine --pre. Its a known issue for window with ruby 1.9. https://github.com/eventmachine/eventmachine/issues/319
I was able to fix this by installing the latest version of the Eventmachine gem: https://rubygems.org/gems/eventmachine
And then subsequently instaling the latest version of the SQLite gem:
http://rubygems.org/gems/sqlite3-ruby
You might be prompted to update your Gemlockfile make sure to do that then everything else should work.

how to install caldecott on win 7?

I have created an and I want to upload that on phpfog but I am getting trouble while uploading my database here on the first step, I have win 7 x64 , I downloaded and installed command prompt with ruby, while creating a tunnel :
C:\Ruby200\devkit>gem install caldecott --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing caldecott:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
creating Makefile
make
generating generator-i386-mingw32.def
compiling generator.c
generator.c: In function 'cState_aref':
generator.c:632:5: warning: variable 'state' set but not used [-Wunused-but-set-
variable]
generator.c: In function 'isArrayOrObject':
generator.c:867:5: warning: suggest parentheses around '&&' within '||' [-Wparen
theses]
linking shared-object json/ext/generator.so
make install
/usr/bin/install -c -m 0755 generator.so C:/Ruby200/lib/ruby/gems/2.0.0/gems/jso
n-1.6.8/ext/json/ext/json/ext
/usr/bin/install: cannot create regular file `C:/Ruby200/lib/ruby/gems/2.0.0/gem
s/json-1.6.8/ext/json/ext/json/ext': No such file or directory
make: *** [install-so] Error 1
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.
8 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.8/ext/json/ext/ge
nerator/gem_make.out
C:\Ruby200\devkit>gem install caldecott --platform=ruby
`
I have Win7 x64, Ruby 2.0.0, DevKit (DevKit-mingw64-32-4.7.2-20130224-1151)
I faced the same issue. My solution:
Download gem source from github - https://github.com/cloudfoundry/caldecott/archive/master.zip
Unzip to C:\caldecott (for example)
Open file caldecott.gemspec and change version of json dependency to "~> 1.7"
Open command prompt, move to gem source directory and perfrom:
gem build caldecott.gemspec
gem install caldecott-0.0.5.gem
That's all
This error occurs with Ruby 2.0.0 version. Downgrade to Ruby 1.9.3

Resources