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
	gemargs="$@"
	command gem install --user-install ${gemargs:7}
else
	command gem "$@"
fi
}

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

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

PATH=$PATH:/boot/home/.gem/ruby/2.2.0/bin

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

Pretty convoluted, colud be solved moch easier i think.

No, it’s a separate project:

https://rubygems.org/gems/csound

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.