# Setup.rb problems and possible fix

**URL:** <https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686>\
**Category:** Ruby\
**Created:** [April 2, 2006, 10:36pm UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686 "2006-04-02T22:36:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 2, 2006, 10:36pm UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/1 "2006-04-02T22:36:13Z")

</div>

As I reported earlier there seems to be some issues with setup.rb.  
After investingating deeper it appears that there may be some very odd  
bugs lurking within. There’s is a lot of good code in their, but I’m  
starting to think it may need a fresh rewrite. Of course, it doesn’t  
help that Minero whas not responded to my emails, and appearnetly does  
not frequent this list.

The issue I’m currently facing is that setup.rb does not seem to be  
handling --prefix correctly. While most things get the prefix, the lib/  
directory does not. Looking at the code one sees these relavent pieces.

def install\_dir\_lib(rel)  
install\_files libfiles(), “#{config(‘rbdir’)}/#{rel}”, 0644  
end

def install\_files(list, dest, mode)  
mkdir\_p dest, @config.install\_prefix  
list.each do |fname|  
install fname, dest, mode, @config.install\_prefix  
end  
end

def mkdir\_p(dirname, prefix = nil)  
dirname = prefix + File.expand\_path(dirname) if prefix  
$stderr.puts “mkdir -p #{dirname}” if verbose?  
return if no\_harm?

```
# Does not check '/', it's too abnormal.
dirs = File.expand_path(dirname).split(%r<(?=/)>)
if /\A[a-z]:\z/i =~ dirs[0]
  disk = dirs.shift
  dirs[0] = disk + dirs[0]
end
dirs.each_index do |idx|
  path = dirs[0..idx].join('')
  Dir.mkdir path unless File.dir?(path)
end

```

end

Looking at this code one would expect that @config.install\_prefix would  
hold the value of the --prefix command line option. But oddly it does  
not --I’m almost inclined to think that this is unintended in itself.  
But assuming that’s not how it’s supposed to be, then obviously  
config(‘rbdir’) must contain the prefix. But it doesn’t. The other  
similiar config dirs do, config(‘bindir’), config(‘datadir’), etc. But  
not ‘rbdir’, which leads me to think that it should actually be  
‘libdir’.

T.

P.S. Although I’ve now subscribed to the RubyGems mailing list and  
posted my simple solution to the datadir problem, no one has responded  
whatsoever.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 3, 2006, 3:39am UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/2 "2006-04-03T03:39:30Z")

</div>

Sigh, ‘libdir’ isn’t right either.

Is setup.rb just not being supported any longer?

T.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 4, 2006, 4:21pm UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/3 "2006-04-04T16:21:57Z")

</div>

On 2006-04-02 13:29:04 -0700, “Trans” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) said:

> As I reported earlier there seems to be some issues with setup.rb.  
> After investingating deeper it appears that there may be some very odd  
> bugs lurking within. There’s is a lot of good code in their, but I’m  
> starting to think it may need a fresh rewrite. Of course, it doesn’t  
> help that Minero whas not responded to my emails, and appearnetly does  
> not frequent this list.

I have had similar troubles. Testing was added in a recent version (a  
few months ago, IIRC) and was broken. I sent him a patch and recieved  
no response.

If anyone knows a sure-fire way to get ahold of him so I know he at  
least had the opportunity to consider my patch (which I’m using in my  
own projects without trouble), I’d love to know, please privately  
contact me.

It sounds like this will end up becoming a (for lack of a better term)  
“qmail patching nightmare” unless we get some consensus on what tool to  
use or how to provide patches for it. On another note, having tools  
like this in the standard distribution (like MakeMaker is for perl)  
would really eliminate a lot of the problems.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 4, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/4 "2006-04-04T22:03:34Z")

</div>

On Tuesday 04 April 2006 1:43 pm, Trans wrote:

> Well, I’m not sure what I’m going to do about it yet. I may re-write  
> it. The code looks more like C than Ruby and I find it difficult to  
> work on (I still haven’t figured out where the prefix is worked-in  
> exactly). Have any interested in such a project?

Wait. Before you rewrite it, take a look at the work that was done on  
package.rb by Mauricio F. and Chris Neukirchen. They haven’t  
worked  
on it since late last year, but even as is, it is a very capable system.  
I  
only have one released package, at the moment, that uses it, but I have  
several more in various states of progress towards new releases, and  
they all  
use it. It works well, is flexible, and is terribly simple to use. And  
it  
can be used in a way that is compatible with existing setup.rb uses.

The URL that I have for it is:

[http://chneukirchen.org/repos/package](http://chneukirchen.org/repos/package)

Kirk H.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 4, 2006, 9:44pm UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/5 "2006-04-04T21:44:48Z")

</div>

> On another note, having tools like this in the standard distribution  
> (like MakeMaker is for perl) would really eliminate a lot of the problems.

I agree. In fact, it never occured to me before, but why isn’t setup.rb  
a part of the Ruby distibution?

