matsumotory / mruby-memcached

libmemcached bindings by mruby
Other
8 stars 4 forks source link

uninitialized constant Memcached #1

Open simo2409 opened 9 years ago

simo2409 commented 9 years ago

Hi, I just installed mruby and I'm trying to make it working with nginx. If I execute some examples they work without problem, now I'm trying to read a value from memcached but I'm getting this error: *4 mrb_run failed: return 500 HTTP status code to client: error: INLINE CODE:6: uninitialized constant Memcached (NameError)

I read that mruby-memcached should be enabled by default in mruby and if I try to do mgem list active I get

$ mgem list active
List of active GEMs:
  [X] mruby-memcached     libmemcached bindings by mruby

So I can't understand why mruby doesn't know memcached.

My mruby script is this:

passenger_enabled off;
mruby_content_handler_code '
  Server = Nginx
  r = Nginx::Request.new
  n_id = r.uri.split("/")[3]
  m = Memcached.new "127.0.0.1:11211"
  html = m.get "key_#{n_id}"
  Server::rputs html
  ';

Probably I'm missing something but I can't figure out what it is

Thank you

matsumotory commented 9 years ago

Hi, Could you show me build_config.rb in ngx_mruby/mruby dir? mgem commands may not support current mruby.

simo2409 commented 9 years ago

Hi, after reading your answer I looked at build_config.rb and I saw that memcached was commented. I decommented it, tried to rebuild everything but I had other problems.

First I do ./configure --with-ngx-src-root=/tmp/nginx-1.6.1: output is http://pastie.org/10120894 Then I do make build_mruby: output (with error) is http://pastie.org/10120902

If it's useful I'm running a CentOS7 in vagrant

matsumotory commented 9 years ago

Could you try to build following the instructions of this manual.

https://github.com/matsumoto-r/ngx_mruby/wiki/Install#install

simo2409 commented 9 years ago

I think I'm following it, I do:

$ cd
$ git clone git://github.com/matsumoto-r/ngx_mruby.git
$ cd ngx_mruby
$ git submodule init
$ git submodule update
Change build_config.rb enabling memcached
$ ./configure --with-ngx-src-root=/tmp/nginx-1.6.1
$ make build_mruby

And here I get the error: http://pastie.org/10121724

My build_config.rb, after my edit, is: http://pastie.org/10121736

Could it be a wrong libmemcached version?

I don't know if it's useful but: CentOS 7 nginx 1.6.1 libmemcached.x86_64 1.0.16-3.el7 libmemcached-devel.x86_64 1.0.16-3.el7

matsumotory commented 9 years ago

I guess, this error was coused by this bug https://bugs.launchpad.net/libmemcached/+bug/1281907

You should use other libmemcached package.

simo2409 commented 9 years ago

Thank you @matsumoto-r for your guess, I was not able to find any related error. Finally, after trying many versions of libmemcached, I found that the latest working one is 1.0.15 (all later versions gave errors).

simo2409 commented 9 years ago

My previous message was not true. I tried to re-provision VM from scratch and I'm still having the same error:

/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/libmemcached.so: undefined reference "pthread_once"
collect2: error: ld returned 1 exit status
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/libmemcached.so: undefined reference "pthread_once"
collect2: error: ld returned 1 exit status
rake aborted!

I tried different versions of libmemcached, I tried different versions of libtool too (which in some similar issues found on google was identified as the root cause of problems) without luck.

Please let me know which versions of libtool and libmemcached you use to compile without problems and I will try with exactly same versions, I don't know what I can try more