Bundle Install Rsruby Fails, But Gem Install Succeeds - ruby

I have ruby2.2, ubuntu 14.04.4 LTS, and I want to install the rsruby gem. Everything is set up, and all my other gems are set up, with "sudo bundle install." But rsruby keeps crashing when I try to install it like that. How do I debug it and make it work?
I have a script I run which runs this command
sudo bundle config build.rsruby "--with-R-include=/usr/share/R/include --with_cflags=\"-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall -fno-strict-aliasing\""
Then I run "sudo bundle install" and it crashes on RSRuby:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.2 -r ./siteconf20161028-31919-l2ks0n.rb extconf.rb
--with-R-include=/usr/share/R/include --with_cflags=\"-fPIC -g -O2
-fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall
-fno-strict-aliasing\"
checking for main() in -lR... *** 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.
from /usr/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
from /usr/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
from /usr/lib/ruby/2.2.0/mkmf.rb:735:in `try_func'
from /usr/lib/ruby/2.2.0/mkmf.rb:992:in `block in find_library'
from /usr/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'
from /usr/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /usr/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
from /usr/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /usr/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
from /usr/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
from /usr/lib/ruby/2.2.0/mkmf.rb:988:in `find_library'
from extconf.rb:15:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in
/var/lib/gems/2.2.0/bundler/gems/rsruby-e72a8dc61617 for inspection.
Results logged to
/var/lib/gems/2.2.0/bundler/gems/extensions/x86_64-linux/2.2.0/rsruby-e72a8dc61617/gem_make.out
An error occurred while installing rsruby (0.5.5), and Bundler cannot
continue.
But if I run
sudo gem install rsruby -- --with-R-dir=/usr/lib/R --with-R-include=/usr/share/R/include --with_cflags="-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall -fno-strict-aliasing"
Then it successfully installs
Fetching: rsruby-0.5.1.1.gem (100%)
Building native extensions with: '--with-R-dir=/usr/lib/R --with-R-include=/usr/share/R/include --with_cflags=-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall -fno-strict-aliasing'
This could take a while...
Successfully installed rsruby-0.5.1.1
Parsing documentation for rsruby-0.5.1.1
Installing ri documentation for rsruby-0.5.1.1
Done installing documentation for rsruby after 0 seconds
1 gem installed
SO, my question is, how do I debug this? And how do I get it working with bundle install? Thanks!
UPDATE, as matt pointed out in the comments, the version of the rsruby gem installed by the two commands was different. if i change my Gemfile to specify bundle to install version "0.5.1.1" then "sudo bundle install" installs successfully. however, i need version "0.5.5". my Gemfile is currently set up like this, "gem 'rsruby', github: 'custora/rsruby'" and must get version 0.5.5. so why would 0.5.1.1 install correctly, but not 0.5.5?
UPDATE, mkmf.log
gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.1.0 -I/usr/include/ruby-2.1.0/ruby/backward -I/usr/include/ruby-2.1.0 -I. -I/usr/share/R/include -D_FORTIFY_SOURCE=2 "-g conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.1-3vrZnx/ruby2.1-2.1.9/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.1 -lpthread -lgmp -ldl -lcrypt -lm -lc"
sh: 1: Syntax error: Unterminated quoted string
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */

Okay so there were a few different things going on here. I will document them all here in case someone else who needs to use rsruby comes across this. First, as Matt pointed out, bundle install and gem install were trying to install two different versions of rsruby. Second, I had to change this script which I ran to set the bundle configuration options, this script did NOT work. To make this work, I replaced the \" with '
#!/bin/bash
# Does /usr/bin/gem link to /usr/bin/gem2.1 ?
# gem install bundler -v 1.6.0.rc2
sudo bundle config build.rsruby "--with-R-include=/usr/share/R/include --with-cflags=\"-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -fPIC\""
The above two steps made rsruby install. But after that I kept getting segfault errors anyway. The problem seems to have been either an old distro of ubuntu, or the fact that since it was an old distro of ubuntu, I had to use brightbox repo to get a more recent version of ruby. In any case, after updating to a current distro of linux which had a current version of ruby, it worked.

Related

Failed to install gem rest-client

I am trying to install gem res-client in my redhat linux server.Installed whatever dependencies i found but still not working for me.
Ruby Version:
ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-linux]
[root#feeds ]# gem install rest-client
Building native extensions. This could take a while...
ERROR: Error installing rest-client:
ERROR: Failed to build gem native extension.
current directory: /opt/rh/rh-ruby23/root/usr/local/share/gems/gems/unf_ext-0.0.7.6/ext/unf_ext
/opt/rh/rh-ruby23/root/usr/bin/ruby -I /opt/rh/rh-ruby23/root/usr/local/share/ruby/site_ruby -r ./siteconf20190429-62674-e4of20.rb extconf.rb
checking for main() in -lstdc++... no
creating Makefile
current directory: /opt/rh/rh-ruby23/root/usr/local/share/gems/gems/unf_ext-
0.0.7.6/ext/unf_ext
make "DESTDIR=" clean
rm -f
rm -f unf_ext.so *.o .bak mkmf.log ..time
current directory: /opt/rh/rh-ruby23/root/usr/local/share/gems/gems/unf_ext-0.0.7.6/ext/unf_ext
make "DESTDIR="
g++ -I. -I/opt/rh/rh-ruby23/root/usr/include -I/opt/rh/rh-ruby23/root/usr/include/ruby/backward -I/opt/rh/rh-ruby23/root/usr/include -I. -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic -m64 -o unf.o -c unf.cc
make: g++: Command not found
make: *** [unf.o] Error 127
make failed, exit code 2
Gem files will remain installed in /opt/rh/rh-ruby23/root/usr/local/share/gems/gems/unf_ext-0.0.7.6 for inspection.
Results logged to /opt/rh/rh-ruby23/root/usr/local/lib64/gems/ruby/unf_ext-0.0.7.6/gem_make.out
Can anyone please suggest.
Thanks
Sina
It looks like you are missing the gcc-c++ compiler. Install it with:
yum install gcc-c++
build-essential g++ are the missing ones. So try installing:
yum install build-essential g++
then install the required gem:
gem install rest-client
hope it helps....
Thanks .
I reinstall ruby and dependencies then it worked.
Regards,
Sina

ERROR: failed to build gem native extension, Linux virtual machine

I'm running Ruby 2.0.0p645 on a Linux AWS.
I tried running gem install mechanize, but got this error:
Building native extensions. This could take a while...
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb
checking for main() in -lstdc++... no
creating Makefile
make "DESTDIR="
g++ -I. -I/usr/include/ruby/2.0 -I/usr/include/ruby/2.0/ruby/backward -I/usr/include/ruby/2.0 -I. -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -m64 -o unf.o -c unf.cc
make: g++: Command not found
make: *** [unf.o] Error 127
Gem files will remain installed in /path/to/.gem/ruby/2.0/gems/unf_ext-0.0.7.1 for inspection.
Results logged to /path/to/.gem/ruby/2.0/gems/unf_ext-0.0.7.1/ext/unf_ext/gem_make.out
How do I fix this so I can install mechanize on my virtual box?
Looks like you might need to install libstdc++. For Debian or Ubuntu try:
sudo apt-get install build-essential libstdc++6
and then retry installing the gem.

Failing to install ruby gem "yajl-ruby"

I am trying to install the ruby gem "yajl ruby". I'm running Mac OS 10.7.4 and Ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]. When I run:
sudo gem install yajl-ruby
I get the following output:
Building native extensions. This could take a while...
ERROR: Error installing yajl-ruby:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
gcc -I. - I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe - fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -funroll-loops -c yajl.c
make: gcc: No such file or directory
make: *** [yajl.o] Error 1
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0/ext/yajl/gem_make.out
What do I need to do in order to make the install work?
Try this:
$ sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2
It's a bit roundabout, but have you considered using RVM to manage your Ruby versions? As this you're working on an OS X box, I'm assuming it's your dev machine and so having a system-wide gem probably isn't as big a deal. RVM changes the paths for installing gems to be relative to the Ruby version in use and, as the paths are local to your user directory, you don't need to use sudo and thus avoid potential permission errors which is what I suspect is happening here.
I say I suspect it's a permission error because the missing file suggests something wasn't written to where it's expected to be. It's just a shot in the dark, though. Alternatively, you could try actually su'ing to root and doing the gem install there, but that's ugly.
I had a similar error installing yajl-ruby.
The error was that /Developer/usr/bin wasn't available. Doing an "ln -s /Applications/Xcode.app/Contents/Developer/usr/ /Developer/usr" fixed the error.
Here is the specific error I was seeing:
gem install yajl-ruby
Building native extensions. This could take a while...
ERROR: Error installing yajl-ruby:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -funroll-loops -c yajl.c
sh: /Developer/usr/bin/xcodebuild: No such file or directory
/Developer/usr/bin/xcodebuild fails with 32512 - Unknown error: 32512
make: *** [yajl.o] Error 69
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0/ext/yajl/gem_make.out

RVM - can not install gem thrift on Ubuntu 11.10

I use Ubuntu 11.10 and ruby 1.9.2
I can not install thrift gem on my machine
$ gem install thrift --no-ri --no-rdoc
Building native extensions. This could take a while...
ERROR: Error installing thrift:
ERROR: Failed to build gem native extension.
/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for strlcpy() in string.h... no
creating Makefile
make
gcc -I. -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -fPIC -g -O2 -Wall -Werror -o thrift_native.o -c thrift_native.c
gcc -I. -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -fPIC -g -O2 -Wall -Werror -o memory_buffer.o -c memory_buffer.c
gcc -I. -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -fPIC -g -O2 -Wall -Werror -o struct.o -c struct.c
struct.c:28:1: error: static declaration of ‘strlcpy’ follows non-static declaration
/home/sayuj/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/missing.h:157:20: note: previous declaration of ‘strlcpy’ was here
make: *** [struct.o] Error 1
Gem files will remain installed in /home/sayuj/.rvm/gems/ruby-1.9.2-p290/gems/thrift-0.7.0 for inspection.
Results logged to /home/sayuj/.rvm/gems/ruby-1.9.2-p290/gems/thrift-0.7.0/ext/gem_make.out
What went wrong and how to fix? All your support willbe highly appreciated. thanks!
I found some references to this issue on an Apache forum. There is a patch file there that it looks like you can run in order to get the thrift gem to install. I checked it over and it looks sound.
You can find it here:
https://issues.apache.org/jira/browse/THRIFT-1382

sqlite3-ruby gem can't find sqlite3.h on ubuntu

Trying to get Rails up on ubuntu, and I’m having trouble installing sqlite3-ruby – it apparently can’t find sqlite3.h. All the references I can find to the error suggest the problem is either: sqlite3 headers aren’t installed, or make can’t find them. It looks to me like I’ve solved both those issues and I’m still seeing the same problem.
No real idea what’s going on here. Version mismatch, maybe? This is with ruby 1.8.7, sqlite 3.6.22-1, gem 1.3.5 and sqlite3-ruby 1.3.1 on ubuntu 10.04.1.
david#li88-188:~$ sudo apt-get install sqlite3
[...successful installation...]
Setting up sqlite3 (3.6.22-1) ...
david#li88-188:~$ sudo apt-get install libsqlite3-dev
[...successful installation...]
Setting up libsqlite3-dev (3.6.22-1) ...
david#li88-188:~$ sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel'
*** 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.
[...configuration options etc....]
david#li88-188:~$ cat /var/lib/gems/1.8/gems/sqlite3-ruby-1.3.1/ext/sqlite3/mkmf.log
find_header: checking for sqlite3.h... -------------------- no
"gcc -E -I. -I/usr/lib/ruby/1.8/i486-linux -I. -I/usr/local/include -I/opt/local/include -I/usr/include -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -g -g -O2 -fPIC -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <sqlite3.h>
/* end */
--------------------
Note that /usr/include is in the list of arguments.
david#li88-188:~$ ls -l /usr/include/sqlite3.h
-rw-r--r-- 1 root root 268351 2010-02-08 03:59 /usr/include/sqlite3.h
And note that the file is there.
In my case I had to install libsqlite3-dev
sudo apt-get install libsqlite3-dev
Never mind. gcc itself wasn't installed, as I discovered when I tried to install another gem with better error messages.
https://help.ubuntu.com/community/RubyOnRails here is a basic tutorial for setting up RoR development environment for Ubuntu with each step of the way explained. Good luck!

Resources