Rails installation fails while running make nior4 - ruby-on-rails

I’m trying to install the current stable version of rails (5.2)
gem install rails
but it fails:
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /Users/ms1/.rvm/gems/ruby-2.4.1/gems/nio4r-2.1.0/ext/nio4r
[…]
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:488:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL 0.00000095367431640625 /* 1/2**20, good till 2200 */
^
./../libev/ev.c:1068:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
[…]
fatal error: too many errors emitted, stopping now [-ferror-limit=]
9 warnings and 20 errors generated.
make: *** [nio4r_ext.o] Error 1
make failed, exit code 2
I’m on Mac OS X HighSierra (10.13.2) and I’ve installed Xcode (9.2) with developer / command-line tools (9.2), rvm 1.29.3, Homebrew 1.4.0, bundler 1.16.0, nokogiri 1.8.1.
I’m on ruby 2.4.1, but tried 2.4.2, 2.3.0, 2.2.2 as well, always with the same result.
Installing nio4r manually results in the same problem:
gem install nio4r
[…]
ERROR: Failed to build gem native extension.
Some answers on StackOverflow suggested
gem install nio4r -v '1.1.0' -- with-cflags="-std=c99"
which did not work, either.
Interestingly,
rails
gives me the following output on my machine:
Ignoring bigdecimal-1.3.2 because its extensions are not built.
Try: gem pristine bigdecimal --version 1.3.2
Rails is not currently installed on this system. To get the latest version, simply type: sudo gem install rails
Of course I tried both of the above mentioned hints, too; both result in the same problem as stated initially.
As I'm running out of ideas here and couldn't find any other helpful advice, I'm really looking forward for any ideas on this!

Filing an issue on nio4r's Github page solved my problem: There was an old port.h file from an abandoned Postgres installation in /usr/local/include/ on my system which was causing the trouble.
Removing /usr/local/include/port.h allowed me to install Rails!

Related

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.

not able to install ruby on rails in OSX mavericks

