-1
bash-4.2# rake db:create
/opt/rubystack-2.3.1-0/ruby/bin/.ruby.bin: symbol lookup error: /opt/rubystack-2.3.1-0/ruby/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.so: undefined symbol: rb_thread_select
bash-4.2# ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
bash-4.2# rails -v
Rails 4.2.6
bash-4.2# gem list pg

*** LOCAL GEMS ***



  pg (0.18.4, 0.15.1)

what's the problem? it's bitnami's ruby stack.

NOTE: It's NOT pg version's bug? Please check my log! Ruby version 2.3.1, pg version 0.18.4.

Matheus Moreira
  • 17,106
  • 3
  • 68
  • 107
Albert.Qing
  • 4,220
  • 4
  • 37
  • 49

1 Answers1

2

The rb_thread_select function has been deprecated since Ruby 1.9.3. It was replaced by the rb_thread_fd_select function as of Ruby 2.2:

VA  VD  VR
old 193 22  rb_thread_select -> rb_thread_fd_select

However, the pg gem has been using the correct function since version 0.15. Here's the relevant section of pg_connection.c @ e5cb1df:

#ifndef HAVE_RB_THREAD_FD_SELECT
#define rb_fdset_t fd_set
#define rb_fd_init(f)
#define rb_fd_zero(f)  FD_ZERO(f)
#define rb_fd_set(n, f)  FD_SET(n, f)
#define rb_fd_term(f)
#define rb_thread_fd_select rb_thread_select
#endif

These directives are evaluated at compile time, so the C extension's shared object must have been compiled incorrectly.

The HAVE_RB_THREAD_FD_SELECT macro must not have been defined when pg_ext.so was built. This could have happened because:

  • It was built against a Ruby that did not have rb_thread_fd_select
  • It was incorrectly configured during the build process

References:

Matheus Moreira
  • 17,106
  • 3
  • 68
  • 107
  • `It was built against a Ruby that did not have rb_thread_fd_select`: Did you mean ,when bundle install ,it point to a bad ruby version?@Matheus Moreira – Albert.Qing May 07 '16 at 02:33
  • @Albert.Qing, if you installed the gem yourself and it built the extension at that time, it is possible that the Ruby the build system checked didn't have the `rb_thread_fd_select` function. So, it probably wasn't the latest version; an older system Ruby perhaps? – Matheus Moreira May 07 '16 at 02:41
  • 1
    You solved my puzzle,I guess the bitnami's ruby may have problem,thank's @Matheus Moreira – Albert.Qing May 07 '16 at 02:51
  • @Albert.Qing so how did you proceed to make things work? I'm facing the same problem :) #bitnamiFtw – gabriel-kaam Sep 09 '16 at 10:17