Why need DevKit - ruby

When I tried to setup my debug environment for Ruby.
I have to get gem package debug_base and debug_ide from repository. 'gem install xxx' command will download packages and using DevKit to compile the package. I was thinking why weren't these gem package compiled in advance? So we don't need DevKit to do build job when installing them. Is there any other purpose for DevKit?

Some packages/gems need to be compiled in advance to work because they use native extensions.
This is done automatically by ruby gem when you use the gem command.
Devkit is:
The RubyInstaller Development Kit is a toolkit that makes it easy to build and use native C/C++ extensions such as RDiscount and RedCloth for Ruby on Windows

Related

Ruby Error installing af: failed to build gem native extension

I wanna deploy my grails application on AppFog. To do this, I've installed Ruby 22 x64 and devkit mengv64. I've extracted devkit.7z to C:\ruby, done commands: dk.rb install,dk.rb init. Then, I entered a command: gem install af,
but I got such error: Error installing af: failed to build gem native extension. How to fix it?
There is often an issue with the escape_utils gem. This a general limitation of RubyGems. If there's a problem with a gem dependencies, new installs of the af gem or updates to any of its gem dependencies can screw things up. That's why AppFog v2 is testing a binary executable to avoid this mess.
That being said, the general practice for installing on Windows is to install the Ruby environment you want and install the appropriate dev kit. When that's done, you'll need to find the Ruby Enabled Command Prompt. Usually, Start > Programs > Ruby*. Everything below should now be done from there:
ruby dk.rb install
ruby dk.rb init
gem update --system
gem install escape_utils -v 1.0.1
This gem regularly has problems, especially for Windows, so this is usually the best version to go with for the time being.
gem install af
Here's AF's article for installing the gem on Windows: Installing the AF CLI Tool on Windows.
Either the App Fog gem requires a native extension, or one of its dependencies does.
Does the error show which gem is failing?
According to RubyGems, there are some dependencies. I don't see which one would require a native extension.
So, you may want to try installing the dependencies and see if one of them fails.

How to fix gem install gtk2 in cygwin Ruby on Windows

I choose to use Cygwin for installing ruby on my system than using the usual rubyinstaller way.
Now, just as when I'm trying to install gems I usually use (like gtk2). It squeaks out some errors.
And here's the details: (I'm on Windows 8)
C:\Users\imraven>ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [i386-cygwin]
C:\Users\imraven>gem install gtk2
Building native extensions. This could take a while...
ERROR: Error installing gtk2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
"C:/Program Files (x86)/git/bin/sh.exe": /usr/bin/ruby.exe: No such file or directory
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/glib2-1.1.9 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/glib2-1.1.9/ext/glib2/gem_make.out
What should I do to fix this? The main reason why I'm opting for Cygwin's Ruby is that I wanted to use Process.fork method (which is unavailable from the normal RubyInstaller Windows version of Ruby)
Thanks! :)
You may have installed ruby for windows, and not the cygwin version.
Run the Cygwin setup, and choose Ruby, under the Ruby category. Also make sure that you've installed the gcc compiler and GNU make, under the Devel category, so that the gems can build the native extensions.

JetBrains RubyMine 3.2.4 debugger not working