I have OSX mavericks and I was trying to install ruby on rails .First I tried Installing via RailsInstaller (http://railsinstaller.org/en) ,There was a notice in the website saying "Please do not run the installer on OSX Mavericks until further notice."
Then I tried installing using rvm which turned out to be a night mare .
I followed instructions from all the below links none seem to work
Installing Rails on Mavericks
Xcode install on OSX 10.9 - clang: error: no input files
Installing Rails on Mavericks
http://railsapps.github.io/installrubyonrails-mac.html
I have installed Xcode 5.0 and I have even manually downloaded Command lines tools
https://developer.apple.com/downloads/index.action
when I try
rails -v
I get a message
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
Then I tried command for which I got an error message
Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb checking for libkern/OSAtomic.h... yes creating Makefile
make "DESTDIR=" compiling atomic_reference.c atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
^~~~~~~~~~~~~~~ /usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
I'm not able to use xcode-select --install either which says the software is not present in the server
Please guide on how to install rails on my osx mavericks ?
Rails 4 needs RubyGems 2.0.3. Update it and you should be good to go.
gem update --system 2.0.3
Then,
gem install rails
Hope it helps.

New Rails Project: 'bundle install' can't install rails in gemfile

I have installed a new rails project like so:
$ rails new site
and it executes and reaches:
bundle install
but then I get this error, when it appears to try installing a dependency
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for libkern/OSAtomic.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling atomic_reference.c
atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
^~~~~~~~~~~~~~~
/usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
^
1 warning generated.
linking shared-object atomic_reference.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [atomic_reference.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/mikeguppy/.bundler/tmp/26234/gems/atomic-1.1.16 for inspection.
Results logged to /Users/mikeguppy/.bundler/tmp/26234/extensions/universal-darwin-13/2.0.0/atomic-1.1.16/gem_make.out
An error occurred while installing atomic (1.1.16), and Bundler cannot continue.
Make sure that `gem install atomic -v '1.1.16'` succeeds before bundling.
I have then tried installing atomic independently with:
gem install atomic
and again no luck.
I'm running Ruby 2.0 on Mac OS 10.9.2
Any help would be much appreciated!
this worked for me:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install rails
I had this same problem and what worked for me was installing RVM, installing Ruby 2.1.1 (an upgrade from the 2.0 that comes packaged in Mavericks)...
rvm get stable
rvm reinstall 2.1.1
(use whatever the latest version is, for me that's 2.1.1)
...and then run rvm use 2.1.1 to make sure that I had switched to using that version.
After that, my gem installs ran smoothly.
This appears to be an issue relating to the system Ruby that is packaged with Mavericks (2.0.0p247), see details about the bug here: https://bugs.ruby-lang.org/issues/9624
I got around this by installing rbenv (or RVM if you prefer) and then installing Ruby 2.1.1 so as not to tamper with the system Ruby version. You will still get a warning during the installation of the atomic gem but it won't fail at least.
rbenv here: https://github.com/sstephenson/rbenv
I had the same problem when installed rails.
My ruby version is 1.9.3 p448 and OS is OS X Mavericks (10.9.2).
Here's what I tried and it works.
$ gem install rails --version 4.0.4
[ref]
http://ruby.railstutorial.org/chapters/beginning#top
First uninstall any existing atomic gem
gem uninstall atomic
Then reinstall it using
gem install atomic -v '1.1.16'
After this try to create a new rails application
rails new projectname
I don't know which version of Rails you are currently using. Sometimes, re-installing Rails to a stable version seems to help. You may want to try that as well if the above steps didn't resolve the issue.
I had a similar problem recently and it was because Xcode updated automatically to 5.1. This version contains a bug/problem with gcc.
The clue is here:
-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning)
Sadly I had to downgrade Xcode - available here.
Ruby 2.1.5 on Maverick via rvm installed atomic 1.1.16 without issue.
This error can occur if you are bundling with the wrong version of ruby for the bundle. Check the Gemfile for the ruby version and then check the output of ruby -v. If there is a version mismatch, use rvm to make sure you are using the same version of ruby, then re-bundle.
I got this exact error and fixed it by changing the version of ruby I was using.
None of these worked for me. I came up with my own solution. The problem lies in json versions less than 2.0. When I tried to upgrade json, I got an error message about dependency issues with rails and sdoc. Here's what I ended up doing:
Open your Gemfile.
Comment out the lines for sdoc and rails.
Add this line:
gem 'json', '> 2'
Run bundle install.
Worked for me.

bundle throwing error Gem::Installer::ExtensionBuildError: ERROR: with Mavericks and ruby 2.0

Getting the below error when i run bundle from a 1.8.7 app. I just upgraded to Mavericks and am using rbenv.
Things I've tried already:
1) uninstall and reinstall rbenv and ruby-build
2) dropped the directory and re-cloned
3) installing x-code cli with xcode-select --install
4) brew install apple-gcc42
5) deleting the root ruby file (2.0) and replacing with 1.8
6) brew unlink apple-gcc42
None of the above have worked yet.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for re.h... no
creating Makefile
make "DESTDIR="
compiling parser.c
parser.rl:165:20: error: expected '(' after 'if'
if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:445:18: note: expanded from macro 'RTEST'
#define RTEST(v) !(((VALUE)(v) & ~Qnil) == 0)
^
1 error generated.
make: *** [parser.o] Error 1
Gem files will remain installed in /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6 for inspection.
Results logged to /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6/ext/json/ext/parser/gem_make.out
An error occurred while installing json (1.4.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.4.6'` succeeds before bundling.
I just got something similar when I changed an old Ruby 1.9.3 project to Ruby 2.2.0 and tried to bundle.
I got errors like parser.rl:139:20: error: expected '(' after 'if'" and " and accept.c:128:2: error: use of undeclared identifier 'TRAP_BEG'.
The fix was to upgrade the gems that failed to build: bundle update json kgio in my case, where the json gem and then the kgio gem failed to build.
If you've locked down the versions of a problematic gem in your Gemfile, you might want to unlock them, too. E.g. change gem "json", "1.1.6" to just gem "json". Though you should of course make sure you know why it was locked down in the first place.
When you just do bundle, it tries to install/build the gem versions listed in Gemfile.lock. Those will be the versions you installed previously on Ruby 1.8.7 in your case, or 1.9.3 in my case. I guess those gem versions are old enough that they simply don't compile for a newer Ruby.

Cannot install Puma gem on 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.

Resources