I am installing gem sqlite3 for rails 4 and get a compilation error. This is a completely new macbook pro with Mavericks OS installed. I have installed XCode, but then also installed gcc 4.9 using Homebrew (using instructions here). Everything was going smooth until I started getting a compilation error while trying to install the gem sqlite3:
app_folder git:(mybranch) gem install sqlite3 -v '1.3.8'
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile
make "DESTDIR="
compiling backup.c
gcc-4.9: error: unrecognized command line option '-Wshorten-64-to-32'
make: *** [backup.o] Error 1
Upon doing some research of the issue, I have found little information besides that this command line option is mac-specific and Homebrew-installed gcc compiler does not have it! Is there a way for me to switch back to native mac gcc compiler? How do I resolve this and why is it barely mentioned anywhere?
gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx- include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.1
I just installed Rails and had a similar experience. I fixed it by getting osx to recognize the correct g++ version and then reinstalling ruby. Here are a few suggestions:
You can set your gcc and g++ version via .bash_profile with the following code
export CC=gcc-4.9
export CXX=g++-4.9
export CPP=cpp-4.9
check your g++ version with g++ -v. If this doesn't work you may need to do bit of hacking.
Per http://instantbadger.blogspot.com/2011/11/porting-rails-23-app-to-ruby-19.html, you can remove the default g++ in /usr/bin and substitute it with a new symlink to g++-4.9:
sudo mv /usr/bin/g++ /usr/bin/g++.bak && sudo ln -s /usr/local/bin/g++-4.9 /usr/bin/g++
Note: this command is different from the one present in the linked page (which moves /usr/local/bin/g++). I didn't have a copy of g++ in /usr/local/bin/, so I adapted the command to work with /usr/bin instead.
Check g++ -v again. It should now reflect the correct version of g++.
Once your g++ version checks out, you can try reinstalling ruby. This insures that your ruby version is compiled with the same compiler that your going to build your gems with.
rvm install 2.0.0
Once you've done that, repeat
gem install sqlite3 -v '1.3.8'
Hopefully, this should work now.
Related
Can seem to get around this.
$gem install ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/remote/part/usern/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile
make
libffi.gnu.mk:16: Extraneous text after `else' directive
libffi.gnu.mk:18: *** only one `else' per conditional. Stop.
Gem files will remain installed in /remote/part/usern/.rvm/gems/ruby-1.9.3-p448#myrailsapp/gems/ffi-1.9.0 for inspection.
Results logged to /remote/part/usern/.rvm/gems/ruby-1.9.3-p448#myrailsapp/gems/ffi-1.9.0/ext/ffi_c/gem_make.out
Any ideas?
try this before
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
apt-get install ruby{version}-dev
bundle install ffi
it worked for me
I had to set the gcc to 4.2 and it worked. I also changed the ffi version to 1.0.9 in Gemfile.lock.
export PATH=/opt/gcc-4.2.0/bin/:$PATH
Hi that's related with the GCC compiler i updated mine and also did the trick that Harpreet mentioned (ffi version downgrade) BUT it's not necessary ffi-1.9.3 worked just fine as well :D
in the Gemfile.lock
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
https://github.com/kennethreitz/osx-gcc-installer
click here github repo with the .pkg installer for all OS (not only MacOSX)
As the title says, it doesn't seem to be failing because libxml2 or libxslt is missing. I'm not really sure what to make of the error. (Get it? Because the issue is during make? hehe...)
Anywho, here's the output I'm getting. Any ideas would be appreciated:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:10: Use RbConfig instead of obsolete and deprecated Config.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
make
compiling xml_element_content.c
compiling xml_relax_ng.c
compiling xml_cdata.c
compiling xml_sax_parser_context.c
compiling xml_node_set.c
compiling xml_text.c
compiling xml_sax_parser.c
compiling xml_attribute_decl.c
compiling nokogiri.c
nokogiri.c: In function ‘ruby_strdup’:
nokogiri.c:43:31: warning: conversion to ‘size_t’ from ‘long int’ may change the sign of the result [-Wsign-conversion]
compiling xml_entity_reference.c
compiling xml_node.c
compiling xml_xpath_context.c
xml_xpath_context.c: In function ‘xpath_generic_exception_handler’:
xml_xpath_context.c:184:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [xml_xpath_context.o] Error 1
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.5.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
For context, I upgraded from Ubuntu 12.04 to 12.10 last night. I had previously built the Nokogiri native extension on this box, though I do not know if it was the same version or not.
I also checked that I have all packages specified in the second post on "error installing nokogiri 1.5.0 with rails 3.1.0 and ubuntu"
to no avail.
Took me some time to figure out how to append the cflags. Here is my command for nokogiri 1.4.7:
sudo gem install nokogiri -v '1.4.7' -- --with-cflags=\"-Wformat-nonliteral -Wno-format-security\"
If you're trying to install Nokogiri < 1.5.4, you'll have problems on hardened Debian systems like Ubuntu 12.
Details on the underlying issue are here: https://github.com/sparklemotion/nokogiri/issues/680
You should be able to upgrade to 1.5.4 or later and install without this problem.
Alternatively, you should be able to set the CFLAGS environment variable at gem-install time to include the string:
-Wno-error=format-security
or
-Wformat-nonliteral -Wno-format-security
Good luck!
Have you tried installing the following depencies for nokogiri??
# nokogiri requirements
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri
This may be happening due to this bug > https://leap.se/code/issues/7231
Run below before running the command:
sudo apt-get install zlib1g-dev
Trying to install Google-api-client for Ruby on Mountain Lion fails due to localmemcache gem (I think).. Here is what happens:
Building native extensions. This could take a while...
ERROR: Error installing localmemcache:
ERROR: Failed to build gem native extension.
sh ./configure --prefix=/Users/rental/.rvm/gems/ruby-1.9.3-p125/gems/localmemcache-0.4.4/src/ruby-binding
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for ranlib... ranlib
checking for apple OS X...
-> Apple OS X is not supported because it doesn't have
sem_getvalue and sem_timedwait!
You may set the environment variable LMC_FORCE_BUILD
to build a version of localmemcache that cannot recover
from crashes.
Important note: this happens, when installed with --development:
sudo gem install google-api-client --development --force --no-rdoc --no-ri
Not sure where lmc is coming from, but its not a direct dependency of the library nor is it required for normal use. For now, suggest skipping the development dependencies and just install with:
gem install google-api-client
I'm trying to build LinkParser in Ruby.
I have RVM Ruby 1.9.2, initially the installer failed to build LinkParser because link-grammar wasn't present, but once I installed it with sudo port install link-grammar, the build error changed to this:
checking for pkg-config... yes
MacOS X build: fixing architecture flags:
using the value in ARCHFLAGS environment variable ("-arch x86_64").
checking for dictionary_create() in -llink-grammar... yes
checking for link-grammar/link-includes.h... no
*** extconf.rb failed ***
It says the link-includes.h file is missing. Are there any other packages I'm missing that need to be present in order to get this installed?
the macports version is too old, It requires at least version 4.7.0 of link-grammar, so I just compiled it from source and it worked.
I'm trying out rvm, and installed ruby 1.9.2 and rails 3 with it. I need to re-install the sqlite3-ruby gem (since rvm keeps all gems separate for different versions of ruby).
The problem is, when I try, I get:
gem install sqlite3-ruby
/home/jenny/.rvm/rubies/ruby-1.9.2-p0/bin/gem:4: warning: Insecure world writable dir /home/jenny/.rvm/gems/ruby-1.9.2-p0/bin in PATH, mode 040777
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/home/jenny/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_next_stmt()... yes
checking for sqlite3_column_database_name()... yes
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
creating Makefile
make
gcc -I. -I/home/jenny/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/i686-linux -I/home/jenny/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/home/jenny/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I. -DHAVE_RB_PROC_ARITY -DHAVE_SQLITE3_INITIALIZE -DHAVE_SQLITE3_NEXT_STMT -DHAVE_SQLITE3_COLUMN_DATABASE_NAME -I/usr/local/include -I/opt/local/include -I/sw/local/include -I/usr/include -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 exception.o -c exception.c
In file included from ./sqlite3_ruby.h:42,
from exception.c:1:
./backup.h:7: error: expected specifier-qualifier-list before ‘sqlite3_backup’
make: *** [exception.o] Error 1
I'm really not quite sure what to make of it... I HAVE installed sqlite3-ruby on this machine before (with rails 2.3.5) When I try to reinstall this gem (using rvm system settings) it doesn't install in a ruby 1.8.7 enviornment, EITHER.
Did rvm break the gem? Is the new gem just not compatible with my OS (i'm running opensuse linux)
Edit: When I try re-installing (uninstalling than installing again) sqlite3-ruby in my regular ruby environment, I get the same error, but then see sqlite3-ruby listed in my gem list (not sure if it's somehow restoring from backup, or installing despite the error)
I'd vote up or comment on Brennan's answer but I don't have enough points to do that yet. I figured I'd leave this answer in case it helps anyone else: I've spent a while on this one...I had Ruby 1.9.1 and Rails 3.0.3 installed and working but decided to move to RVM. Installed RVM according to directions and then installed rails again, all gravy...then tried to bundle install and ran into this error with sqlite3:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/Users/Jasonp/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite3-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** 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 know I had SQLite3 working before in my previous config, so I went to find the original dir. which was usr/local/sqlite3
I tried using that as the --with-sqlite3-dir= path but didn't work. Then just for fun I tried:
gem install sqlite3-ruby -- --with-sqlite3-dir=/usr/local/lib
and for wahtever reason, that worked. So, just in case someone
You could try
gem install sqlite3-ruby -- --with-sqlite3-dir=/path/to/your/sqlite3
And if that doesn't work, you might try to update your sqlite3, 3.6.4 is rather old, and I think the newer versions of Ruby sqlite have problems with something that old.
(And the most likely reason that you're getting different answers with the two is that between versions 2 and 3 was a major change -- mostly dealing with Unicode, I believe -- and some programs still use 2, not 3.)
When I installed sqlite3 from source it placed the include files in /usr/local/include
I tried
gem install sqlite3-ruby -- --with-sqlite3-dir=/usr/local/lib
and it finally installed.
on ubuntu 9.04 I also had to download sqlite and install from source