Error installing gem mysql2 -v 0.3.21 on RHEL 8 - ruby

I am copying my application to a new server, as old one got corrupted, but while trying to run bundle install, gem mysql2 failed to install.
[me#localhost redmine]$ gem install mysql2 -v 0.3.21
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21/ext/mysql2
/home/x-mwojciechow4/.rvm/rubies/ruby-2.2.9/bin/ruby -I /home/x-mwojciechow4/.rvm/rubies/ruby-2.2.9/lib/ruby/site_ruby/2.2.0 -r ./siteconf20220613-3672195-xa12ap.rb 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()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting libpath to /usr/lib64/mysql
-----
creating Makefile
current directory: /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean
current directory: /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling client.c
client.c: In function ‘nogvl_read_query_result’:
client.c:439:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
my_bool res = mysql_read_query_result(client);
^~~~~~~
bool
client.c: In function ‘_mysql_client_options’:
client.c:762:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
my_bool boolval;
^~~~~~~
bool
client.c:797:10: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
case MYSQL_SECURE_AUTH:
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
client.c:797:10: note: each undeclared identifier is reported only once for each function it appears in
client.c: In function ‘set_secure_auth’:
client.c:1185:38: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
client.c:1186:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
make: *** [Makefile:238: client.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21 for inspection.
Results logged to /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/extensions/x86_64-linux/2.2.0/mysql2-0.3.21/gem_make.out
The first error I notice is "checking for rb_thread_blocking_region()... no" -however I didnt find anything useful by googling this.
It is important to me to stay on the same mysql2 version, as this is a testing server, so I want it to be as close to production server as possible.
system:
RHEL 8.1
Ruby 2.2.9p480
Rails 4.2.7.1
MySql 8.0.29 MySQL Community Server - GPL

The mysql2 gem in version 0.3.21 is not compatible with MySQL 8.0.
As such, unless there are any actual concerns, you should update your gem versions (both on testing and production). mysql2 0.4.10 (the last version of 0.4.x) should be compatible with your Rails version and supports MySQL 8.0. If you can also update Rails to at least 4.2.11.3 (which you should, there were a lot of security fixes since version 4.2.7.1), you can also use mysql2 0.5.x.
In any case all of the ruby software versions you mentioned (i.e. ruby itself, rails and mysql2) are outdated and do not receive any updates in their respective branches anymore. You should invest to update all of those to newer supported versions.

Related

gem install pg | error: ‘PQERRORS_SQLSTATE’ undeclared

I am working in openSuse Leap, using rbenv. After upgrading from Leap 15.1 to 15.2 I have a problem. I cannot make 'gem install pg'.
Reproduce:
gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
/home/alex/.rbenv/versions/2.6.6/bin/ruby -I /home/alex/.rbenv/versions/2.6.6/lib64/ruby/2.6.0 -r ./siteconf20200827-12823-54e7ke.rb extcon
f.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.
---
find / -name "pg_config" -print
/usr/lib/postgresql10/bin/pg_config
gem install pg -- --with-pg-config=/usr/lib/postgresql10/bin/pg_config
Building native extensions with: '--with-pg-config=/usr/lib/postgresql10/bin/pg_config'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
/home/alex/.rbenv/versions/2.6.6/bin/ruby -I /home/alex/.rbenv/versions/2.6.6/lib64/ruby/2.6.0 -r ./siteconf20200827-12620-silryo.rb extconf.rb --with-pg-config\=/usr/lib/postgresql10/bin/pg_config
Using config values from /usr/lib/postgresql10/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for PQsslAttribute()... yes
checking for PQresultVerboseErrorMessage()... yes
checking for PQencryptPasswordConn()... yes
checking for PQresultMemorySize()... yes
checking for timegm()... yes
checking for rb_gc_adjust_memory_usage()... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile
current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
make "DESTDIR=" clean
current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
In file included from /home/alex/.rbenv/versions/2.6.6/include/ruby-2.6.0/ruby.h:33:0,
from pg.h:20,
from pg.c:49:
pg.c: In function ‘Init_pg_ext’:
pg.c:470:64: error: ‘PQERRORS_SQLSTATE’ undeclared (first use in this function); did you mean ‘PQERRORS_TERSE’?
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
^
/home/alex/.rbenv/versions/2.6.6/include/ruby-2.6.0/ruby/ruby.h:261:33: note: in definition of macro ‘RB_INT2FIX’
#define RB_INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIXNUM_FLAG)
^
pg.c:470:56: note: in expansion of macro ‘INT2FIX’
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
^~~~~~~
pg.c:470:64: note: each undeclared identifier is reported only once for each function it appears in
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
^
/home/alex/.rbenv/versions/2.6.6/include/ruby-2.6.0/ruby/ruby.h:261:33: note: in definition of macro ‘RB_INT2FIX’
#define RB_INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIXNUM_FLAG)
^
pg.c:470:56: note: in expansion of macro ‘INT2FIX’
rb_define_const(rb_mPGconstants, "PQERRORS_SQLSTATE", INT2FIX(PQERRORS_SQLSTATE));
^~~~~~~
pg.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-cast-function-type’
make: *** [Makefile:245: pg.o] Ошибка 1
make failed, exit code 2
Gem files will remain installed in /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3 for inspection.
Results logged to /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/pg-1.2.3/gem_make.out
OpenSuse Support Forum recommended that I report a bug on bugzilla:
'Looks like although dependencies are satisfied, there is an upstream compilation error likely due to a change in supported methods. Code identified the error, then tried to resolve on its own (apparently there is some error checking and fixes already in the code, maybe errors like this has happened before). That kind of error isn't likely going to be solved by an end user.'
But this did not solve the problem, please take a look.
Any ideas? Help would be very helpful.
UPD
LC_ALL=C sudo zypper in postgresql postgresql-server postgresql-contrib
[sudo] password for root:
Loading repository data...
Reading installed packages...
'postgresql' is already installed.
No update candidate for 'postgresql-12.0.1-lp152.5.5.noarch'. The highest available version is already installed.
'postgresql-server' is already installed.
No update candidate for 'postgresql-server-12.0.1-lp152.5.5.noarch'. The highest available version is already installed.
'postgresql-contrib' is already installed.
No update candidate for 'postgresql-contrib-12.0.1-lp152.5.5.noarch'. The highest available version is already installed.
Resolving package dependencies...
Nothing to do.
Not sure about Leap, but under Tumbleweed I solved exactly the same problem by removing postgresql10-devel and installing both postgresql12-devel and postgresql12-server-devel.

weird error when installing mechainze gem on mac os

I'm trying to install the mechainze gem on my mac os, however when I typed gem install mechanize, after a few seconds, it poped out:
Building native extensions. This could take a while...
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
/Users/Tim/.rvm/rubies/ruby-1.9.3-p545/bin/ruby extconf.rb
checking for main() in -lstdc++... yes
checking for ruby/encoding.h... yes
creating Makefile
make clean
make
compiling unf.cc
g++: error: unrecognized command line option '-Wshorten-64-to-32'
make: *** [unf.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/Tim/.rvm/gems/ruby-1.9.3-p545#global/gems/unf_ext-0.0.6 for inspection.
Results logged to /Users/Tim/.rvm/gems/ruby-1.9.3-p545#global/extensions/x86_64-darwin-12/1.9.1/unf_ext-0.0.6/gem_make.out
I have no idea why this happened and is there anyone willing to help?
Thanks!
PS: I found out that actually a long time ago I set the default compiler to g++ instead of clang. Does this matter?
Actually this is indeed caused by my switching the default compiler to gcc4.7. After I switched back(command: sudo port select --set gcc llvm-gcc42), it went well smoothly.

Ruby gem version_sorter on OS X 10.9

I've tried to make update for Gitlab Installation guide for OS X (https://github.com/CiTroNaK/Installation-guide-for-GitLab-on-OS-X) for the newest version of Gitlab 6.7.
I use OS X 10.9 with xcode command lines tools and I ended with this error for version_sorter gem:
Building native extensions. This could take a while...
ERROR: Error installing version_sorter:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for pcre_compile() in -lpcre... yes
creating Makefile
make "DESTDIR="
compiling rb_version_sorter.c
compiling version_sorter.c
version_sorter.c:49:16: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while (cur = vsi->head) {
~~~~^~~~~~~~~~~
version_sorter.c:49:16: note: place parentheses around the assignment to silence this warning
while (cur = vsi->head) {
^
( )
version_sorter.c:49:16: note: use '==' to turn this assignment into an equality comparison
while (cur = vsi->head) {
^
==
1 warning generated.
linking shared-object version_sorter.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [version_sorter.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/version_sorter-1.1.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/version_sorter-1.1.0/ext/version_sorter/gem_make.out
Unfortunately I do not have enough knowledge to fix it. Could someone help me please?
A recent XCode update broke quite a bit of native code compilation, try this:
Add ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future to whatever you were running above. It looks like the Gitlab instructions are installing it using the system Ruby, so try this:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install version_sorter

Thrift Ruby gem

I cannot, for the life of me, successfully run "gem install thrift", the thing fails when building the gem's native extensions; this is the output:
(acib708) ~ -> gem install thrift
Building native extensions. This could take a while...
ERROR: Error installing thrift:
ERROR: Failed to build gem native extension.
/Users/acib708/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
extconf.rb:25:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:25:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for strlcpy() in string.h... yes
creating Makefile
make "DESTDIR="
compiling binary_protocol_accelerated.c
compiling bytes.c
compiling compact_protocol.c
compiling memory_buffer.c
compiling protocol.c
compiling strlcpy.c
^
(...)
In file included from strlcpy.c:20:
./strlcpy.h:28:15: error: conflicting types for '__builtin___strlcpy_chk'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
__builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
^
./strlcpy.h:28:15: note: '__builtin___strlcpy_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
__builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
^
4 errors generated.
make: *** [strlcpy.o] Error 1
Gem files will remain installed in /Users/acib708/.rvm/gems/ruby-2.0.0-p247/gems/thrift-0.9.1 for inspection.
Results logged to /Users/acib708/.rvm/gems/ruby-2.0.0-p247/gems/thrift-0.9.1/ext/gem_make.out
I've seen lots of similar errors around the web, but I haven't found the solution. I'm running OS X 10.9, with a fresh rvm/ruby-2.0.0-p247 install. Any ideas?
Thanks.
the issue for the moment can be found at https://issues.apache.org/jira/browse/THRIFT-2219
As a temporary fix for folks using gems, you can try setting the #define'ing the _FORTIFY_SOURCE macro to 0 to make strlcpy a function rather than a macro:
gem install thrift -- --with-cppflags='-D_FORTIFY_SOURCE=0'
or if you're using bundler, you can set the cflags for thrift locally via:
bundle config build.thrift --with-cppflags='-D_FORTIFY_SOURCE=0'
On OS 10.9.4 the command below worked for me
bundle config build.thrift "--with-cppflags=-D_FORTIFY_SOURCE=0"
The following should install the gem.
gem install thrift -- --with-cppflags=\"-Wno-compound-token-split-by-macro\"
In bundler, you'll need to do the following until a new ruby release goes out with the fix linked to in the issue above.
bundle config build.thrift --with-cppflags=\"-Wno-compound-token-split-by-macro\"
rather than use a workaround with cppflags I committed a fix which checks for __has_builtin(strlcpy) and if builtins are not available on the system but strlcpy is defined then it uses externs as it previously did. works on os x 10.8, 10.9, centos, ubuntu, ...
Please edit the ~/.bundle/config file then it looks like this:
---
BUNDLE_BUILD__THRIFT: "--with-cppflags=\"-D_FORTIFY_SOURCE=0 -Wno-shift-negative-value\""
It works for me, thanks.

homebrew install postgresql problem

I'm new to OSX and want to install postgresql, as it is my preferred db for django.
I installed xcode and can start it, which is a prerequisite for homebrew.
Then I installed homebrew and run brew install postgresql, getting the following warning and errors. First of all I get an Xcode is not installed warning, whereas it is definitely installed. I think the reason for this warning is described in this post: https://github.com/mxcl/homebrew/issues/2567
Below the traceback.
TK$ brew install postgresql
Warning: Xcode is not installed! Builds may fail!
==> Downloading ftp://ftp.cwru.edu/pub/bash/readline-6.1.tar.gz
File already downloaded and cached to /Users/TK/Library/Caches/Homebrew
==> Downloading patches
######################################################################## 100.0%
######################################################################## 100.0%
==> Patching
patching file complete.c
patching file patchlevel
patching file readline.h
patching file patchlevel
==> ./configure --prefix=/usr/local/Cellar/readline/6.1 --mandir=/usr/local/Cell
checking build system type... i386-apple-darwin10.7.3
checking host system type... i386-apple-darwin10.7.3
Beginning configuration for readline-6.1 for i386-apple-darwin10.7.3
checking whether make sets $(MAKE)... no
checking for gcc... /usr/bin/cc
checking for C compiler default output file name...
configure: error: in `/private/tmp/homebrew-readline-6.1-3bbC/readline-6.1':
configure: error: C compiler cannot create executables
See `config.log' for more details.
==> Exit Status: 77
http://github.com/mxcl/homebrew/blob/master/Library/Formula/readline.rb#L24
==> Environment
/usr/local/Library/Homebrew/utils.rb:275:in `llvm_build_version': undefined method `/' for "/Developer":String (NoMethodError)
from /usr/local/Library/Homebrew/cmd/--config.rb:9:in `llvm'
from /usr/local/Library/Homebrew/cmd/--config.rb:61:in `config_s'
from /usr/local/bin/brew:116
If i run brew-config I get the following trackeback.
TK$ brew --config
Error: undefined method `/' for "/Developer":String
Please report this bug: https://github.com/mxcl/homebrew/wiki/new-issue
/usr/local/Library/Homebrew/utils.rb:275:in `llvm_build_version'
/usr/local/Library/Homebrew/cmd/--config.rb:9:in `llvm'
/usr/local/Library/Homebrew/cmd/--config.rb:61:in `config_s'
/usr/local/Library/Homebrew/cmd/--config.rb:5:in `__config'
/usr/local/bin/brew:82:in `send'
/usr/local/bin/brew:82
Any idea what I did wrong?
configure: error: C compiler cannot create executables
and
Error: undefined method `/' for "/Developer":String
suggest that you do not have Xcode and gnu c++ installed. Install code from your OS disk or register as a developer (free) and get XCode 3 or buy Xcode from AppStore,

Resources