librelist archives

« back to archive

Install location override for ruby-odbc

Install location override for ruby-odbc

From:
Joel Chippindale
Date:
2009-12-15 @ 07:24
I've been trying to write a formula for RubyOdbc

I started with this

require 'formula'

class RubyOdbc < Formula
  url 'http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz'
  homepage 'http://www.ch-werner.de/rubyodbc/'
  md5 '36d21519795c3edc8bc63b1ec6682b99'

  depends_on 'unixodbc'
  depends_on 'freetds'

  def install
    system "ruby extconf.rb --enable-dlopen
--with-odbc-dir=#{HOMEBREW_PREFIX}/lib"
    system 'make'
    system 'make install'
  end
end

This runs successfully. However it installs ruby-odbc within the
folders of the current ruby installation. Given that this ruby may or
may not have been installed with homebrew this breaks the convention
of ensuring that homebrew only makes changes within the hombrew
install directories. It also means that the uninstall fails.

extconf.rb doesn't have a prefix option but it is possible to add a
step to modify the make file as part of the install by adding the
following line before the make call

inreplace 'Makefile', /^prefix = .*$/, "prefix = #{prefix}"

However once installed in this way ruby is unable to find the
ruby_odbc.so bundle that the make file installs.

Could anyone suggest a good way to resolve this?

J.

Re: [homebrew] Install location override for ruby-odbc

From:
Max Howell
Date:
2009-12-15 @ 11:54
> This runs successfully. However it installs ruby-odbc within the
> folders of the current ruby installation

Yeah sucks eh? The problem is we don't currently know any solution except:

Symlink the tmbundle into /Library/Ruby/1.8/Site something or other.

The reason for this is the bundle is a plugin and Ruby has to be able
to find its plugins at runtime. The usual way for such things is a
hardcoded path.

If you look deeper you may find there is an environment variable you
can also set to add paths that ruby searches.

So the final solution would be, don't run make install, install the
tmbundle manually into the keg (eg. prefix.install
'rubyodbc.tmbundle'), and then list what the user must do next in the
Formula.caveats reimplementation.

There are several instances on OS X where it would be nice to have a
facility where Homebrew can manage files outside its prefix. We should
write them down somewhere and see what we can come up with.

Max
-- 
Freelance mobile, desktop and web developer
http://www.methylblue.com/

Re: [homebrew] Install location override for ruby-odbc

From:
Joel Chippindale
Date:
2009-12-16 @ 08:57
Cheers for the suggestions.

I opted for customizing the install to put ruby-odbc in homebrew and
adding a caveat explaining how to update your environment to tell ruby
where to look for the library (see

http://github.com/mocoso/homebrew/commit/02c801c7dd29275b5096ef5ae4a4abcf99fff8c0).

J.

2009/12/15 Max Howell <max@methylblue.com>:
>> This runs successfully. However it installs ruby-odbc within the
>> folders of the current ruby installation
>
> Yeah sucks eh? The problem is we don't currently know any solution except:
>
> Symlink the tmbundle into /Library/Ruby/1.8/Site something or other.
>
> The reason for this is the bundle is a plugin and Ruby has to be able
> to find its plugins at runtime. The usual way for such things is a
> hardcoded path.
>
> If you look deeper you may find there is an environment variable you
> can also set to add paths that ruby searches.
>
> So the final solution would be, don't run make install, install the
> tmbundle manually into the keg (eg. prefix.install
> 'rubyodbc.tmbundle'), and then list what the user must do next in the
> Formula.caveats reimplementation.
>
> There are several instances on OS X where it would be nice to have a
> facility where Homebrew can manage files outside its prefix. We should
> write them down somewhere and see what we can come up with.
>
> Max
> --
> Freelance mobile, desktop and web developer
> http://www.methylblue.com/
>