This is the error I got:
MacBook-Pro:myapp marcamilly$ gem install json -v 1.1.3
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/Users/marcamilly/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
creating Makefile
make
gcc -I. -I/Users/marcamilly/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/x86_64-darwin10.4.0 -I/Users/marcamilly/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/Users/marcamilly/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -Wall -o parser.o -c parser.c
parser.rl:2:16: error: re.h: No such file or directory
In file included from parser.rl:3:
/Users/marcamilly/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward/st.h:2:2: warning: #warning use "ruby/st.h" instead of bare "st.h"
parser.rl: In function ‘cParser_initialize’:
parser.rl:499: error: ‘struct RHash’ has no member named ‘tbl’
parser.rl:511: error: ‘struct RHash’ has no member named ‘tbl’
parser.rl:518: error: ‘struct RHash’ has no member named ‘tbl’
make: *** [parser.o] Error 1
Gem files will remain installed in /Users/marcamilly/.rvm/gems/ruby-1.9.2-p0/gems/json-1.1.3 for inspection.
Results logged to /Users/marcamilly/.rvm/gems/ruby-1.9.2-p0/gems/json-1.1.3/ext/json/ext/parser/gem_make.out
Any thoughts on what how I can fix this?
I believe that I might have had json installed as apart of another project (a Rails project) previously, but now I am trying to install this specific one, to be used with Sinatra and this is the error I get.
Thanks.
It seems that I had to have ruby 1.8.7 chosen as the current version of Ruby before installing this gem.
I finally got it installed properly.
Related
I upgraded the macos to Mojave and reinstalled xcode, xcode CLT, ruby, etc. Then when I tried:
gem install nokogiri
I got the following error (installing other gems gave similar error):
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20181209-20884-etfc5r.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.
I checked the mkmf.log, which contains the following:
"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:
The text went on like this for a while. I also cd to the nokogiri folder and directly run extconf.rb, and got the following error:
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
... (skipped similar content for brevity and continued below)
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.
I tried to install xcode. I also installed the header and acknowledged the license. I at first thought it has to do with GCC, but the mkmf file showed that the problem is with Clang.
Hope someone can help.
I had to run the following cryptic commands to get nokogiri installed. Basically this entails getting my C compiler working in mac osx Mojave, after having everything working fine in a previous OS (Yosemite I think it was...)
This is an (somewhat) obvious step when upgrading osx:
xcode-select --install
I also had to do this, which I never would've known how to do without google and this post
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Finally, I had to agree to the xcode license (found I had to do this via the makefile logs when install of nokogiri failed...)
sudo xcodebuild -licence
It'll prompt you to eventually type "agree"
Finally, continuing with bundle works as expected for a new rails project that includes nokogiri. Success!
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.
I keep getting this error while installing the gem wdm from inside cygwin. Does anybody had the same issue and know now to fix it. Thanks. (I am Trying to install Guard gem)
$ gem install wdm
Building native extensions. This could take a while...
ERROR: Error installing wdm:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for main() in -lkernel32... yes
checking for windows.h... yes
checking for ruby.h... yes
checking for HAVE_RUBY_ENCODING_H... yes
creating Makefile
make
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o entry.o -c entry.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o memory.o -c memory.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o monitor.o -c monitor.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o queue.o -c queue.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o rb_change.o -c rb_change.c
rb_change.c: In function ‘extract_absolute_path_from_notification’:
rb_change.c:47:16: error: ‘_MAX_FNAME’ undeclared (first use in this function)
rb_change.c:47:16: note: each undeclared identifier is reported only once for each function it appears in
rb_change.c:47:33: error: ‘_MAX_EXT’ undeclared (first use in this function)
Makefile:206: recipe for target `rb_change.o' failed
make: *** [rb_change.o] Error 1
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/wdm-0.1.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/wdm-0.1.0/ext/wdm/gem_make.out
A colleague of mine had an issue with wdm the other day.
We fixed it by downloading the Ruby DevKit (Not sure if you already had this installed).
I found some pretty decent step by steps online, I'll paste them here - hope they help
Development kit is here: http://rubyinstaller.org/downloads/
Download the Development Kit and install it in say c:\devkit.
Open a command window and type c:.
Change folders by typing cd devkit.
Type ruby dk.rb init to generate the config.yml file to be used later.
Your installed Rubies will be listed there (only those installed by a RubyInstaller package are detected at present). This needs to be done only once.
Finally type, ruby dk.rb install for DevKit enhance your installed Rubies. This needs to be done only once.
Confirm your Ruby environment is correctly using the DevKit by running:
gem install wdm --platform=ruby
It’s crucial that you include the --platform=ruby option to force RubyGems to build the native gem rather than potentially installing an incorrect binary gem.
I am ubuntu guy and not able to install win32-api.
Please find my log
Building native extensions. This could take a while...
ERROR: Error installing win32-api:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for strncpy_s()... no
creating Makefile
make
gcc -I. -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -Iwin32 -D_FILE_OFFSET_BITS=64 -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -o api.o -c win32/api.c
win32/api.c:2:21: error: windows.h: No such file or directory
win32/api.c:33: error: expected specifier-qualifier-list before ‘HANDLE’
win32/api.c: In function ‘api_free’:
win32/api.c:40: error: ‘Win32API’ has no member named ‘library’
win32/api.c:41: error: ‘Win32API’ has no member named ‘library’
win32/api.c: At top level:
win32/api.c:58: error: expected ‘)’ before ‘dwError’
win32/api.c: In function ‘callback_init’:
win32/api.c:189: error: ‘LPARAM’ undeclared (first use in this function)
win32/api.c:189: error: (Each undeclared identifier is reported only once
win32/api.c:189: error: for each function it appears in.)
win32/api.c:189: error: expected ‘)’ before ‘find_callback’
win32/api.c: In function ‘api_init’:
The Win32 API only exists on Windows. Or in WINE, but going that route is more complex than you're ready for.
a CentOS 64-bit Server with Ruby 1.8.7 & 1.9.2
{{no RVM, need it without RVM...
currently all Ruby1.9.2 binaries are ruby19 and similarly accessible,
so no mapping of gem-path or anything of that sort is there}}
is giving error while installing gem 'mysql2' ...
I have all dependencies installed and all are 64-bit versions ...
All error are of kind {./client.h:13:
error: redefinition of typedef
‘rb_unblock_function_t’}
Could {#warning rubysig.h is obsolete}
be a reason for this?
Console Capture:
#gem19 install mysql2 -v 0.2.7 -- --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby19 extconf.rb --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql
checking for rb_thread_blocking_region()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -Wall -fno-strict-aliasing -fPIC -Wall -funroll-loops -o result.o -c result.c
In file included from ./client.h:11,
from ./mysql2_ext.h:39,
from result.c:1:
/usr/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
In file included from ./mysql2_ext.h:39,
from result.c:1:
./client.h:13: error: redefinition of typedef ‘rb_unblock_function_t’
/usr/include/ruby-1.9.1/ruby/intern.h:754: error: previous declaration of ‘rb_unblock_function_t’ was here
./client.h:14: error: redefinition of typedef ‘rb_blocking_function_t’
/usr/include/ruby-1.9.1/ruby/intern.h:755: error: previous declaration of ‘rb_blocking_function_t’ was here
./client.h:20: error: static declaration of ‘rb_thread_blocking_region’ follows non-static declaration
/usr/include/ruby-1.9.1/ruby/intern.h:759: error: previous declaration of ‘rb_thread_blocking_region’ was here
./client.h: In function ‘rb_thread_blocking_region’:
./client.h:23: warning: ‘rb_thread_blocking_region_begin’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:31)
./client.h:25: warning: ‘rb_thread_blocking_region_end’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:32)
In file included from ./mysql2_ext.h:39,
from result.c:1:
./client.h:41:7: warning: no newline at end of file
make: *** [result.o] Error 1
This is caused by a patch they introduced on the gem in order for it to run in Ruby 1.8 but it is not needed on Ruby 1.9.
To deactivated this "fix" and be able to install the gem you can define a flag for the compiler:
gem install mysql2 -- --with-cflags=\"-DHAVE_RB_THREAD_BLOCKING_REGION\"
The problem is in the extconf/mkmf section:
rb_thread_blocking_region()... no
But Ruby 1.9.2 defines rb_thread_blocking_region (unless you built Ruby
with some funky set of ifdef's and edits I'm not aware of).
Check your mkmf.log file. It should show you that Ruby failed
to compile/link the conftest.c file that tests for
rb_thread_blocking_region. The reason why is that libcrypt.a
has a dependency on libfreebl3, but the library isn't getting
referenced on the link line.
I fixed the problem by editing /usr/local/lib/ruby/1.9.1/i686-linux/rbconfig.rb like so:
- CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lm "
+ CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lfreebl3 -lm "
I was able to build the mysql2 gem after. No need to install rvm, etc.
What I did to fix it was to re-install Ruby via RVM. There no more errors after that.
Alternatively, remove the block in client.h that is trying to emulate rb_thread_blocking_region for Ruby 1.8 and you'll be good to go.