I just cloned a repository from GitHub for the first time.
I went to check it out on my local machine, so within the local repository on my mac I ran the following command
bin/rails server
I got the following error:
Could not find activesupport-5.0.0.1 in any of the sources
Run bundle install to install missing gems.
So I then ran the bundle install command as suggested, but then it gave me the following error
An error occurred while installing oj (2.12.14), and Bundler cannot continue.
Make sure that gem install oj -v '2.12.14' succeeds before bundling.
So as suggested I ran: gem install oj -v '2.12.14'
Then I got a really long message with warning and an error (see below). Any thoughts?
ERROR: Error installing oj:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14/ext/oj
/usr/local/opt/ruby/bin/ruby -r ./siteconf20170218-3717-1p2bvl9.rb extconf.rb
>>>>> Creating Makefile for ruby version 2.4.0 on x86_64-darwin16 <<<<<
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14/ext/oj
make "DESTDIR=" clean
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14/ext/oj
make "DESTDIR="
compiling cache8.c
compiling circarray.c
compiling compat.c
compiling dump.c
dump.c:503:8: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
cnt = RSTRING_LEN(rstr);
~ ^~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:976:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : \
^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:972:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dump.c:503:8: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
cnt = RSTRING_LEN(rstr);
~ ^~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:977:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
dump.c:1776:39: warning: 'rb_struct_ptr' is deprecated [-Wdeprecated-declarations]
for (i = (int)RSTRUCT_LEN(obj), vp = RSTRUCT_PTR(obj); 0 < i; i--, vp++) {
^
/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:1190:33: note: expanded from macro 'RSTRUCT_PTR'
#define RSTRUCT_PTR(st) rb_struct_ptr(st)
^
/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/intern.h:889:25: note: 'rb_struct_ptr' has been explicitly marked deprecated here
DEPRECATED(const VALUE *rb_struct_ptr(VALUE s));
^
dump.c:1776:37: warning: assigning to 'VALUE *' (aka 'unsigned long *') from 'const VALUE *' (aka 'const unsigned long *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
for (i = (int)RSTRUCT_LEN(obj), vp = RSTRUCT_PTR(obj); 0 < i; i--, vp++) {
^ ~~~~~~~~~~~~~~~~
4 warnings generated.
compiling err.c
compiling fast.c
fast.c:816:17: warning: 'rb_data_object_alloc' is deprecated: by rb_data_object_wrap [-Wdeprecated-declarations]
doc->self = rb_data_object_alloc(clas, doc, 0, free_doc_cb);
^
/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/ruby.h:1379:1: note: 'rb_data_object_alloc' has been explicitly marked deprecated here
rb_data_object_alloc(VALUE klass, void *data, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
^
fast.c:1280:24: error: use of undeclared identifier 'rb_cFixnum'
case T_FIXNUM: type = rb_cFixnum; break;
^
1 warning and 1 error generated.
make: *** [fast.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/oj-2.12.14 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/oj-2.12.14/gem_make.out
Fixnum is no longer a thing in ruby 2.4. Either downgrade your ruby or update oj to 2.16.1, which supports ruby 2.4.
Related
Issue while installing semacode gem from gemfile. is there a way to resolve this? i am running bundle install. Is this a issue with my machine or a gem issue? This issue did happen for the first time on my machine when i tried to run the application locally.
Using semacode 0.7.5 from https://github.com/toretore/semacode.git (at master#4e31e0b)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
make "DESTDIR=" clean
.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/bundler/gems/semacode-4e31e0b79a1a/ext
make "DESTDIR="
compiling reedsol.c
compiling semacode.c
semacode.c:61:3: error: implicit declaration of function 'iec16022init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
iec16022init(&semacode->width, &semacode->height, message);
^
semacode.c:96:28: warning: 'bzero' call operates on objects of type 'semacode_t' (aka 'struct semacode_t') while the size is based on a different type 'semacode_t *' (aka 'struct
semacode_t *') [-Wsizeof-pointer-memaccess]
bzero(semacode, sizeof(semacode));
~~~~~~~~ ^~~~~~~~
semacode.c:96:28: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?
bzero(semacode, sizeof(semacode));
^~~~~~~~
semacode.c:129:27: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
encode_string(semacode, StringValueLen(message), StringValuePtr(message));
~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RSTRING_EMBED_LEN(str) : \
^~~~~~~~~~~~~~~~~~~~~~
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semacode.c:129:27: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
encode_string(semacode, StringValueLen(message), StringValuePtr(message));
~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-2.3.0/ruby/ruby.h:995:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
semacode.c:239:20: warning: equality comparison result unused [-Wunused-comparison]
semacode->data == NULL;
~~~~~~~~~~~~~~~^~~~~~~
semacode.c:239:20: note: use '=' to turn this equality comparison into an assignment
semacode->data == NULL;
^~
=
semacode.c:243:44: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
DATA_PTR(self) = encode_string(semacode, StringValueLen(message), StringValuePtr(message));
~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/ruby.h:994:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : \
^~~~~~~~~~~~~~~~~~~~~~
.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/ruby.h:990:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semacode.c:243:44: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
DATA_PTR(self) = encode_string(semacode, StringValueLen(message), StringValuePtr(message));
~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:27: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/ruby.h:995:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
6 warnings and 1 error generated.
make: *** [semacode.o] Error 1
make failed, exit code 2
Gem files will remain installed in .rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/bundler/gems/semacode-4e31e0b79a1a for inspection.
Results logged to .rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/bundler/gems/extensions/x86_64-darwin-19/2.3.0-static/semacode-4e31e0b79a1a/gem_make.out
An error occurred while installing semacode (0.7.5), and Bundler cannot continue.
In Gemfile:
semacode
Try this
gem install semacode -v 0.7.5 -- --with-cflags="-Wno-error=implicit-function-declaration"
Here is more information:
Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)
https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes
I've seen some similar issues on macOS that have only started since v12 was released. If you have v12 you can try downgrading to v11.5 from download.developer.apple.com/Developer_Tools/… and retrying the gem installation
credits - #anothermh
Does anyone know what causes this and how I can fix it? I am trying to install a ruby gem for my project which is an old project running on rails 3, but I'm running on ubuntu 20.04. All I am doing is essentially running bundle install and then I get everything else working except this ruby gem. Please advise!
current directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean
current directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/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’?
439 | my_bool res = mysql_read_query_result(client);
| ^~~~~~~
| bool
client.c: In function ‘rb_query’:
client.c:687:14: warning: passing argument 1 of ‘rb_rescue2’ from incompatible pointer type [-Wincompatible-pointer-types]
687 | rb_rescue2(do_send_query, (VALUE)&args, disconnect_and_raise, self, rb_eException, (VALUE)0);
| ^~~~~~~~~~~~~
| |
| VALUE (*)(void *) {aka long unsigned int (*)(void *)}
In file included from /home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby.h:33,
from ./mysql2_ext.h:8,
from client.c:1:
/home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby/ruby.h:1988:18: note: expected ‘VALUE (*)(VALUE)’ {aka ‘long unsigned int (*)(long unsigned int)’} but argument is of type ‘VALUE (*)(void *)’ {aka ‘long unsigned int (*)(void *)’}
1988 | VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
| ^~~~~~~~~~~~~~~
client.c:695:16: warning: passing argument 1 of ‘rb_rescue2’ from incompatible pointer type [-Wincompatible-pointer-types]
695 | rb_rescue2(do_query, (VALUE)&async_args, disconnect_and_raise, self, rb_eException, (VALUE)0);
| ^~~~~~~~
| |
| VALUE (*)(void *) {aka long unsigned int (*)(void *)}
In file included from /home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby.h:33,
from ./mysql2_ext.h:8,
from client.c:1:
/home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby/ruby.h:1988:18: note: expected ‘VALUE (*)(VALUE)’ {aka ‘long unsigned int (*)(long unsigned int)’} but argument is of type ‘VALUE (*)(void *)’ {aka ‘long unsigned int (*)(void *)’}
1988 | VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
| ^~~~~~~~~~~~~~~
client.c: In function ‘_mysql_client_options’:
client.c:762:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
762 | my_bool boolval;
| ^~~~~~~
| bool
client.c:797:10: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
797 | 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’?
1185 | 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]
1186 | }
| ^
client.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’
make: *** [Makefile:245: client.o] Error 1
I had a similar issue with version 0.4.5, It worked fine for me with version 0.4.10
Try with the below on your Gemfile:
gem 'mysql2', '0.4.10'
The latest version of the mysql2 gem compatible with Rails 3 is v0.3.21 (source).
mysql2 gem v0.3.21 depends on the my_bool datatype in MySQL itself.
MySQL 5.7 has the my_bool datatype but it was removed in MySQL 8.0 (source).
Ubuntu 20.04 does not have MySQL 5.7, only 8.0+ (source).
Therefore you need to install MySQL 5.7 from MySQL's own apt repositories and stop your server from installing any MySQL stuff from Ubuntu's apt repositories.
I just did all this and successfully got a Rails 3.2 app running on Ubuntu 20.04 LTS.
(Also, Rails 3.2.x is only compatible with Ruby <= 2.3.x.)
my env:ruby2.3,rails3,ubuntu20 server
first of all uninstall mysql5.8, and install mysql5.7
you can see this
enter link description here
but the most important is that make sure the libmysqlclient-dev's version before you install gem mysql2'0.3.11' .
the default libmysqlclient-dev's version is 8.0
i download the
libmysqlclient20_5.7.35-1ubuntu18.04_amd64.deb
libmysqlclient-dev_5.7.35-1ubuntu18.04_amd64.deb
and install them sudo dpkg -i them
that ok
Just for fun, I'm attempting to build the irixxxx's qemu-irix as a Docker image.
It builds successfuly under Debian Buster (using GCC 8 container). However, it fails to build under Alpine 3.10 (it fails only when I selected the Irix targets), with the following errors (at the make stage):
CC util/oslib-posix.o
In file included from util/oslib-posix.c:39:
/usr/include/sys/signal.h:1:2: warning: #warning redirecting incorrect #include <sys/signal.h> to <signal.h> [-Wcpp]
#warning redirecting incorrect #include <sys/signal.h> to <signal.h>
^~~~~~~
CC util/qemu-openpty.o
util/qemu-openpty.c: In function 'qemu_openpty_raw':
util/qemu-openpty.c:123:9: warning: implicit declaration of function 'openpty'; did you mean 'openat'? [-Wimplicit-function-declaration]
if (openpty(&amaster, aslave, pty_buf, NULL, NULL) < 0) {
^~~~~~~
openat
util/qemu-openpty.c:123:9: warning: nested extern declaration of 'openpty' [-Wnested-externs]
(...)
CC irix-linux-user/linux-user/syscall.o
/qemu-irix/linux-user/syscall.c:6784:22: error: 'F_EXLCK' undeclared here (not in a function); did you mean 'F_RDLCK'?
TRANSTBL_CONVERT(F_EXLCK),
^~~~~~~
/qemu-irix/linux-user/syscall.c:6779:51: note: in definition of macro 'TRANSTBL_CONVERT'
#define TRANSTBL_CONVERT(a) { -1, TARGET_##a, -1, a }
^
/qemu-irix/linux-user/syscall.c:6785:22: error: 'F_SHLCK' undeclared here (not in a function); did you mean 'F_RDLCK'?
TRANSTBL_CONVERT(F_SHLCK),
^~~~~~~
/qemu-irix/linux-user/syscall.c:6779:51: note: in definition of macro 'TRANSTBL_CONVERT'
#define TRANSTBL_CONVERT(a) { -1, TARGET_##a, -1, a }
^
In file included from /qemu-irix/linux-user/syscall.c:121:
/qemu-irix/linux-user/syscall.c: In function 'target_to_host_sigevent':
/qemu-irix/linux-user/syscall.c:7422:27: error: 'struct sigevent' has no member named '_sigev_un'; did you mean 'sigev_value'?
__get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
^~~~~~~~~
/qemu-irix/linux-user/qemu.h:501:5: note: in definition of macro '__get_user_e'
((x) = (typeof(*hptr))( \
^
/qemu-irix/linux-user/syscall.c:7422:5: note: in expansion of macro '__get_user'
__get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
^~~~~~~~~~
/qemu-irix/linux-user/syscall.c:7422:36: error: '(const bitmask_transtbl *)&<erroneous-expression>' is a pointer; did you mean to use '->'?
__get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
^
/qemu-irix/linux-user/qemu.h:501:5: note: in definition of macro '__get_user_e'
((x) = (typeof(*hptr))( \
^
/qemu-irix/linux-user/syscall.c:7422:5: note: in expansion of macro '__get_user'
__get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
^~~~~~~~~~
/qemu-irix/linux-user/qemu.h:506:13: warning: left-hand operand of comma expression has no effect [-Wunused-value]
(hptr)), (void)0)
^
/qemu-irix/linux-user/qemu.h:510:31: note: in expansion of macro '__get_user_e'
# define __get_user(x, hptr) __get_user_e(x, hptr, be)
^~~~~~~~~~~~
/qemu-irix/linux-user/syscall.c:7422:5: note: in expansion of macro '__get_user'
__get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
^~~~~~~~~~
/qemu-irix/linux-user/syscall.c: In function 'do_syscall':
/qemu-irix/linux-user/syscall.c:13545:25: warning: implicit declaration of function 'sethostid'; did you mean 'gethostid'? [-Wimplicit-function-declaration]
ret = get_errno(sethostid(arg1));
^~~~~~~~~
gethostid
/qemu-irix/linux-user/syscall.c:13545:25: warning: nested extern declaration of 'sethostid' [-Wnested-externs]
make[1]: *** [/qemu-irix/rules.mak:66: linux-user/syscall.o] Error 1
make: *** [Makefile:472: subdir-irix-linux-user] Error 2
The command '/bin/sh -c make && DESTDIR=/tmp/qemu make install' returned a non-zero code: 2
I researched about the differences between Debian's and Alpine's GCC (in fact, libc6 and musl) about similar failures, but I haven't found any information about how to solve this without modifying the code.
So, where can I find more information about this issue and which packages may solve it? Thanks.
Dockerfiles and full log here. Docker container image (Debian Buster) here.
The difference seems to be caused by the underlying libc implementations: glibc of Debian, vs musl-libc of Alpine.
While GNU libc is the defacto standard libc implementation in Linux, musl libc is used by a handful of distributions, such as Alpine Linux and Void Linux. musl is a minimalistic strict-POSIX libc implementation, and is generally not compatible with glibc. Usually, software projects have to be ported to musl libc to be supported on Alpine, especially non trivial applications.
The compilation of syscall.c breaks on several places, the first being:
/qemu-irix/linux-user/syscall.c:6784:22: error: 'F_EXLCK' undeclared here (not in a function); did you mean 'F_RDLCK'?
TRANSTBL_CONVERT(F_EXLCK)
The F_EXLCK is macro is not defined in musl libc's fcntl.h. However, it could be easily patched by defining it manually, for example with make CFLAGS='"-DF_EXLCK=4"'. This is how qemu is patched for musl for non-irix targets (patch link).
However, there are more undefined macros down the road, such as __SIGRTMIN and __SIGRTMAX, the macro TRANSTBL_CONVERT, and probably others. Patching them ad-hoc may not be enough - so it appears to be that the qemu-irix project has to be properly ported for Alpine and musl libc.
If you're willing, you could try following existing qemu musl patches, and attempt to patch it yourself for qemu-irix:
- https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg04773.html
- https://github.com/NixOS/nixpkgs/pull/46449/files
Off topic comment, use make -j to build parallely, which will end much faster.
I'm trying to bundle install a Rails 3.2 LTS app on my mac (High Sierra), but when it gets to the mysql2 gem it fails:
current directory: /Users/Daniel/.gem/ruby/2.3.5/gems/mysql2-0.3.21/ext/mysql2
/Users/Daniel/.rubies/ruby-2.3.5/bin/ruby -r ./siteconf20180828-30901-1g9qqrc.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/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting rpath to /usr/local/Cellar/mysql/8.0.12/lib
-----
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/Daniel/.gem/ruby/2.3.5/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.3.21/mkmf.log
current directory: /Users/Daniel/.gem/ruby/2.3.5/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/Daniel/.gem/ruby/2.3.5/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling client.c
client.c:367:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
elapsed_time = end_time - start_time;
~ ~~~~~~~~~^~~~~~~~~~~~
client.c:439:3: error: use of undeclared identifier 'my_bool'
my_bool res = mysql_read_query_result(client);
^
client.c:441:19: error: use of undeclared identifier 'res'
return (void *)(res == 0 ? Qtrue : Qfalse);
^
client.c:762:3: error: use of undeclared identifier 'my_bool'
my_bool boolval;
^
client.c:793:7: error: use of undeclared identifier 'boolval'
boolval = (value == Qfalse ? 0 : 1);
^
client.c:794:17: error: use of undeclared identifier 'boolval'
retval = &boolval;
^
client.c:797:10: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
case MYSQL_SECURE_AUTH:
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.12/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here
MYSQL_DEFAULT_AUTH,
^
client.c:798:7: error: use of undeclared identifier 'boolval'
boolval = (value == Qfalse ? 0 : 1);
^
client.c:799:17: error: use of undeclared identifier 'boolval'
retval = &boolval;
^
client.c:830:38: error: use of undeclared identifier 'boolval'
wrapper->reconnect_enabled = boolval;
^
client.c:1152:56: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
client.c:1185:38: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.12/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here
MYSQL_DEFAULT_AUTH,
^
2 warnings and 10 errors generated.
make: *** [client.o] Error 1
make failed, exit code 2
I've tried all the other tricks associated with fixing issues like this, but none of them have worked, which is why I'm posting here.
UPDATE:
I think I know what the problem is - I'm running mysql 8 on my machine, but the mysql2 0.3 gem isn't compatible with this - so I think a new question is required - how can I install both mysql 5.* and mysql8, and have each of them with with the relevant versions of the mysql2 gem?
Do I even need to use 8, or can I get away with just using 5.7?
You've probably found the answer to this by now but incase not (or incase I forget and need to Google this again), here is what worked for me:
gem install mysql2 -v '0.3.21' -- --with-opt-dir="$(brew --prefix openssl)"
I am using Rails 4.2.11 and MySQL server version 5.7.24 (installed via Homebrew)
After installing sqlite, libsqlite0-dev and libsqlite3-dev (and ruby1.9.3 of course) on my Ubuntu 12.04.4 LTS, I do :
sudo gem install sqlite-ruby
And here is the log I got :
Building native extensions. This could take a while...
ERROR: Error installing sqlite-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking for main() in -lsqlite... yes
checking for sqlite.h... yes
checking for sqlite_open() in -lsqlite... yes
creating Makefile
make
compiling sqlite-api.c
sqlite-api.c: In function 'static_api_open':
sqlite-api.c:273:15: warning: assignment makes pointer from integer without a cast [enabled by default]
sqlite-api.c: In function 'static_api_compile':
sqlite-api.c:335:28: warning: passing argument 2 of 'sqlite_compile' makes pointer from integer without a cast [enabled by default]
/usr/include/sqlite.h:657:5: note: expected 'const char *' but argument is of type 'int'
sqlite-api.c: In function 'static_api_complete':
sqlite-api.c:548:3: warning: passing argument 1 of 'sqlite_complete' makes pointer from integer without a cast [enabled by default]
/usr/include/sqlite.h:260:5: note: expected 'const char *' but argument is of type 'int'
sqlite-api.c: In function 'static_api_set_result':
sqlite-api.c:783:24: error: 'struct RString' has no member named 'ptr'
sqlite-api.c:784:24: error: 'struct RString' has no member named 'len'
sqlite-api.c: In function 'static_api_set_result_error':
sqlite-api.c:820:53: error: 'struct RString' has no member named 'ptr'
sqlite-api.c:821:20: error: 'struct RString' has no member named 'len'
sqlite-api.c: In function 'static_raise_db_error':
sqlite-api.c:1181:3: warning: format not a string literal and no format arguments [-Wformat-security]
make: *** [sqlite-api.o] Error 1
Gem files will remain installed in /var/lib/gems/1.9.1/gems/sqlite-ruby-2.2.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/sqlite-ruby-2.2.3/ext/gem_make.out
Can somebody help me on installing that lib ? (my main problem is to migrate a Trac project to a Redmine following that documentation)
Thanks to Graeme McLean's comment my question, http://boga.wordpress.com/2008/04/15/ruby-19-porting-notes/, https://www.ruby-forum.com/topic/4405578 and http://guides.rubygems.org/make-your-own-gem/, I managed to patch the sqlite-ruby gem, build it and install it :
gem fetch sqlite-ruby
gem unpack sqlite-ruby-2.2.3.gem
cd sqlite-ruby-2.2.3/
sed -i 's/RSTRING(\(.*\))->ptr/RSTRING_PTR(\1)/g' ext/sqlite-api.c
sed -i 's/RSTRING(\(.*\))->len/RSTRING_LEN(\1)/g' ext/sqlite-api.c
gem unpack --spec ../sqlite-ruby-2.2.3.gem
sed -i 's/version: 2.2.3/version: 2.2.3.patched/' sqlite-ruby-2.2.3.gemspec
cat >> sqlite-ruby-2.2.3.gemspec <<EOF
cert_chain: []
licenses: []
required_rubygems_version: !ruby/object:Gem::Version::Requirement
requirements:
-
- ">="
- !ruby/object:Gem::Version
version: 1.8.0
version:
EOF
gem build sqlite-ruby-2.2.3.gemspec
sudo gem install sqlite-ruby --local