ninjudd / memcache

Advanced ruby memcache client
MIT License
47 stars 23 forks source link

Cant get the native extension to work #26

Open ChrisPortman opened 10 years ago

ChrisPortman commented 10 years ago

gem install memcache works without error. I can see that I have /var/lib/gems/1.9.1/gems/memcache-1.5.1/lib/memcache/native_server.so

OS: Linux Mint 17 (Ubuntu 14.04)

when i require 'memcache' i get: memcache is not using native bindings. for faster performance, compile extensions by hand or install as a local gem.

Let me know what other info you need. I havent been able to google up anything.

Thanks, Chris

zerolith commented 9 years ago

Same here

*** Using Ruby version: 2.1.3
*** with CPPFLAGS:  $(DEFS) $(cppflags)
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling native_server.c
native_server.c: In function ‘escape_key’:
native_server.c:159:51: error: ‘struct RString’ has no member named ‘len’
 #define RSTRING_SET_LEN(str, newlen) (RSTRING(str)->len = new_len)
                                                   ^
native_server.c:179:5: note: in expansion of macro ‘RSTRING_SET_LEN’
     RSTRING_SET_LEN(key, new_len);
     ^
native_server.c: In function ‘unescape_key’:
native_server.c:159:51: error: ‘struct RString’ has no member named ‘len’
 #define RSTRING_SET_LEN(str, newlen) (RSTRING(str)->len = new_len)
                                                   ^
native_server.c:218:5: note: in expansion of macro ‘RSTRING_SET_LEN’
     RSTRING_SET_LEN(key, new_len);
     ^
make: *** [native_server.o] Fehler 1

make failed, exit code 2
Wulfson commented 8 years ago

Also getting a bunch of log spam from the message here: https://github.com/ninjudd/memcache/blob/master/lib/memcache.rb#L10

When I made a test.rb file with the following:

#!/usr/bin/ruby1.9.1
require 'memcache/native_server'

I get this error:

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require': libmemcached.so.11: cannot open shared object file: No such file or directory - /var/lib/gems/1.9.1/gems/memcache-1.5.1/lib/memcache/native_server.so (LoadError)
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
        from ./test.rb:2:in `<main>'

But, if I navigate to that dir, I definitely see native_server.so:

/var/lib/gems/1.9.1/gems/memcache-1.5.1/lib/memcache$ ls -al
total 80
drwxr-xr-x 2 root root  4096 Oct 28 15:34 ./
drwxr-xr-x 3 root root  4096 Oct 28 15:31 ../
-rw-r--r-- 1 root root  1464 Oct 28 15:31 base.rb
-rw-r--r-- 1 root root  1387 Oct 28 15:31 local_server.rb
-rw-r--r-- 1 root root   570 Oct 28 15:31 migration.rb
-rwxr-xr-x 1 root root 35336 Oct 28 15:34 native_server.so*
-rw-r--r-- 1 root root   408 Oct 28 15:31 null_server.rb
-rw-r--r-- 1 root root  4461 Oct 28 15:31 pg_server.rb
-rw-r--r-- 1 root root  3368 Oct 28 15:31 segmented.rb
-rw-r--r-- 1 root root  7020 Oct 28 15:31 server.rb
sbbowers commented 6 years ago

That rescue message is unhelpfully clobbering the real reason why the native extension isn't working:

libmemcached.so.11: cannot open shared object file: No such file or directory

On modern systems, an apt install libmemcached11 should solve this dependency issue.

On older systems, this seems to work:

apt install libmemcached10 ln -s /usr/lib/x86_64-linux-gnu/libmemcached.so.10.0.0 /usr/lib/x86_64-linux-gnu/libmemcached.so.11

(or whatever is similar on your distribution)