Cannot install mysql2 gem on openshift scaled app - ruby-on-rails

I'm trying to install mysql2 gem with ruby on rails 4/ruby 2.0 OpenShift scaled app.
But, bundle install fails, trying "gem install mysql2", which leads to the following error:
gem install mysql2
Fetching: mysql2-0.4.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/opt/rh/ruby200/root/usr/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /opt/rh/mysql55/root/usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /opt/rh/mysql55/root/usr/lib64/mysql
-----
creating Makefile
make "DESTDIR="
gcc -I. -I/opt/rh/ruby200/root/usr/include -I/opt/rh/ruby200/root/usr/include/ruby/backward -I/opt/rh/ruby200/root/usr/include -I. -I/opt/rh/mysql55/root/usr/include/mysql -DHAVE_RUBY_THREAD_H -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_HASH_DUP -DHAVE_RB_INTERN3 -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC -m64 -o client.o -c client.c
gcc -I. -I/opt/rh/ruby200/root/usr/include -I/opt/rh/ruby200/root/usr/include/ruby/backward -I/opt/rh/ruby200/root/usr/include -I. -I/opt/rh/mysql55/root/usr/include/mysql -DHAVE_RUBY_THREAD_H -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_HASH_DUP -DHAVE_RB_INTERN3 -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC -m64 -o infile.o -c infile.c
gcc -I. -I/opt/rh/ruby200/root/usr/include -I/opt/rh/ruby200/root/usr/include/ruby/backward -I/opt/rh/ruby200/root/usr/include -I. -I/opt/rh/mysql55/root/usr/include/mysql -DHAVE_RUBY_THREAD_H -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_HASH_DUP -DHAVE_RB_INTERN3 -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC -m64 -o mysql2_ext.o -c mysql2_ext.c
gcc -I. -I/opt/rh/ruby200/root/usr/include -I/opt/rh/ruby200/root/usr/include/ruby/backward -I/opt/rh/ruby200/root/usr/include -I. -I/opt/rh/mysql55/root/usr/include/mysql -DHAVE_RUBY_THREAD_H -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_HASH_DUP -DHAVE_RB_INTERN3 -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC -m64 -o result.o -c result.c
gcc -I. -I/opt/rh/ruby200/root/usr/include -I/opt/rh/ruby200/root/usr/include/ruby/backward -I/opt/rh/ruby200/root/usr/include -I. -I/opt/rh/mysql55/root/usr/include/mysql -DHAVE_RUBY_THREAD_H -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_HASH_DUP -DHAVE_RB_INTERN3 -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC -m64 -o statement.o -c statement.c
rm -f mysql2.so
gcc -shared -o mysql2.so client.o infile.o mysql2_ext.o result.o statement.o -L. -L/opt/rh/ruby200/root/usr/lib64 -L/opt/rh/mysql55/root/usr/lib64/mysql -L. -fstack-protector -rdynamic -Wl,-export-dynamic -m64 -lruby -L/opt/rh/mysql55/root/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lpthread -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1
Gem files will remain installed in /var/lib/openshift/541424415004469f3a000b85/.gem/gems/mysql2-0.4.1 for inspection.
Results logged to /var/lib/openshift/541424415004469f3a000b85/.gem/gems/mysql2-0.4.1/ext/mysql2/gem_make.out
MySQL libraries/SDK are supposed to be maintained/provided by RedHat in the PaaS offering, so I'm a bit stuck. Interestingly enough, until tonight, it worked well.
EDIT:
The first answers revealed, that I missed an important point in the question. In OpenShift one does not have root access to the gear, so I cannot execute yum install as suggested below. It is really an OpenShift specific question, not a general one. I definitely know how to install MySQL development libraries. Sorry about the confusion, caused by the missing piece of information.

On Mac OS X, and is using Homebrew:
brew install mysql
or if you're on Red Hat or CentOS or other distributions using yum:
sudo yum install mysql-devel
and finally, if you're on Ubuntu or Debian or other distributions using aptitude:
sudo apt-get install libmysqlclient-dev

Ok, I finally made it and I'm posting the answer so that others can benefit from that in case they meet the same problem.
The reason for the behavior was apparently that the previous deployment approach in OpenShift broke in the middle, which left the gear in an inconsistent state (the issue with mysql2 gem was one symptom of that). What I basically tried to do is to bring it back to a consistent state manually by bundle'ing and re-building from the git HEAD.
This did not work.
Attempts to push to the gear git from my development repository did not work either, since nothing has changed from the last push (which resulted in deployment that broke apparently due to some OpenShift internal bugs).
What I did at the end, I made some change in the bundle (in my case updated one gem by bundle update) and this updated Gemfile.lock.
Since I also checked in "force_clean_build" marker, the subsequent push rebuilt the gear from scratch, also having brought it to a consistent state.
Long story short, if OpenShift deployment breaks in the middle, it is much better to make a fake change in sources and push them in conjunction with the marker force_clean_build to the gear's git than to try to rebuild manually by gear deploy HEAD, since the latter does not clean up the possibly occurred inconsistency.

Related

Unable to install johnson with gem

