Gem build "recipe for target 'stemmer.so' failed" - ruby

When installing Jekyll from gem using gem install jekyll, I am getting the following build error. I am using Cygwin on Windows 7 and have built the posix-spawn gem from source prior to installing.
Building native extensions. This could take a while...
ERROR: Error installing jekyll-1.1.2.gem:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
creating Makefile
make
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -ggdb -O2 -pipe -fno-strict-aliasing -o porter.o -c porter.c
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -ggdb -O2 -pipe -fno-strict-aliasing -o porter_wrap.o -c porter_wrap.c
rm -f stemmer.so
gcc -shared -o stemmer.so porter.o porter_wrap.o -L. -L/usr/lib -L. -Wl,--export-all-symbols -Wl,--enable-auto-image-base,--enable-auto-import -lruby191 -lpthread -lrt -ldl -lcrypt
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lcrypt
collect2: error: ld returned 1 exit status
Makefile:214: recipe for target `stemmer.so' failed
make: *** [stemmer.so] Error 1
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/fast-stemmer-1.0.2 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/fast-stemmer-1.0.2/ext/gem_make.out
I am using gem v2.0.7, ruby v1.9.3p448, gcc v4.8.1 and g++ v4.8.1
Any ideas? I have no idea when it comes to Ruby gems. I cannot find any information on this "stemmer".
Dan

Turns out the crux of this error was in the cannot find -lcrypt. I installed libcrypt-devel and the gem compiled fine after that.
I think on most native Linux distros, this lib will already be included!

Yeah, Thanks, I installed :-).
Please installing 'libcrypt-devel' in cygwin

Related

Errors Installing the gem wdm in cygwin

I keep getting this error while installing the gem wdm from inside cygwin. Does anybody had the same issue and know now to fix it. Thanks. (I am Trying to install Guard gem)
$ gem install wdm
Building native extensions. This could take a while...
ERROR: Error installing wdm:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for main() in -lkernel32... yes
checking for windows.h... yes
checking for ruby.h... yes
checking for HAVE_RUBY_ENCODING_H... yes
creating Makefile
make
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o entry.o -c entry.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o memory.o -c memory.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o monitor.o -c monitor.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o queue.o -c queue.c
gcc -I. -I/usr/include/ruby-1.9.1/i386-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H -DHAVE_RUBY_H -DHAVE_CONST_HAVE_RUBY_ENCODING_H -ggdb -O2 -pipe -fno-strict-aliasing -o rb_change.o -c rb_change.c
rb_change.c: In function ‘extract_absolute_path_from_notification’:
rb_change.c:47:16: error: ‘_MAX_FNAME’ undeclared (first use in this function)
rb_change.c:47:16: note: each undeclared identifier is reported only once for each function it appears in
rb_change.c:47:33: error: ‘_MAX_EXT’ undeclared (first use in this function)
Makefile:206: recipe for target `rb_change.o' failed
make: *** [rb_change.o] Error 1
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/wdm-0.1.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/wdm-0.1.0/ext/wdm/gem_make.out
A colleague of mine had an issue with wdm the other day.
We fixed it by downloading the Ruby DevKit (Not sure if you already had this installed).
I found some pretty decent step by steps online, I'll paste them here - hope they help
Development kit is here: http://rubyinstaller.org/downloads/
Download the Development Kit and install it in say c:\devkit.
Open a command window and type c:.
Change folders by typing cd devkit.
Type ruby dk.rb init to generate the config.yml file to be used later.
Your installed Rubies will be listed there (only those installed by a RubyInstaller package are detected at present). This needs to be done only once.
Finally type, ruby dk.rb install for DevKit enhance your installed Rubies. This needs to be done only once.
Confirm your Ruby environment is correctly using the DevKit by running:
gem install wdm --platform=ruby
It’s crucial that you include the --platform=ruby option to force RubyGems to build the native gem rather than potentially installing an incorrect binary gem.

How to install gbarcode gem to Ubuntu?

