Installing ruby gems fails when attempting to build native - ruby

So I decided that I was going to give Ruby (first 1.9.1, then 1.8.7) a try and I wanted to get the basic tools installed before I attempted to do too much.
I have begun to install some gems, and I have run into some issues when I attempt to install one which builds native code on windows 7.
I was attempting to install the ruby debugger and linecache and each time I get the following make error: make: *** No rule to make target %RUBY_HOME%/include/ruby-1.9.1/ruby.h', needed bytrace_nums.o'.
My google-fu has not turned up anything very useful, so I am asking for the SO community to point me in the right direction. When I go used Ruby 1.8.7, i only attempted to install ruby-debug and linecache. When I was using 1.9.1, I attempted to use ruby-debug19 and linecache19. Since the issue is the same for both versions, I assume that it is something wrong on my end, but I do not know where to start.

For some reason, I needed to run the gem install from a Unix shell emulator from the devkit.
I don't know why it worked out the way it did, but this how I fixed the problem.

Related

Can't find installed gems

I am very new to ruby, and am using Ubuntu , I installed ruby last week and have been using it ever since. But when I decided to start studying rails I realised the rails server will not start, I decided to reinstall ruby, and then rails, which I did successfully.
But now when I install a ruby gem, I do not see it, not even when I type gem list on the terminal, it also throws an error when I try to run it in a program. I am very frustrated and do not know what to do..
Try installing RVM instead of ruby directly, this will install the required setting and it will be easier to beginners.
https://rvm.io/rvm/install

Ruby error on OS X Yosemite and chef

Getting this error when trying to install chef on OS X Yosemite, other gems have installed fine. Not seeing a requirement. Just wondering if anyone has and idea of what the issue is or has come across this.
$sudo gem install chef
Building native extensions. This could take a while...
ERROR: Error installing chef:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20141023-4708-6api21.rb extconf.rb
creating Makefile
/Library/Ruby/Gems/2.0.0/gems/libyajl2-1.1.0/ext/libyajl2
extconf.rb:104:in `makemakefiles': unhandled exception
from extconf.rb:138:in `<main>'
extconf failed, exit code 1
EDIT: Although my answer below will help you install it on the system version of Ruby. I would probably suggest using RVM instead as the comment below mentions. I do not use Ruby very often and it would probably be fine, but I decided to take the 10 mins to change it to installing to RVM since that way I leave the system ruby untouched.
As I was searching across the web, I could actually resolve this issue (which also appeared on docker/ubuntu) as suggested in this thread:
https://stackoverflow.com/a/32191707/1948319
Long story short: The gmp library is missing. You can install it on ubuntu with
sudo apt-get install libgmp3-dev
I had this problem with this gem specifically, and another gem with c extensions as well.
Turns out I needed to accept new terms & conditions after updating XCode :-)
sudo xcodebuild -license
So I actually answered my own question very shortly after I posted and I hope it helps someone else in the future.
I used this instead:
$ sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install chef
The Apple LLVM compiler in Xcode treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
Came across this issue which was similar enough:
https://github.com/FontCustom/fontcustom/issues/194

Installing mysql2 gem on Windows 8

I'm trying to install the mysql2 gem on Windows 8 (Ruby 1.9.3 and Rails 4.0.1). I've installed the Devkit and it's working properly, and I'm entering the following:
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-conector"'
I've done this before and it's worked, but for some reason this time it's throwing this bizarre message:
Cannot find include dir at C:\mysql-connector\include;C:\mysql-connector\include;C:\mysql-connector/include;
This is of course in addition to the whole "Could not create makefile for some reason..." message. I'm using the mysql connector that I found through a different post here--Ruby MYSQL2 gem installation on windows 7
Does anyone know how I can fix this? I really need this gem...
I figured this out...
All I had to do was:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector\"'
Strange though--last time it worked with the code above... Go figure...
I just ran into the exact same issue trying to install mysql2 0.3.14 on Window 64bit, Rails 3.2.15 and Ruby 2.0.0p247. I used a command very simliar to what user2986379 posted and it worked; literally 5 minutes later when I had to rerun the command to fix another issue it stopped working. I was even copying the command from notepad each time so there wasn't a typo. Odd.
Anyway, user2986379's solution of adding quotes to the paths helped me get past the issue, but I was still getting some errors. I ended up modifying the command by removing the single quotes. In case anyone needs it, here's the command I ran:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\mysql-connector"
Lastly, just for completeness, I had to use the version of connector c located here. You can read more about why this is necessary at the bottom of https://github.com/brianmario/mysql2/issues/372. It will install fine, but without the special connector_c you might get a segmentation fault when you go to actually use the gem. (Don't forget to grab the libmysql.dll out of that special connector c zip file as well and place it in your ruby bin directory.)