I am trying to install johnson, in order to install harmony with Centos 8.
gem install johnson
I keep getting the error that there is no such file as node.h. But I have clearly installed nodejs, and nodejs-devel (I used the latest packages from stream: nodejs:18)
I am using Discourse community software, so require a specific version or ruby
current directory: /usr/local/share/gems/gems/johnson-1.2.0/ext/spidermonkey
make "DESTDIR="
gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey/Linux_All_DBG.OBJ -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -g -Wall -Wextra -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -DXP_UNIX -m64 -o context.o -c context.c
In file included from context.h:4,
from context.c:1:
spidermonkey.h:21: warning: "MAYBE_UNUSED" redefined
# define MAYBE_UNUSED(name) name __attribute__((unused))
In file included from /usr/include/ruby/config.h:18,
from /usr/include/ruby/ruby.h:24,
from /usr/include/ruby.h:33,
from spidermonkey.h:7,
from context.h:4,
from context.c:1:
/usr/include/ruby/config-x86_64.h:152: note: this is the location of the previous definition
#define MAYBE_UNUSED(x) __attribute__ ((__unused__)) x
gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey/Linux_All_DBG.OBJ -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -g -Wall -Wextra -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -DXP_UNIX -m64 -o conversions.o -c conversions.c
In file included from conversions.h:4,
from conversions.c:1:
spidermonkey.h:21: warning: "MAYBE_UNUSED" redefined
# define MAYBE_UNUSED(name) name __attribute__((unused))
In file included from /usr/include/ruby/config.h:18,
from /usr/include/ruby/ruby.h:24,
from /usr/include/ruby.h:33,
from spidermonkey.h:7,
from conversions.h:4,
from conversions.c:1:
/usr/include/ruby/config-x86_64.h:152: note: this is the location of the previous definition
#define MAYBE_UNUSED(x) __attribute__ ((__unused__)) x
In file included from conversions.c:2:
js_land_proxy.h:11:10: fatal error: node.h: No such file or directory
#include "node.h"
^~~~~~~~
compilation terminated.
make: *** [Makefile:245: conversions.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/share/gems/gems/johnson-1.2.0 for inspection.
Results logged to /usr/local/lib64/gems/ruby/johnson-1.2.0/gem_make.out

bundle install fails installing ruby-oci8 on osx 10.9

I ran 'bundle install' with ruby 2.0 and when it gets to the ruby-oci8 gem it fails.
"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -I/opt/oracle_11_2/instantclient_11_2/rdbms/public conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L. -L/usr/local/lib -arch x86_64 -arch i386 -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/opt/oracle_11_2/instantclient_11_2/lib -lclntsh -lruby.2.0.0 -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/opt/oracle_11_2/instantclient_11_2/lib -lclntsh -lpthread -ldl -lobjc "
conftest.c:7:29: error: too few arguments to function call, expected 5, have 0
int t(void) { OCIInitialize(); return 0; }
~~~~~~~~~~~~~ ^
/opt/oracle_11_2/instantclient_11_2/rdbms/public/ociap.h:7085:1: note: 'OCIInitialize' declared here
sword OCIInitialize (ub4 mode, void *ctxp,
How do I fix this?
turns out I had the 32 bit instead of the 64 bit oracle instantclient

Problems while installing pg gem

I need to install pg gem, but the installation failed. I've tried all the solution propesed in other questions but no luck.
Here is my output, and here is my "mkmf.log" file
Any idea?
[UPDATE]
I've solved the first problem by putting libs in the correct directory. But now I've another problem:
find_executable: checking for pg_config... -------------------- yes
--------------------
"gcc -o conftest -I/usr/include/ruby-1.9.1/i686-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -I/usr/include/postgresql -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby-1.9.1-static -lpthread -lrt -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
[UPDATE2]
Solved it by putting links to "libgcc", "libgcc_s", "crtend.o", "crtendS.o", "crtbeginS.o" and "crtbegin.o" into /usr/lib
It looks like you are missing development libraries even for glibc. Just install devel packages for glibc and postgresql and try again.

I can't install rails correctly on mac

I attempt to intsall rails on mac by error still exist
I really frustrated and want some suggestions
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/1.8/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR="
xcrun cc -I. -I. - I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal- darwin12.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 -c atomic_reference.c
xcrun: Error: could not stat active Xcode path '/Developer'. (No such file or directory)
cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o atomic_reference.bundle atomic_reference.o -L. - L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -lruby -lpthread -ldl -lobjc
clang: error: no such file or directory: 'atomic_reference.o'
make: *** [atomic_reference.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/atomic-1.1.12 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/atomic-1.1.12/ext/gem_make.out
I've found the best way is with Homebrew and RVM. There's an excellent Railscast on this: http://railscasts.com/episodes/310-getting-started-with-rails

issues installing gem install bcrypt-ruby -v '3.0.1' on Mac OSX 10.8.2

Trying to troubleshoot a web app and in doing so I am going through the steps in http://wiki.dreamhost.com/Rails_3. I am stuck on trying to get the console to run. It asks me to bundle and then when I get an error for bcrypt-ruby -v '3.0.1'. This is the error i get when i try to use gem install:
gem install bcrypt-ruby -v '3.0.1'
Building native extensions. This could take a while...
ERROR: Error installing bcrypt-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-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.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 -c bcrypt_ext.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.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 -c crypt.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.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 -c crypt_blowfish.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.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 -c crypt_gensalt.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.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 -c wrapper.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o bcrypt_ext.bundle bcrypt_ext.o crypt.o crypt_blowfish.o crypt_gensalt.o wrapper.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -lruby -lpthread -ldl -lobjc
clang: error: no such file or directory: 'bcrypt_ext.o'
clang: error: no such file or directory: 'crypt.o'
clang: error: no such file or directory: 'crypt_blowfish.o'
clang: error: no such file or directory: 'crypt_gensalt.o'
clang: error: no such file or directory: 'wrapper.o'
make: *** [bcrypt_ext.bundle] Error 1
Gem files will remain installed in /Users/karrde00/.gems/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /Users/karrde00/.gems/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out

Resources