gem install pg | error: ‘PQERRORS_SQLSTATE’ undeclared - ruby

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.

Related

Error installing gem mysql2 -v 0.3.21 on RHEL 8

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.

Install wget on mac

I downloaded wget-1.19.tar.gz from this site http://ftp.gnu.org/gnu/wget/ and then i exctract the tar file and run
./configure
The output is that:
checking for ftello... yes
checking for sigblock... yes
checking for sigsetjmp... yes
checking for memrchr... (cached) no
checking for wcwidth... (cached) yes
checking for mbtowc... yes
checking for sleep... yes
checking for symlink... (cached) yes
checking for utime... yes
checking for strlcpy... yes
checking for random... yes
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for LIBPSL... no
checking for library containing psl_builtin... no
configure: WARNING: *** libpsl was not found. Fallback to builtin cookie checking.
checking for ZLIB... yes
checking for GNUTLS... no
configure: error: Package requirements (gnutls) were not met:
No package 'gnutls' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables GNUTLS_CFLAGS
and GNUTLS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
I found different guides on the web, but none solve my problem.
I try to install different package with brew, for example
brew install gnutls
but nothing works.
In fact if I do brew install gnutls, seems to be correct, but if i digit
make
the error is that:
/Library/Developer/CommandLineTools/usr/bin/make all-recursive
Making all in lib
/Library/Developer/CommandLineTools/usr/bin/make all-recursive
make[4]: Nothing to be done for `all-am'.
Making all in src
/Library/Developer/CommandLineTools/usr/bin/make all-am
CC ftp.o
ftp.c:1466:19: error: no member named 'rpl_unlink' in 'struct options'
if (opt.unlink && file_exists_p (con->target))
~~~ ^
../lib/unistd.h:1851:19: note: expanded from macro 'unlink'
# define unlink rpl_unlink
^
error: error opening '.deps/ftp.Tpo': Permission denied
2 errors generated.
make[3]: *** [ftp.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Can anyone help me?
I want to install wget on my Mac because I have to download folders in this page http://www.tlc.dii.univpm.it/fb4fd/ and using curl I can't download them in recursive way.
there are instructions to install wget here. It involves loading wget using Ruby and then running brew install wget.
From terminal run the following commands:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
then run:
brew install wget

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.

ERROR: Failed to build gem native extension (ruby extconf.rb): Mac OSX [duplicate]

This question already has answers here:
Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply_definedsuppress'
(11 answers)
Closed 8 years ago.
I am attempting to install a gem, and I get this error, which myself and the gem author have never seen before. How do I fix this?
Davids-MacBook-Pro:web david$ sudo /usr/bin/gem install compass --pre
Password:
Building native extensions. This could take a while...
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... 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 "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:303:5: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
^
1 warning generated.
compiling ClosurePool.c
compiling DataConverter.c
DataConverter.c:43:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling DynamicLibrary.c
compiling ffi.c
compiling Function.c
Function.c:479:33: warning: incompatible pointer types passing 'VALUE (void *)' to parameter of type 'void *(*)(void *)' [-Wincompatible-pointer-types]
rb_thread_call_with_gvl(callback_with_gvl, &cb);
^~~~~~~~~~~~~~~~~
Function.c:102:46: note: passing argument to parameter 'func' here
extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
^
Function.c:563:9: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
rb_thread_call_without_gvl(async_cb_wait, &w, async_cb_stop, &w);
^
Function.c:738:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
3 warnings generated.
compiling FunctionInfo.c
compiling LastError.c
compiling LongDouble.c
compiling MappedType.c
compiling MemoryPointer.c
compiling MethodHandle.c
compiling Platform.c
compiling Pointer.c
compiling Struct.c
compiling StructByReference.c
compiling StructByValue.c
compiling StructLayout.c
compiling Thread.c
compiling Type.c
compiling Types.c
compiling Variadic.c
linking shared-object ffi_c.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: *** [ffi_c.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/ext/ffi_c/gem_make.out
If this is occuring in OSX Mavericks, please ensure the command line tools are installed by running the following.
Older editions of OSX & XCode had the install for Command Line Tools in the XCode IDE itself. In OSX Mavericks I had to run the commands below to fix my command line tools so that I could install rubygems using native extensions.
$ sudo xcode-select --install
$ xcode-select --print-path
/Library/Developer/CommandLineTools
Try this:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install <gemName>
For an explanation see this answer
On OSX-10.9.5 using xcode-select --install did not work for me. It started and asked to confirm the licence but then reported that it could not find the software.
I ended up visiting: https://developer.apple.com/downloads/index.action#, downloading the appropriate CommandLineTools dmg for OSX-10.9.5, installing the tools manually from the pkg, and then using: xcode-select --switch=/Library/Developer/CommandLineTools, to set the path.
After which everything worked fine.
This is an Apple LLVM error.
For now, you can:
export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
Though as you can see from the warning name this not a permanent solution.
Source: https://langui.sh/2014/03/10/wunused-command-line-argument-hard-error-in-future-is-a-harsh-mistress/

Installing Ruby 1.9.3 Troubles with Clang

I am attempting to install Ruby 1.9.3 on Mac OS X Lion, same method as I discovered here:
Basically it's:
rvm install 1.9.3 --with-gcc=clang --with-readline-dir=$rvm_path/usr
However, this time Clang throws an error on the --with-readline-dir option:
Larson:~ andrewjl$ rvm install 1.9.3 --with-gcc=clang --with-readline-dir=$rvm_path/usr
clang: error: unsupported option '--with-readline'
clang: error: unsupported option '--with-opt-dir=/Users/andrewjl/.rvm/usr'
Is this an issue with Clang? Does anybody know how to get around this?
EDIT
After trying Shigeya's answer I get this error:
Larson:~ andrewjl$ rvm install 1.9.3-p125 --patch xcode-debugopt-fix-r34840.diff --with-readline-dir=$rvm_path/usr --with-openssl-dir=$rvm_path/usr --with-tcl-lib=/usr --with-tk-lib=/usr
Installing Ruby from source to: /Users/andrewjl/.rvm/rubies/ruby-1.9.3-p125, this may take a while depending on your cpu(s)...
ruby-1.9.3-p125 - #fetching
ruby-1.9.3-p125 - #downloading ruby-1.9.3-p125, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9505k 100 9505k 0 0 52267 0 0:03:06 0:03:06 --:--:-- 50727
ruby-1.9.3-p125 - #extracting ruby-1.9.3-p125 to /Users/andrewjl/.rvm/src/ruby-1.9.3-p125
ruby-1.9.3-p125 - #extracted to /Users/andrewjl/.rvm/src/ruby-1.9.3-p125
Applying patch 'xcode-debugopt-fix-r34840.diff' (located at /Users/andrewjl/.rvm/patches/ruby/1.9.3/p125/xcode-debugopt-fix-r34840.diff)
ruby-1.9.3-p125 - #autoreconf
Error running 'autoreconf', please read /Users/andrewjl/.rvm/log/ruby-1.9.3-p125/autoreconf.log
ruby-1.9.3-p125 - #configuring
Error running ' ./configure --prefix=/Users/andrewjl/.rvm/rubies/ruby-1.9.3-p125 --enable-shared --disable-install-doc --with-readline --with-opt-dir=/Users/andrewjl/.rvm/usr --with-openssl --with-tcl-lib=/usr --with-tk-lib=/usr --with-libyaml --with-gcc=clang ', please read /Users/andrewjl/.rvm/log/ruby-1.9.3-p125/configure.log
There has been an error while running configure. Halting the installation.
Here's the log file error:
/usr/local/include/fuse/fuse_compat.h:69:10: fatal error: 'sys/statfs.h' file not found
#include <sys/statfs.h>
^
clang: error: unable to execute command: Broken pipe: 13
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Error generating preprocessed source(s).
yes
checking for strip... strip
checking for prefix of external symbols... _
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for if make is GNU make... yes
checking for nroff... /usr/bin/nroff
.ext/include/x86_64-darwin11.4.0/ruby/config.h updated
ruby library version = 1.9.1
configure: creating ./config.status
config.status: creating Makefile
configure: WARNING: unrecognized options: --with-readline, --with-openssl, --with-tcl-lib, --with-tk-lib, --with-libyaml
In file included from <built-in>:143:
In file included from <command line>:1:
In file included from /usr/local/include/fuse/fuse.h:26:
/usr/local/include/fuse/fuse_common.h:32:2: error: #error Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
#error Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
^
In file included from <built-in>:143:
In file included from <command line>:1:
In file included from /usr/local/include/fuse/fuse.h:857:
/usr/local/include/fuse/fuse_compat.h:69:10: fatal error: 'sys/statfs.h' file not found
#include <sys/statfs.h>
^
clang: error: unable to execute command: Broken pipe: 13
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Error generating preprocessed source(s).
configure: WARNING: unrecognized options: --with-readline, --with-openssl, --with-tcl-lib, --with-tk-lib, --with-libyaml
config.status: creating ruby-1.9.pc
./configure: line 18932: syntax error near unexpected token `('
./configure: line 18932: ` sed 's/{\$([^(){}]*)[^{}]*}//g' ${srcdir}/common.mk'
Refer to this answer.
Even though both ruby-1.9.3-p125 and ruby-1.9.3-p194 some support for clang, installing Ruby with clang is generally not recommended.
(Note: I had to accept edit proposal first, then edit. Thank you very much for contribution.)

Resources