Error installing debug_inspector 0.0.2 Native Extensions?

Getting this error when trying to do a bundle install. Following the instructions to do a direct gem install fails as well. I have since wiped all ruby (and project code) from my machine including any ruby configuration and reinstalled ruby, devkit, and my project code. Still getting this. Not sure where to look next. Most searches turn up gem-specific solutions that don't seem to apply here. Let me know if I can provide more info. Thanks!
An error occurred while installing debug_inspector (0.0.2), and Bundler cannot
continue.
Make sure that `gem install debug_inspector -v '0.0.2'` succeeds before
bundling.
C:\TFS\Grange Commercial SEQ\White\Specifications>gem install debug_inspector -v
'0.0.2'
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
The system cannot find the path specified.
The system cannot find the path specified.
ERROR: Error installing debug_inspector:
ERROR: Failed to build gem native extension.
C:/devl/Ruby/Ruby192/bin/ruby.exe extconf.rb
Gem files will remain installed in C:/devl/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems
/debug_inspector-0.0.2 for inspection.
Results logged to C:/devl/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/debug_inspector-
0.0.2/ext/debug_inspector/gem_make.out
I know this question is very old. However, I see two problems with this right off.
Windows doesn't have the tools (by default, or using the ruby installer) to compile c dependencies for ruby. If you want to do it yourself, you might check out: http://rubylearning.com/blog/how-do-i-install-a-ruby-gem-with-native-extensions-on-windows/
The other problem is that this particular gem doesn't work with ruby < 2.0: https://github.com/banister/debug_inspector and your ruby version appears to be 1.9.1
I would check your Gemfile.lock to see which gems are requiring debug-inspector. If you can do without them, take them out, and your bundle will succeed. If you must have them, try running a linux VM and using it for your development. My personal suggestion would be Ubuntu: http://www.ubuntu.com/download/desktop and VirtualBox or VMWare Player. Virtual Box is FOSS, so if this is company work, you'll have to use it: https://www.virtualbox.org/ . VMWare Player is free for personal use, and I like how it works a little better: http://www.vmware.com/products/player
I got the same error, using Ruby 2.2.4 64bit, on windows 10 64.
In my case what caused the error was installing several ruby versions, one after the other- (to try and solve that error)
Eventually I solved it by running ruby dk.rb install --force (At first I did that without the force flag), as stated by this answer- Just make sure to use the correct ruby version- version that worked for me was ruby 2.1.7 32bit.

Easiest way to get Compass/Sass running on OSX

I first had to follow the instructions here to make sure that I had Ruby and Gems installed. Then I installed compass using Gems.
Then I tried to run compass and had some errors...
"Warning: Unable to load CarbonCore.
FSEvents will be unavailable compass"
I found a solution here, but it required me to install RVM via gems first and then following the instructions in the link above.
Is there an easier way to setup/run compass/sass on OSX?
This problem is described in the compass issue tracker. It's not a showtopper because it falls back to another (less efficient) method of watching for file changes that doesn't depend of fsevents. Still, it would be nice to fix, right?
Since you compiled your own version of ruby, you need to enable shared libraries for it as well. This is described on the rubycocoa getting started page.
More details can be found in this google groups discussion, particularly the advice from Brandon Mathis.
Installing last version of Compass gem (0.11.5) seems to solve the problem:
gem install compass
You have to update your gems:
sudo gem update –system

Resources