Running with Ruby 1.9.2
The IDE complains that The gem ruby-debug-base19x is required and offers to install it.
However, upon attempting to install it it displays the message
Failed to install gems. Following gems were not installed: C:/Program
Files (x86)/JetBrains/RubyMine
3.2.4/rb/gems/ruby-debug-base19x-0.11.30.pre2.gem: Error installing ruby-debug-base19x-0.11.30.pre2.gem: The 'linecache19' native gem
requires installed build tools. Please update your PATH to include
build tools or download the DevKit from
'http://rubyinstaller.org/downloads' and follow the instructions at
'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
C:/Program Files (x86)/JetBrains/RubyMine
3.2.4/rb/gems/ruby-debug-ide-0.4.17.beta8.gem: Error installing ruby-debug-ide-0.4.17.beta8.gem: The 'ruby-debug-ide' native gem
requires installed build tools. Please update your PATH to include
build tools or download the DevKit from
'http://rubyinstaller.org/downloads' and follow the instructions at
'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
linecache19 (0.5.12): Error installing linecache19: The 'linecache19'
native gem requires installed build tools. Please update your PATH to
include build tools or download the DevKit from
'http://rubyinstaller.org/downloads' and follow the instructions at
'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
I followed its advice to download the DevKit - but the DevKit upon attempting to install, said that it was already correctly installed as part of Ruby.
Any advice?
The problem is not specific to RubyMine, I'd try to reinstall Ruby and DevKit from scratch.
Verify that DevKit actually works using a test from the installation guide:
gem install rdiscount --platform=ruby
ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html"
If it works fine, try to install the debug gems manually from the console using the following commands:
gem install ruby-debug-base19x --pre
gem install ruby-debug-ide --pre
Post logs, provide more details if it still doesn't work for you.
The gem that rubymine debugger installs by itself conflicts with the existing debug gem in the gemset. Uninstall the existing debug gems, you can get a list by running gem list | grep debug and let rubymine install its own version. Also make sure that you do not have a debug gem mentioned in the Gemfile and also there should not be any debug gem in the global gemset.
I had the same problem.
i was able to get it working by uninstalling and reinstalling RubyMine. Then everything worked perfectly, as expected.
There is an open issue on this at the RubyMine forum. The answer by Roman Melnik worked for me (but my environment is Mac OS).

Playing sound in Ruby 1.9.2 on Windows 7?

When I follow this tutorial on Ruby 1.9.2 on Win 7, I get this error:
Is there a simpler way to play a sound? (specifically, wav)
The problem is that you're using Ruby 1.9.2 and the binary gem for win32-sound, the binary, has not been compiled or made compatible with Ruby 1.9.x, only Ruby 1.8
You can skip this using the RubyInstaller DevKit downloadable from RubyInstaller website.
Please follow the instructions from the DevKit page to complete the installation. Also note that to install win32-sound, you will need to change the command for the gem installation.
First:
gem list win32
gem list windows
Uninstall all the win32- and windows gems
Then:
gem install win32-sound --platform=ruby
That should install and compile a binary compatible with your installed Ruby.
Hope that helps

How do you precompile the native extensions for a ruby gem for linux?

We have a ruby application that depends on a gem with native extensions (in this specific case Nokogiri). However, for various reasons we cannot install the build prerequisites (such as build-essential, libxslt-dev, ruby-dev, etc) for that gem onto our production host.
Is there a (standard?) way to repackage the gem with the native extensions pre-built?
It should be possible (it seems to be fairly standard to do this for Windows), but I can't find any documentation on the subject.
Note that we only need to support a single platform, with known versions of all system libraries (Ubuntu 9.04 Server 64 bit, Ruby 1.8.7).
UPDATE:
We're using Bundler, so we want to still have a gem to install at the end of the day, not a debian package.
Finally found a way to do this for gems that use rake-compiler for building their C extensions (which is most of them).
You need to do the following on a machine that is identical to the one you want to deploy to, or it simply won't work:
Install the build prerequisites for building C extensions:
# apt-get install build-essentials ruby-dev # ... etc
# gem install rake-compiler
Unpack the gem you want to rebuild:
$ gem unpack nokogiri
Build your shiny new precompiled gem:
$ rake native gem
You can now install the native gem on a machine without any build tools installed:
$ gem install pkg/nokogiri-1.4.3.1-x86-linux.gem
Successfully installed nokogiri-1.4.3.1-x86-linux
1 gem installed
Build machine
To have the correctly platformed version for all of your gems already cached,
package all gems in vendor/cache on an identical machine:
$ bundle package --all
Prduction machine
Install all gem dependecies already cached that requires to have the correctly
platformed version using the gem cache:
$ bundle install --local --deployment

Resources