Can't require 'osx/cocoa' after RubyCocoa installation - ruby

I've tried moving files around and performing various un/installations and still cannot seem to get RubyCocoa to load when I do require 'osx/cocoa'. I even found the native apple version of RubyCocoa and those files won't load either. I've hit a dead end trying to determine how I can get it to work and was really hoping someone could help. I'm interested in testing its functionality and possibly writing some applescripts, using Ruby, but until I overcome this issue I'm completely stuck. Thanks!
Extra points if you can figure out how I can install RubyCocoa with RVM.

In Mac OS X Maverics, OS-embedded Ruby 1.8 (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby) is required to use require osx/cocoa. Specify the path instead of using other versions of Ruby that are installed with rbenv or rvm.
Please note that this solution is temporal because the version of Ruby 1.8 has been removed in Yosemite and require osx/cocoa is unavailable.

I'm late to the game but this gist will help https://gist.github.com/nsforge/6861400.

Related

Why does requiring 'watir-webdriver' in my macruby application in xcode cause this error?

I have installed watir-webdriver via macgem in root and in user, I have required rubygems and included /Library/Frameworks recursively in my framework search path in build settings for this project.
require 'rubygems' runs without a problem
require 'watir-webdriver' returns the error :
Assertion failed: (method_getImplementation(m) == imp), function add_method, file vm.cpp, line 1019.
(lldb)
Im really new to using ruby in xcode can someone explain this?
Thanks
I think I recall hearing something about the version of ruby that ships with the mac OS being um well a kind word would be ancient (1.8 started in 2003.. 1.8.7 in 2008, and while it has been patched more recently than that, it's still kinda old.)
Not sure what Apple's reason for not going to a 1.9 version was, but for some reason they seem to like the older stuff.
Most folks I know working on Watir use some flavor of Ruby 1.9 typically 1.9.3 or 1.9.3. Increasingly people are shifting to 2.0, which came out in Feb.
The first thing I would try is getting a more current version or Ruby and see if that eliminates that error. Instructions are found here I'm pretty sure I used RVM when I installed on my 'work' system (a macbook pro). RVM can be pretty handy (such as if you want to experiment with 2.0) so I'd usually recommend using it for folks on a Mac

Can I switch versions of Ruby dynamically using RVM?

I'm working on building a GUI for my checkers implementation. I'm utilizing a GUI framework that only works with Ruby 1.8, yet my game engine, which I have packaged as a gem, only works with Ruby 1.9.
I can't change the code for the GUI framework and reworking my game engine to make it compatible with 1.8 is undesirable, to say the least.
I'm using RVM though, and it looks like you can write RVM scripts to change Ruby versions on the fly.
Does anyone have any experience with that or what the script might look like?
You could run it in two processes. Give the GUI a 1.8 process and talk to it via a shared db or an API on the other side. That's how I'd do it. The good part about that is you can have on online version of your game as well because other clients will be able to talk to it as well.
You can't run one app with two versions of Ruby. How do you imagine this?
RVM has an ability to automatically change current ruby when you cd into a directory. Just create in that directory a file called .rvmrc with content like
rvm use 1.8.7

Linux-Live-system inc. Ruby 1.9 on USB-Stick with r/w-Partition

well guess that many of you have great expertise on Linux. I currently have some issues with creating a linux-live-medium.
i have a box with OpenSuse-Linux Version 11.3 with all nice things. Several languages run very well: Perl, Python, PHP! All is very well! BTW - i am very glad that Perl runs very nice.
But I am not able to install Ruby 1.9. Everytime i want to do that i end up with Ruby 1.8.7. I want to testrun some ruby-code. Therefore i need Ruby with the following gems
mechanize
nokogiri
utf8_utils
I heard of a Linux-Live-medium that is able to run with all the wanted things including Ruby 1.9.
Therefore the Live-medium is installed on a USB-Stick with R/W partitions. Is this possible.
I am not a linux-expert - but with all the expertise here i think it is possible to create such a USB-Stick. (...with Ruby 1.9 and all with all that extensions)
I love to hear from you!
best regards
zero
Debian/Ubuntu includes both Ruby 1.8.x and 1.9.x - and essentially duplicates most packages in 2 flavors: for 1.8 and 1.9. That might be enough for your purposes - although YMMV, of course.
Yet another solution is RVM that karudzo already mentioned.
Yet another solution is virtualization: simplest form of it would be just chrooting. Most modern Linux systems have an ability to install itself based from some root directory (SuSE has install into given directory functionality, Debian/Ubuntu have debootstrap - and then just running chroot /path/to/that/directory - you'd end up in essentially another system installed cleanly in separate directory.
This will actually be a better solution for you- use RVM:
https://rvm.io/
Then you can easily switch back and forth from 1.8 to 1.9 as desired and make 1.9.2 your default. Just read their docs carefully, it really makes gem management a lot easier.

mingw32 Ruby Installer for Windows

How good is the new Ruby Installer for Windows?
I asked before about why Ruby was so slow on windows and now I've seen some impressive benchmarks showing marked speed improvements with the minGW compilation used in the new installers and am curious how it has worked for people who have tried it?
How many gems are broken for this version? Any big ones you have been bit by not on this list?
I've played with it a fair bit. It's definitely faster, both because of the new YARV VM in 1.9.1, and the use of a C compiler created sometime this century.
Pure Ruby gems are pretty reliable, obviously. Getting mswin32 binaries to work is a hit/miss situation (mostly miss IMHO), and native mingw32 binaries are still the exception, not the rule.
I wanted FXRuby on Windows, and went through the following to get it: Getting FXRuby Going with Ruby 1.9.1 and the new RubyInstaller
So it depends what gems you care about and how handy you are with build scripts and such. Despite the heroic efforts of Louis Lavena and the Ruby Installer contributors, Ruby on Windows remains a second-class citizen.
As you've already noticed, the RubyInstaller guys maintain a list of gems known to work, or not, but this is pretty fluid. The mailing list is usually pretty responsive to questions as well.
It's quite a bit faster, the exact experience varying according to your application. For low-volume Rails stuff, for example, I think you would probably not notice much: database access doesn't really change, for example.
Easiest thing is to try it. If you save your ruby\bin and ruby\lib directories first, you can install over your existing Ruby and be able to switch between the two. I think only those two directories are affected - it seems to work for me at least.
Once you have an installed mingw32 instance, start with the gem installs. The ones that have compiled components will hopefully already have mingw32 versions. Failing that, you could try modifying with the mswin32 versions from your "old" lib - I haven't done this myself and have only the vaguest memory of reading something that suggested it may work...
At the bare minimum, the mingw32 binaries run fine. If you start installing some esoteric gems, you might get some install failures. I highly recommend using Ruby on Linux or Mac, everything works better on those platforms. You will actually be spending time writing Ruby code instead of yak shaving your way to get gems to configure and build properly. I am writing this based on installing Ruby 1.9.1 mingw bins. The 1.8 version might be more stable. The msvc Ruby 1.9.1 binaries have their own separate set of issues, mostly run time ones.

On Ubuntu does Shoes require Ruby1.8 or Ruby1.9?

I have only installed Ruby1.9 on my machine. Have some kind of problems with the programs I am trying to write using Shoes. Am wondering if this is a version issue.
I am trying to do some stuff over ssl.
Shoes comes with its own Ruby version embedded in the script you download. It is completely self-contained as far as I can tell.
I'm don't know what is "Shoes" but i found this:
https://launchpad.net/ubuntu/+source/shoes
according to that "shoes (0.r396-5)" Depend on "rubygems1.8"

Resources