I know this is simple but I just can't figure it out. I need to run a script in Ruby and it requires Nokogiri. I do have some experience in other languages but not in Ruby.
Here is my system :
Ruby 2.0.0-p195 (x64) is installed # C:\Programs\RubyLanguage
Ruby Development Kit (mingw64-64-4.7.2-20130224-1432) is installed # C:\Programs\RubyDevKit
When I run gem install nokogiri I get this error:
ERROR: Error installing nokogiri:
The 'nokogiri' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
Easy enough. So I followed the link of above and did to step 3. However step 4 says generate "config.yml". So I did. Now the file is an empty list with some comments. I still can't install Nokogiri because of error above and I don't seem to get anywhere with DevKit . What I am saying is that the steps in the Development Kit installation is not clear enough for me.
Update it now says installation of Nokogiri failed ( DevKit Works according to step 5 : Installing documentation for json-1.8.0
1 gem installed )
mkmf.log: package configuration for libxslt is not found
package configuration for libxml-2.0 is not found
package configuration for libiconv is not found
find_header: checking for libxml/parser.h... -------------------- no
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Programs/RubyLanguage/include/ruby-2.0.0/x64-mingw32 -IC:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/backward -IC:/Programs/RubyLanguage/include/ruby-2.0.0 -I. -IC:/Programs/RubyLanguage/include/libxml2 -IC:/Programs/RubyLanguage/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -L. -LC:/Programs/RubyLanguage/lib -LC:/Programs/RubyLanguage/lib -L. -lx64-msvcrt-ruby200 -lshell32 -lws2_32 -limagehlp -lshlwapi "
In file included from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/defines.h:153:0,
from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h:70,
from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby.h:33,
from conftest.c:1:
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/win32.h: In function 'rb_w32_pow':
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/win32.h:776:16: warning: conversion to 'double' from 'long double' may alter its value [-Wconversion]
In file included from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby.h:33:0,
from conftest.c:1:
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_float_value':
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h:777:6: warning: negative integer implicitly converted to unsigned type [-Wsign-conversion]
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h:777:6: warning: negative integer implicitly converted to unsigned type [-Wsign-conversion]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7: return 0;
8: }
/* end */
"x86_64-w64-mingw32-gcc -E -IC:/Programs/RubyLanguage/include/ruby-2.0.0/x64-mingw32 -IC:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/backward -IC:/Programs/RubyLanguage/include/ruby-2.0.0 -I. -IC:/Programs/RubyLanguage/include/libxml2 -IC:/Programs/RubyLanguage/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -o conftest.i"
conftest.c:5:27: fatal error: libxml/parser.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <libxml/parser.h>
/* end */
CMD log
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\SEPEHR>gem install nokogiri
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
C:/Programs/RubyLanguage/bin/ruby.exe extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokog
iri.html for help with installing dependencies.
-----
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Programs/RubyLanguage/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-libiconv-config
--without-libiconv-config
--with-pkg-config
--without-pkg-config
Gem files will remain installed in C:/Programs/RubyLanguage/lib/ruby/gems/2.0.0/
gems/nokogiri-1.6.0 for inspection.
Results logged to C:/Programs/RubyLanguage/lib/ruby/gems/2.0.0/gems/nokogiri-1.6
.0/ext/nokogiri/gem_make.out
Update: As of version 1.6.2, Nokogiri now does support the 64-bit version of Ruby 2.0.0. (Note that it requires libxml >= 2.6.21 )
Here's the answer if you still need to install the x86 version for some reason or if you want to understand how to install and build a gem using DevKit:
Nokogiri does not yet support the 64-bit version of Ruby 2.0.0. You can read about it and follow the status here.
But Nokogiri does support the x86 version of ruby 2.0.0. You should be able to install the gem in on 2.0.0 x86 install.
It's pretty easy to hand-install. I prefer that over RailsInstaller because I need to maintain other things as they are. Here's how:
Download and unzip the files for the version you need. Be sure to download the correct version of DevKit for the x86 version of 2.0.0.
Fix your path: Make sure your path includes the directories to the right ruby, gem, and DevKit dirs:
Assume you installed the x86 version of ruby 2.0.0 into C:\rubies\ruby-2-0-0-x86 and the associated DevKit into C:\rubies\DevKit-xxxx-x86 you will need to include these directories in your PATH:
C:\rubies\ruby-2-0-0-x86\bin
C:\rubies\ruby-2-0-0-x86\lib\ruby\gems\2.0.0
C:\rubies\DevKit-xxxx-x86\bin
Inject DevKit into the right ruby install: Once you have ruby installed and can get the correct info when you type ruby -v, then run ruby dk.rb init -- which will get DevKit set up & 'injected' into the correct ruby version. (N.B. I always have to edit the config.yml file that is produced and put in the correct path to the ruby installation I want. Don't sweat it if you need to do that.)
Yup ... Downgrading to 1.9.3 worked . Tnx for help . I put the summary here :
Install Ruby 1.9.3 ( Do not change Install Name to ex.RubyLang or
config doesn't find it automatically )
Install DevKit (Follow DevKit Installation Steps)
Install Nokogiri
I wasn't able to install x64 Nokogiri for Ruby 2.0 on Windows 7, but the binary gem seems to be working.
Related
After setting up a new mac and transferring data from my old one, some gems won't install and I am getting error messages such as the following when trying to install spidr:
$ sudo gem install spidr
Password:
Fetching: mini_portile2-2.4.0.gem (100%)
Successfully installed mini_portile2-2.4.0
Fetching: nokogiri-1.9.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing spidr:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.9.0/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20181217-24587-ul93i2.rb extconf.rb
checking if the C compiler accepts ... *** 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.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/Cellar/ruby/2.5.3_1/bin/$(RUBY_BASE_NAME)
--help
--clean
/usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:412:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/nokogiri-1.9.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.9.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/nokogiri-1.9.0/gem_make.out
I am also attaching the contents of the referenced mkmf.log file below:
"clang -o conftest -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/x86_64-darwin18 -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/backward -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/usr/local/Cellar/ruby/2.5.3_1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -lruby.2.5.3 -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:11: warning: non-portable path to file '<String.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
# include <string.h>
^~~~~~~~~~
<String.h>
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:
/usr/local/include/string.h:25:10: fatal error: 'plist/Node.h' file not found
#include <plist/Node.h>
^~~~~~~~~~~~~~
1 warning and 1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
I have done research for quite some hours now and don't know what to do anymore. I am attaching another similar error when trying to install another gem, fastlane:
$ sudo gem install fastlane
Password:
Building native extensions. This could take a while...
ERROR: Error installing fastlane:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.5.0/gems/unf_ext-0.0.7.5/ext/unf_ext
/usr/local/opt/ruby/bin/ruby -r ./siteconf20181217-24788-1jgurro.rb extconf.rb
checking for -lstdc++... *** 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.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/Cellar/ruby/2.5.3_1/bin/$(RUBY_BASE_NAME)
--with-static-libstdc++
--without-static-libstdc++
--with-stdc++lib
--without-stdc++lib
/usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:559:in `try_link'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:778:in `try_func'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:1005:in `block in have_library'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:948:in `block in checking_for'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:947:in `checking_for'
from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:1000:in `have_library'
from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/unf_ext-0.0.7.5/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/unf_ext-0.0.7.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/unf_ext-0.0.7.5/gem_make.out
The corresponding mkmf.log contents:
"clang -o conftest -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/x86_64-darwin18 -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/backward -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/usr/local/Cellar/ruby/2.5.3_1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -lruby.2.5.3 -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:11: warning: non-portable path to file '<String.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
# include <string.h>
^~~~~~~~~~
<String.h>
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:
/usr/local/include/string.h:25:10: fatal error: 'plist/Node.h' file not found
#include <plist/Node.h>
^~~~~~~~~~~~~~
1 warning and 1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
Xcode Developer Tools are installed using xcode-select --install.
Does anyone maybe have a hint what to do?
Thanks very much in advance for any help and best regards
Sebastian
I think I fixed it by deleting file String.h in /usr/local/include/ folder. The same is written in this SO question: gem install libxml-ruby: fatal error: 'plist/Node.h' file not found
Command brew doctor told me that there are lots of files in /usr/local/include/ folder that might be deleted. I deleted file String.h and left all other files in place. This fixed it.
Thanks for everyone commenting and trying to help.
Currently trying to install the mysql2 gem on redhat. This is what I'm getting after running gem install
gem install mysql2 -v 0.3.18 -- --with-mysql-config=/usr/bin/mysql_config
checking for ruby/thread.h... *** 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.
It looks like most people who get a similar error need to install mysql dev/lib packages. The packages are already installed and up to date. The mkmf.log file looks like this:
"gcc -o conftest -I/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/x86_64-linux -I/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/backward
-I/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0 -I. -I/home/zdev/.rbenv/versions/2.2.0/include -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3
-Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings
-Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L.
-L/home/zdev/.rbenv/versions/2.2.0/lib -Wl,-R/home/zdev/.rbenv/versions/2.2.0/lib -L/home/zdev/.rbenv/versions/2.2.0/lib -lruby-static -lpthread -lrt
-ldl -lcrypt -lm -lc"
In file included from /home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby.h:33,
from conftest.c:1:
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h:107: error: size of array 'ruby_check_sizeof_long' is negative
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h:111: error: size of array 'ruby_check_sizeof_voidp' is negative
In file included from /home/zdorman/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby.h:33,
from conftest.c:1:
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_int2num_inline':
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h:1303: warning: comparison is always true due to limited range of data type
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h:1303: warning: comparison is always true due to limited range of data type
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_uint2num_inline':
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h:1313: warning: comparison is always true due to limited range of data type
In file included from /home/zdorman/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/intern.h:35,
from /home/zdorman/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/ruby.h:1710,
from /home/zdorman/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby.h:33,
from conftest.c:1:
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/st.h: At top level:
/home/zdev/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/st.h:52: error: size of array 'st_check_for_sizeof_st_index_t' is negative
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
The errors in the log file are produced by sanity checks like this:
typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1];
What could be the cause of this issue? gcc and mysql are both 64 bit - are there any other binaries/libs that would cause this issue?
For the record, there is a copy of the mysql2 gem already installed on this system. It was installed a couple years ago by the original developer, and is tied to a ruby install in /usr/bin. I'm trying to migrate a project over to using a ruby managed by rbenv. From a clean ruby install made through rbenv, bundle install will work flawlessly on our ubuntu box, but it trips up with the mysql2 gem on this system.
When I try to running bundle install I see:
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/extensions/x86-
mingw32/2.3.0/nio4r-2.1.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/nio4r-2.1.0 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/extensions/x86-
mingw32/2.3.0/nio4r-2.1.0/gem_make.out
An error occurred while installing nio4r (2.1.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.1.0'` succeeds before bundling.
I am using Windows 10, Ruby 2.3.3, Rails 5.0.2.
mkmf.log content is:
"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.3.0/include/ruby-2.3.0/i386-
mingw32 -IC:/RailsInstaller/Ruby2.3.0/include/ruby-2.3.0/ruby/backward -
IC:/RailsInstaller/Ruby2.3.0/include/ruby-2.3.0 -I. -DFD_SETSIZE=2048 -
D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -
O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-
parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -
Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-
statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-
packed-bitfield-compat conftest.c -L. -LC:/RailsInstaller/Ruby2.3.0/lib -L.
-lmsvcrt-ruby230 -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
Checked program was:
#include "ruby.h"
#include <winsock2.h>
#include <windows.h>
int main(int argc, char **argv)
{
return 0;
}
If other gems have same error (and it's initial bundle install), try to change in gemfile source 'https://rubygems.org' to source 'http://rubygems.org'.
I had this problem on windows in corporate network, and problem somewhere with ssl. That solution works for me, but i know, it isn't best solution.
But it's a bad recommendation, if any other gem installed with success.
I'm trying to install the ffi gem so that I can use guard-rspec using the command sudo gem install ffi -v '1.9.8'. I end up getting this output:
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby -r ./siteconf20150424-14771-zza3du.rb extconf.rb
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/usr/local/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
from /usr/local/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
from /usr/local/lib/ruby/2.2.0/mkmf.rb:637:in `try_ldflags'
from /usr/local/lib/ruby/2.2.0/mkmf.rb:1780:in `pkg_config'
from extconf.rb:15:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.2.0/gems/ffi-1.9.8 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/ffi-1.9.8/gem_make.out
The mkmf.log file looks like this:
"/usr/local/bin/gcc -o conftest -I/usr/local/include/ruby-2.2.0/x86_64-darwin14 -I/usr/local/include/ruby-2.2.0/ruby/backward -I/usr/local/include/ruby-2.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -pipe conftest.c -L. -L/usr/local/lib -L. -fstack-protector -lruby-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
sh: line 1: 14464 Trace/BPT trap: 5 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find dsymutil 2> /dev/null
dsymutil: error: unable to find utility "dsymutil", not a developer tool or in PATH
collect2: error: dsymutil returned 72 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
So mkmf.rb seems to be complaining that it can't find dsymutil. But the command /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find dsymutil gives the output
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil
So the problem isn't that I don't have the command line tools installed.
I decided to take a look at the source code for mkmf.rb to see if I could figure out what was going on. The method that raised the error is:
def try_do(src, command, *opts, &b)
unless have_devel?
raise <<MSG
The compiler failed to generate an executable file.
You have to install development tools first.
MSG
end
begin
src = create_tmpsrc(src, &b)
xsystem(command, *opts)
ensure
log_src(src)
MakeMakefile.rm_rf "#{CONFTEST}.dSYM"
end
end
So we can see that the error that gets raised is raised if the method have_devel? returns false. Now check this out:
$ irb
irb(main):001:0> require 'mkmf'
=> true
irb(main):002:0> have_devel?
=> true
Great. So ruby can find my command line tools. But if I run irb as root:
$ sudo irb
Password:
irb(main):001:0> require 'mkmf'
=> true
irb(main):002:0> have_devel?
=> false
It fails. The mkmf.log file that gets spit out is the same as the one above, complaining about lack of dsymutil. I have no idea why this would happen.
Does anybody have any suggestions as to how I could get ffi installed? I suspect that something is weird about my box and nobody will be able to reproduce this mkmf behavior.
In order to build ruby 1.9 on mac I had to install gcc 4.6. Rails and a bunch of other gems built fine. installing mysql or mysql2 is giving me all sorts of heartache.
rubygems> env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/ff/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** 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.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/ff/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
--with-mysql-config
Gem files will remain installed in /Users/ff/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/ff/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
When I look at the mkmf.log file I see:
have_header: checking for mysql.h... -------------------- no
"/opt/local/bin/gcc-mp-4.6 -E -I/Users/ff/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1/x86_64-darwin11.2.0 -I/Users/ff/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1/ruby/backward -I/Users/ff/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1 -I. -I/Users/ff/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -Os -arch i386 -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fno-common -pipe conftest.c -o conftest.i"
gcc-mp-4.6: error: i386: No such file or directory
gcc-mp-4.6: error: unrecognized option '-arch'
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <mysql.h>
/* end */
So basically it seems that the -arch flag is not supported. Anyone have an idea as to where these compile options are provided so I can remove this flag? Or any other solution.... Thanks
I tried all the solutions posted here, but was not lucky. I reinstalled mysql through homebrew a couple of times and still no luck. Then I came across a blog post with a solution.
I edited the mysql_config file in /usr/local/Cellar/mysql/5.6.12/bin and removed the W-compiler options -Wno-null-conversion and -Wno-unused-private-field for cflags and cxxflags.
This solved the problem with gem install mysql2.
Reference: randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os
Install MySQL separate from when installing rails. I tried installing it with rvm and it did not work.
Check out this article it should help you with installing mysql
If that fails here's another solution. Both have worked for me.
well, since you're living on the edge... -arch flags should be -m64 instead now... so you'll need to probably update your mysql_config to reflect that change e.g. in mine it's on line 128 replace:
-arch x86_64
with
-m64
then,
gem install mysql2
Failed to build gem native extension is not about gem dependencies but its rather about the application not being installed completely.
I faced the same problem, this should do the trick:
sudo apt-get install libmysql-ruby libmysqlclient-dev