Well, I’m not sure what I’m going to do about it yet. I may re-write  
it. The code looks more like C than Ruby and I find it difficult to  
work on (I still haven’t figured out where the prefix is worked-in  
exactly). Have any interested in such a project?

T.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 5, 2006, 5:26am UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/6 "2006-04-05T05:26:04Z")

</div>

Very interesting. Thanks for making me aware of this. I’m curious about  
a couple of things though. I wonder about this script involved. Eg.

Package.setup(“1.0”) {  
…  
}

Is that neccessary for every project? If so, is there a minimal  
default? I found the available docs/examples of this a bit confusing.  
Do the commands confom to a standard repo structure? For example:

# all .rb files under foo/ are installed under foo/ in the specified

libdir  
lib _Dir["foo/\*\*/_.rb"]

Does that mean my repo dir /lib/foo will map to distro /lib/foo? Or  
does it mean repo /foo maps to distro /lib/foo?

T.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 5, 2006, 6:03am UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/7 "2006-04-05T06:03:06Z")

</div>

Coming from the Windows world, this thread really interests me.  
Installing software on Windows has traditionally been a challenge; in  
recent years Microsoft started including an installation engine (Windows  
Installer) in the OS. Then .NET promised “xcopy deployment” but that  
wasn’t quite true either (except in the simplest of cases).

1. I’ve seen usage of setup.rb and just assumed it came with my  
one-click-installer distribution. Until I read this thread I didn’t  
think twice about it, but what exactly is/was the mission of setup.rb?

2. If we’re just talking about copying files, etc. I wonder if using  
Rake would be better than an entirely new system. Would it be possible  
to just use Rake tasks as a way to install files?

3. What happens in a Ruby setup other than copying files into the right  
folders?

4. Is there a desire/need for OS-specific setup options? For example,  
on Windows, “good” installers place an entry in the Control Panel’s  
Add/Remove list, and also probably install some shortcut icons in the  
start menu, etc. And maybe there are similar needs on \*nix and Mac?

Please pardon any stupid-sounding newbie questions here… any light  
that could be shed would be much appreciated 🙂

Thanks  
Jeff

> **[Hey Daddio!](http://www.softiesonrails.com)**
>
> Home of Hey Daddio Software

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 5, 2006, 4:43pm UTC](https://www.ruby-forum.com/t/setup-rb-problems-and-possible-fix/56686/8 "2006-04-05T16:43:49Z")

</div>

On Tuesday 04 April 2006 9:23 pm, Trans wrote:

> Very interesting. Thanks for making me aware of this. I’m curious about  
> a couple of things though. I wonder about this script involved. Eg.
> 
> Package.setup(“1.0”) {  
> …  
> }
> 
> Is that neccessary for every project? If so, is there a minimal  
> default? I found the available docs/examples of this a bit confusing.  
> Do the commands confom to a standard repo structure? For example:

The Package.setup() call is what handles the actual installation tasks.  
The ‘1.0’ that is passed in tells it which packaging specification to  
use (and  
right now, 1.0 is the only one that is defined).

The aoki() method looks like it was intended to work with a standard  
setup.rb  
directory structure:

Package.setup(‘1.0’) {  
aoki  
}

Yes, the docs are very, very minimalistic. A little work here and  
there,  
though, and package.rb could be very, very nice.

Here’s the current setup script for the upcoming IOWA release:

* * *

basedir = File.dirname( **FILE** )  
$:.push(basedir)

require ‘external/package’

Dir.chdir(basedir)  
Package.setup(“1.0”) {  
name “IOWA”

lib [“iowa.rb”,“iowa\_webrick.rb”,“iowa\_mongrel.rb”]  
lib _Dir["iowa/\*\*/_.rb"]  
lib “mod\_iowa.rb” =\> “apache/mod\_iowa.rb”

begin  
require ‘tmail’  
rescue LoadError  
# No tmail; install ours.  
translate(:lib, ‘external/tmail/’ =\> ‘’)  
lib _Dir["external/tmail/\*\*/_.rb"]  
lib ‘external/tmail/tmail/parser.y’  
end

bin “iowa\_fcgi\_handler.rb”

## unit\_test Dir[“test/TC\*.rb”] }

One thing I like about package.rb is that while it will work to install  
packages laid out according to the setup.rb convention, it is simple and  
flexible enough to work with other data structures. This allows me to  
structure my source in a way that makes sense for me and for the  
project, and  
still easily create an installation script that does what I want.

> # all .rb files under foo/ are installed under foo/ in the specified
> 
> libdir  
> lib _Dir["foo/\*\*/_.rb"]
> 
> Does that mean my repo dir /lib/foo will map to distro /lib/foo? Or  
> does it mean repo /foo maps to distro /lib/foo?

That means that in your package, there is a foo/ directory. Everything  
in it  
that ends in .rb will be installed into the Ruby sitelib/foo/

Thanks,

Kirk H.
