Ruby Gems/FFI

Has anyone used gems to install an app in Ruby?
I’m trying to add a facility that uses FFI (an interface to Csound, actually), and I’m not getting very far yet. If anyone else has trodden a similar path it could save me a lot of pain!

The first barrier was that gems wanted to put the downloads in the system read-only ruby directory. Seems that it is not adapted for Haiku packages. Fixed with the ‘-i’ option.

Then of course I had to install ruby-devel, but even after that it gets loads of errors the moment it tries to compile the FFI stuff. I suspect more options may fix this too, but ther’s a lot to wade through.

If anyone has a map, it would help!

Someone here in the Haiku community knows a way around that issue by adding a hack to your bashrc file. I have that hack myself and can post it here when I get the chance. I have not had any success in getting the rails gem installed due to failure in compiling extensions, etc.

Which gem is that?

Yes please, if you can dig it out…

It’s actually a bridge to Csound, which I run a lot in Haiku.

I use Ruby frequently, too, but usually for my own scripts, so I’m not at all familiar with gem.

It is in the csound tarball?

Here is what’s in my BASH profile…

gem() {
if [[ $1 == "install" ]]; then
	command gem install --user-install ${gemargs:7}
	command gem "$@"

if hash ruby 2>/dev/null; then
	PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"

# rbenv
# export PATH="$HOME/.rbenv/bin:$PATH"
# eval "$(rbenv init -)"


export PATH="/boot/home/.bin:$PATH"

Pretty convoluted, colud be solved moch easier i think.

No, it’s a separate project:

I haven’t tried it yet, but I have to confess I don’t understand what it does. It seems to refer to a ‘…/home/.bin’ directory that I certainly don’t have!

Second tought: this shouldn’t be required at all, i will try to patch ruby instead on this weekend.

I got that solution from someone else in the Haiku community though I can’t remember who it was.

It uses userinstall instead of install so installing gems doesnt fails because the read only system folder. This happens on every other OS too without admin rights.
Then it adds the bin folder to the path 2 different ways.
The one made this hack should have patched ruby instead of this, and in the meantimecould have used any other folder instead of littering dotfolders in the $HOME.

~> gem install --user-install csound
Fetching ffi-1.12.1.gem
Fetching csound-0.0.4.gem
Building native extensions. This could take a while...
Successfully installed ffi-1.12.1
Successfully installed csound-0.0.4
Parsing documentation for ffi-1.12.1
Installing ri documentation for ffi-1.12.1
Parsing documentation for csound-0.0.4
Installing ri documentation for csound-0.0.4
Done installing documentation for ffi, csound after 16 seconds
2 gems installed

This is Haiku hrev53759 x86_64 Haiku

Btw, next time it would help a lot if you could state the name of the program and your os version string. I mean it took 9 comments to find out what do you trying to accomplish.
We still don’t know what the “loads of errors in ffi” was, because you did not posted them, so i assume you are using 32 bit Haiku, and ruby mistakenly tries to use the wrong compiler toolchain.

1 Like