Problems while installing pg gem - ruby-on-rails

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.

Related

Homebrew- impossible to install postgresql

I am stuck in the installation process of pg, making circles with the same issues, and couldn't resolve them.
I brew install libpq, then brew install openssl#1.1 then pg, and the exit error goes back to ask me to reinstall OpenSSL.
I have several Rails projects where PG used to work fine. I updates homebrew a few days ago and my configuration is a total mess.
My system is Mac OS Mojave 10.14.6. What do you advise to clean and start again with a proper configuration? (I am far from being a command line expert..)
Thanks for all recommendations!
Here is the mkmf.log I get when the installation of pg fails:
find_executable: checking for pg_config... -------------------- no
--------------------
checking for libpq per pkg-config... -------------------- no
"pkg-config --exists libpq"
| pkg-config --libs libpq
=> "-lpq\n"
"clang -fdeclspec -o conftest -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0/x86_64-darwin18 -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/backward -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0 -I. -I/Users/rougnaux/.rbenv/versions/3.0.0/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -fno-common -pipe conftest.c -L. -L/Users/rougnaux/.rbenv/versions/3.0.0/lib -L. -L/Users/rougnaux/.rbenv/versions/3.0.0/lib -fstack-protector-strong -L/usr/local/lib -lruby.3.0 "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
"clang -fdeclspec -o conftest -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0/x86_64-darwin18 -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/backward -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0 -I. -I/Users/rougnaux/.rbenv/versions/3.0.0/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -fno-common -pipe conftest.c -L. -L/Users/rougnaux/.rbenv/versions/3.0.0/lib -L. -L/Users/rougnaux/.rbenv/versions/3.0.0/lib -fstack-protector-strong -L/usr/local/lib -lruby.3.0 -lpq "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
| pkg-config --cflags-only-I libpq
=> "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.Internal.sdk/usr/local/include\n"
| pkg-config --cflags-only-other libpq
=> "\n"
| pkg-config --libs-only-l libpq
=> "-lpq\n"
package configuration for libpq
incflags: -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.Internal.sdk/usr/local/include
cflags:
ldflags:
libs: -lpq
--------------------
find_header: checking for libpq-fe.h... -------------------- no
"clang -E -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0/x86_64-darwin18 -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/backward -I/Users/rougnaux/.rbenv/versions/3.0.0/include/ruby-3.0.0 -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.Internal.sdk/usr/local/include -I/Users/rougnaux/.rbenv/versions/3.0.0/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -fno-common -pipe conftest.c -o conftest.i"
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
^~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
/* end */
have you tried using an installed instead? https://www.postgresql.org/download/

Ruby on Rails cannot find -lssl and -lcrypto when installing the mysql2 gem on Debian

I'm trying to connect ruby on rails with MariaDB at the moment. But for some reason when trying to install the mysql2 gem I'm getting this error:
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
What SSL/Crypto library am I missing for ruby on rails?
I couldn't find anyone else with this exact problem.
The error I'm getting:
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -
I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -
I/usr/include/mysql -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-
map=/build/ruby2.3-yge53O/rub$
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -
I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -
I/usr/include/mysql -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.3-yge53O/rub$
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
It looks like you are missing the libssl-dev package. Try running:
sudo apt-get update
sudo apt-get install libssl-dev
Once the package is installed, try installing your gem again.

Rails postresql installation issue

Hi folks, I have a problem when I try to install the postgresql, it is about a project, first I install the postgresql, then I write: sudo bundle install and it gives me this error and I cannot run the project because of it:
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.20.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/pg-0.20.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.20.0/gem_make.out
Below is the code from the file: mkmf.log
nd_executable: checking for pg_config... -------------------- yes
/usr/lib/ruby/2.3.0/mkmf.rb:1547: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
--------------------
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.3 -Wl,-rpath, -lpthread -lgmp -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
find_header: checking for libpq-fe.h... -------------------- no
"gcc -E -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -o conftest.i"
conftest.c:3:22: fatal error: libpq-fe.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
/* end */
--------------------

Cannot install mysql2 gem on openshift scaled app

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.

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

Resources