I've problem with gbarcode gem which has dependency gnu-barcode c application.
When trying to say gem install gbarcode it says:
Building native extensions. This could take a while...
ERROR: Error installing gbarcode-linux:
ERROR: Failed to build gem native extension.
/home/user/.rvm/rubies/ruby-1.8.7-p357/bin/ruby extconf.rb
checking for main() in -lbarcode... yes
creating Makefile
make
gcc -I. -I. -I/home/user/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/1.8/x86_64-linux -I. -fPIC -g -O2 -fPIC -c barcode_wrap.c
gcc -shared -o gbarcode.so barcode_wrap.o -L. -L/home/user/.rvm/rubies/ruby-1.8.7-p357/lib -Wl,-R/home/user/.rvm/rubies/ruby-1.8.7-p357/lib -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/user/.rvm/rubies/ruby-1.8.7-p357/lib -L/home/user/.rvm/rubies/ruby-1.8.7-p357/lib -lruby -lbarcode -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libbarcode.a(library.o): relocation R_X86_64_32 against `encodings' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libbarcode.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [gbarcode.so] Error 1
I've tried to install gnu-barcode application from ubuntu software center, apt-get and directly from source http://www.gnu.org/software/barcode/ and the response is always the same.
How should I install gnu barcode so that it's working with the gem.
And yes this project is quite heavy dependent on that gem so replacing it would be really painful to all parties.

CocoaPods installation issue using Xcode 5 and Xcode 4.6.3

After this command sudo gem install cocoapods I got error below.
I think it is connected to the wrong path for Xcode 5. When I installed it I save it on Desktop but them moved it to the Application folder. I use Xcode 4.6.3 as well as Xcode 5. How can I change path to solve this issue. Command line tools are installed on both XCodes.
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -DJSON_GENERATOR -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -O3 -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -c generator.c
xcrun: Error: could not stat active Xcode path '/Users/alex/Desktop/Xcode 5.app/Contents/Developer'. (No such file or directory)
cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o generator.bundle generator.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -lruby -lpthread -ldl -lobjc
clang: error: no such file or directory: 'generator.o'
make: *** [generator.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.8.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
I have run this command in terminal
sudo xcode-select -switch /Applications/Xcode.app
it works for me

Bundler halts on json install, even though there's no json in Gemfile

Project bundle is stopping with error on json installation. But I'm not asking for json in Gemfile. Current Ruby in RVM is 1.9.2-p290, strict.
Have no idea to workaround this. Any helps, maybe?
Installing json (1.7.7)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. - I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -DJSON_GENERATOR -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -O3 -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -c generator.c
xcrun: Error: could not stat active Xcode path '/Developer'. (No such file or directory)
cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o generator.bundle generator.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -lruby -lpthread -ldl -lobjc
i686-apple-darwin11-llvm-gcc-4.2: generator.o: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: generator.o: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/ft/gswz6cs52wb9jh_v5h2yt5_h0000gn/T//ccvGNawc.out
make: *** [generator.bundle] Error 1
Gem files will remain installed in /Users/noAlvaro/.rvm/gems/ruby-1.9.2-p290#heroku_project/gems/json-1.7.7 for inspection.
Results logged to /Users/noAlvaro/.rvm/gems/ruby-1.9.2-p290#heroku_project/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.7'` succeeds before bundling.
Any help, anything, will be much appreciated. :)
Even if you don't explicitly list json as dependency, other gems you are using may do this. As a result, Bundler will include it in the bundled list.
To check which library is using json you can inspect the Gemfile.lock file or use bundle viz to draw your dependency tree.

compiler error while installing rubygem 'mysql2' in Ruby 1.9.2 over CentOS 64-bit

a CentOS 64-bit Server with Ruby 1.8.7 & 1.9.2
{{no RVM, need it without RVM...
currently all Ruby1.9.2 binaries are ruby19 and similarly accessible,
so no mapping of gem-path or anything of that sort is there}}
is giving error while installing gem 'mysql2' ...
I have all dependencies installed and all are 64-bit versions ...
All error are of kind {./client.h:13:
error: redefinition of typedef
‘rb_unblock_function_t’}
Could {#warning rubysig.h is obsolete}
be a reason for this?
Console Capture:
#gem19 install mysql2 -v 0.2.7 -- --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby19 extconf.rb --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql
checking for rb_thread_blocking_region()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -Wall -fno-strict-aliasing -fPIC -Wall -funroll-loops -o result.o -c result.c
In file included from ./client.h:11,
from ./mysql2_ext.h:39,
from result.c:1:
/usr/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
In file included from ./mysql2_ext.h:39,
from result.c:1:
./client.h:13: error: redefinition of typedef ‘rb_unblock_function_t’
/usr/include/ruby-1.9.1/ruby/intern.h:754: error: previous declaration of ‘rb_unblock_function_t’ was here
./client.h:14: error: redefinition of typedef ‘rb_blocking_function_t’
/usr/include/ruby-1.9.1/ruby/intern.h:755: error: previous declaration of ‘rb_blocking_function_t’ was here
./client.h:20: error: static declaration of ‘rb_thread_blocking_region’ follows non-static declaration
/usr/include/ruby-1.9.1/ruby/intern.h:759: error: previous declaration of ‘rb_thread_blocking_region’ was here
./client.h: In function ‘rb_thread_blocking_region’:
./client.h:23: warning: ‘rb_thread_blocking_region_begin’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:31)
./client.h:25: warning: ‘rb_thread_blocking_region_end’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:32)
In file included from ./mysql2_ext.h:39,
from result.c:1:
./client.h:41:7: warning: no newline at end of file
make: *** [result.o] Error 1
This is caused by a patch they introduced on the gem in order for it to run in Ruby 1.8 but it is not needed on Ruby 1.9.
To deactivated this "fix" and be able to install the gem you can define a flag for the compiler:
gem install mysql2 -- --with-cflags=\"-DHAVE_RB_THREAD_BLOCKING_REGION\"
The problem is in the extconf/mkmf section:
rb_thread_blocking_region()... no
But Ruby 1.9.2 defines rb_thread_blocking_region (unless you built Ruby
with some funky set of ifdef's and edits I'm not aware of).
Check your mkmf.log file. It should show you that Ruby failed
to compile/link the conftest.c file that tests for
rb_thread_blocking_region. The reason why is that libcrypt.a
has a dependency on libfreebl3, but the library isn't getting
referenced on the link line.
I fixed the problem by editing /usr/local/lib/ruby/1.9.1/i686-linux/rbconfig.rb like so:
- CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lm "
+ CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lfreebl3 -lm "
I was able to build the mysql2 gem after. No need to install rvm, etc.
What I did to fix it was to re-install Ruby via RVM. There no more errors after that.
Alternatively, remove the block in client.h that is trying to emulate rb_thread_blocking_region for Ruby 1.8 and you'll be good to go.

Resources