install.rb/setup.rb question 
Author Message
 install.rb/setup.rb question

I want to install a script that will be run as an executable which isn't a
big problem on *nix, just put:
#!<path_to_ruby>
on the first line and make the file executable.

However <path_to_ruby> can vary depending on which flavor of *nix or even
which flavor of Linux you're using and how ruby was installed.

So my question is, does install.rb take care of this?  ie. for each script
in your package's /bin directory does it prepend the #!<path_to_ruby>
prior to installing the script?

Also...  I would guess that unless you're running cygwin under Windows
that install.rb wouldn't be too useful for installing a package on the
Windows platform, correct?

Phil



Sat, 07 May 2005 03:48:50 GMT  
 install.rb/setup.rb question

Quote:

> I want to install a script that will be run as an executable which isn't a
> big problem on *nix, just put:
> #!<path_to_ruby>
> on the first line and make the file executable.

> However <path_to_ruby> can vary depending on which flavor of *nix or even
> which flavor of Linux you're using and how ruby was installed.

> So my question is, does install.rb take care of this?  ie. for each script
> in your package's /bin directory does it prepend the #!<path_to_ruby>
> prior to installing the script?

> Also...  I would guess that unless you're running cygwin under Windows
> that install.rb wouldn't be too useful for installing a package on the
> Windows platform, correct?

What about using

#! /usr/bin/env ruby

--
Jim Freeze
----------
New systems generate new problems.



Sat, 07 May 2005 04:32:14 GMT  
 install.rb/setup.rb question

Quote:
> Also...  I would guess that unless you're running cygwin under Windows
> that install.rb wouldn't be too useful for installing a package on the
> Windows platform, correct?

I copped the essentials from the RDoc install script to create the install
script for Rimport, and it seems to work fine on Windows.

James



Sat, 07 May 2005 04:47:55 GMT  
 install.rb/setup.rb question


Quote:

>> I want to install a script that will be run as an executable which isn't a
>> big problem on *nix, just put:
>> #!<path_to_ruby>
>> on the first line and make the file executable.

>> However <path_to_ruby> can vary depending on which flavor of *nix or even
>> which flavor of Linux you're using and how ruby was installed.

>> So my question is, does install.rb take care of this?  ie. for each script
>> in your package's /bin directory does it prepend the #!<path_to_ruby>
>> prior to installing the script?

>> Also...  I would guess that unless you're running cygwin under Windows
>> that install.rb wouldn't be too useful for installing a package on the
>> Windows platform, correct?

>What about using

>#! /usr/bin/env ruby

Oh, good idea.  It seems to work on Linux.  Does it work on other *nix's
as well?

Phil



Sat, 07 May 2005 04:50:49 GMT  
 install.rb/setup.rb question

Quote:




> >> I want to install a script that will be run as an executable which isn't a
> >> big problem on *nix, just put:
> >> #!<path_to_ruby>
> >> on the first line and make the file executable.

> >> However <path_to_ruby> can vary depending on which flavor of *nix or even
> >> which flavor of Linux you're using and how ruby was installed.

> >> So my question is, does install.rb take care of this?  ie. for each script
> >> in your package's /bin directory does it prepend the #!<path_to_ruby>
> >> prior to installing the script?

> >> Also...  I would guess that unless you're running cygwin under Windows
> >> that install.rb wouldn't be too useful for installing a package on the
> >> Windows platform, correct?

> >What about using

> >#! /usr/bin/env ruby

> Oh, good idea.  It seems to work on Linux.  Does it work on other *nix's
> as well?

Yes.
Overall, it depends on /usr/bin/env existing. From what I can tell, it seems
ubiquitous(sp?).  If your environment is somewhat controlled, it
is a great solution. If your environment is not controlled, it is a good
solution. One plus is, that you can change your path to point
to a different install of Ruby and it will automatically use
the right version. However, if the path in hardcoded in the shebang
operator, then you are stuck with using the ruby that it points
to.
(Using env also lets you control environment variables.)

--
Jim Freeze
----------
Vote for ME -- I'm well-tapered, half-cocked, ill-conceived and
TAX-DEFERRED!



Sat, 07 May 2005 06:01:29 GMT  
 install.rb/setup.rb question
Hi,

At Tue, 19 Nov 2002 07:01:29 +0900,

Quote:

> Overall, it depends on /usr/bin/env existing. From what I can tell, it seems
> ubiquitous(sp?).  If your environment is somewhat controlled, it
> is a great solution. If your environment is not controlled, it is a good
> solution. One plus is, that you can change your path to point
> to a different install of Ruby and it will automatically use
> the right version. However, if the path in hardcoded in the shebang
> operator, then you are stuck with using the ruby that it points
> to.
> (Using env also lets you control environment variables.)

OTOH, it may cause a security issue.

--
Nobu Nakada



Sat, 07 May 2005 06:18:21 GMT  
 install.rb/setup.rb question

Quote:

> Yes.
> Overall, it depends on /usr/bin/env existing. From what I can tell, it seems
> ubiquitous(sp?).  If your environment is somewhat controlled, it
> is a great solution. If your environment is not controlled, it is a good
> solution. One plus is, that you can change your path to point
> to a different install of Ruby and it will automatically use
> the right version. However, if the path in hardcoded in the shebang
> operator, then you are stuck with using the ruby that it points
> to.
> (Using env also lets you control environment variables.)

Just as a data point, it does NOT work on my vanilla Mandrake 9.0
system.


Sat, 07 May 2005 07:52:49 GMT  
 install.rb/setup.rb question
Hi,

At Tue, 19 Nov 2002 05:09:27 +0900,

Quote:

> So my question is, does install.rb take care of this?  ie. for each script
> in your package's /bin directory does it prepend the #!<path_to_ruby>
> prior to installing the script?

You mean setup package by Minero Aoki?  If so, that install.rb
rewrites (not prepend) shebangs in scripts under /bin directory
automatically according to --ruby-path command line option for
config, and it's defaulted to ${bindir}/${ruby_install_name}.

--
Nobu Nakada



Sat, 07 May 2005 09:04:25 GMT  
 install.rb/setup.rb question

Quote:

> Hi,

> At Tue, 19 Nov 2002 07:01:29 +0900,

> > Overall, it depends on /usr/bin/env existing. From what I can tell, it seems
> > ubiquitous(sp?).  If your environment is somewhat controlled, it
> > is a great solution. If your environment is not controlled, it is a good
> > solution. One plus is, that you can change your path to point
> > to a different install of Ruby and it will automatically use
> > the right version. However, if the path in hardcoded in the shebang
> > operator, then you are stuck with using the ruby that it points
> > to.
> > (Using env also lets you control environment variables.)

> OTOH, it may cause a security issue.

Yes. In that case you can use all the options to env and
specify both the path and all the env vars.

--
Jim Freeze
----------
Why is the alphabet in that order?  Is it because of that song?



Sat, 07 May 2005 10:22:16 GMT  
 install.rb/setup.rb question

Quote:


> > Yes.
> > Overall, it depends on /usr/bin/env existing. From what I can tell, it seems
> > ubiquitous(sp?).  If your environment is somewhat controlled, it
> > is a great solution. If your environment is not controlled, it is a good
> > solution. One plus is, that you can change your path to point
> > to a different install of Ruby and it will automatically use
> > the right version. However, if the path in hardcoded in the shebang
> > operator, then you are stuck with using the ruby that it points
> > to.
> > (Using env also lets you control environment variables.)

> Just as a data point, it does NOT work on my vanilla Mandrake 9.0
> system.

I'll refrain from any comments about Mandrake.
Maybe env is at /bin/env.

--
Jim Freeze
----------
After a number of decimal places, nobody gives a damn.



Sat, 07 May 2005 10:24:05 GMT  
 install.rb/setup.rb question

Quote:

>Hi,

>At Tue, 19 Nov 2002 05:09:27 +0900,

>> So my question is, does install.rb take care of this?  ie. for each script
>> in your package's /bin directory does it prepend the #!<path_to_ruby>
>> prior to installing the script?

>You mean setup package by Minero Aoki?  

Yes, that's the one.

Quote:
>If so, that install.rb
>rewrites (not prepend) shebangs in scripts under /bin directory
>automatically according to --ruby-path command line option for
>config, and it's defaulted to ${bindir}/${ruby_install_name}.

I don't see the '#!/usr/bin/ruby' line being added to the scripts in the
/bin directory.

When I run:

ruby install.rb setup

I see the following messages:

"
install.rb: entering setup phase...
---> bin
set #! line to "#!/usr/bin/ruby" for
/home/phil/ruby_stuff/raa_exec/bin/raa_exec ...
rm -f raa_exec.tmp
<--- bin
install.rb: setup done.
"

So it looks like it's going to add the shebang, but when I look at the
installed file it's not there...

...later...

Ok, I went off and did some investigation of the sourcecode and tried some
things out.  Here's the scoop:

1) If you have no shebang at the top of a script in the bin directory
you'll get now shebang+path_to_ruby_bin added.
2) if you have: '#!/usr/bin/env ruby'  for the first line of the script it
will not be changed.
3) if you have: '#!ruby' it'll be expanded to: '#!/usr/bin/ruby'  (or
whatever the actual path to your ruby executable is.)  Actually, it uses
the following regex:  /\A\#!\s*\S*ruby\S*/
so I found that if I had: #!/usr/bin/ruby  and then ran config and setup
with another version of Ruby that I have installed elsewhere it would get
changed to (in this particular case):
#!/home/phil/ruby_1.7.3/bin/ruby

So it seems to do what I would expect.  The reason why it didn't work
initially was that I had: '#!/usr/bin/env ruby' or no shebang at all
and install.rb doesn't change it (special cases).

Phil



Sun, 08 May 2005 04:48:57 GMT  
 install.rb/setup.rb question
I'm sorry for too late replying...

  In mail "Re: install.rb/setup.rb question"

Quote:
> Ok, I went off and did some investigation of the sourcecode and tried some
> things out.  Here's the scoop:

> 1) If you have no shebang at the top of a script in the bin directory
> you'll get now shebang+path_to_ruby_bin added.
> 2) if you have: '#!/usr/bin/env ruby'  for the first line of the script it
> will not be changed.
> 3) if you have: '#!ruby' it'll be expanded to: '#!/usr/bin/ruby'  (or
> whatever the actual path to your ruby executable is.)  Actually, it uses
> the following regex:  /\A\#!\s*\S*ruby\S*/
> so I found that if I had: #!/usr/bin/ruby  and then ran config and setup
> with another version of Ruby that I have installed elsewhere it would get
> changed to (in this particular case):
> #!/home/phil/ruby_1.7.3/bin/ruby

> So it seems to do what I would expect.  The reason why it didn't work
> initially was that I had: '#!/usr/bin/env ruby' or no shebang at all
> and install.rb doesn't change it (special cases).

That's right.
install.rb/setup.rb does not change the shebang line when #! does not
exist, because the installer must not modify non-script (binary) file.

Since /usr/bin/env trick is also useful, install.rb/setup.rb should not
modify it (The author might select it intentionaly).  But if the shebang
line is /usr/local/bin/ruby or /usr/bin/ruby, that's dangerous.  In the
case, the installer should modify it.

-- Minero Aoki



Sun, 08 May 2005 06:10:19 GMT  
 install.rb/setup.rb question

Quote:

> So it seems to do what I would expect.  The reason why it didn't work
> initially was that I had: '#!/usr/bin/env ruby' or no shebang at all
> and install.rb doesn't change it (special cases).

Thanks for the little dissertation on this.
Very informative.
Is this in the FAQ or somewhere?

--
Jim Freeze
----------
There's so much plastic in this culture that vinyl leopard skin is
becoming an endangered synthetic.
                -- Lily Tomlin



Sun, 08 May 2005 07:37:30 GMT  
 install.rb/setup.rb question

Quote:

> > So it seems to do what I would expect.  The reason why it didn't work
> > initially was that I had: '#!/usr/bin/env ruby' or no shebang at all
> > and install.rb doesn't change it (special cases).

> Thanks for the little dissertation on this.
> Very informative.
> Is this in the FAQ or somewhere?

It's just waiting for you to put it in, Jim!  If you have a good grasp of the
question and answer, I suggest you create a new post, entitled "[FAQ]
install.rb" or similar.  I'll ensure the information ends up in the FAQ before
too long, and others can comment/correct it before it gets there.

Quote:
> Jim Freeze

Gavin


Sun, 08 May 2005 07:43:02 GMT  
 install.rb/setup.rb question


Quote:

>> So it seems to do what I would expect.  The reason why it didn't work
>> initially was that I had: '#!/usr/bin/env ruby' or no shebang at all
>> and install.rb doesn't change it (special cases).

>Thanks for the little dissertation on this.
>Very informative.
>Is this in the FAQ or somewhere?

Dunno, but it's a good candidate for the FAQ if it isn't in there.  
Actually the FAQ should
have a whole section on "How do I make a Ruby module installable?" or some
similar question.  We're really lacking unified info in this area, so
everybody does it a little bit differently.  We need to come up with a
'standard' way of doing package installation in order to make it easier
for the various installer packages (raa_install, rpkg, rubynet, etc...)

Phil



Sun, 08 May 2005 08:20:06 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. replace setup.rb/install.rb with builtin module

2. testunit-0.1.5 install failure (may be setup.rb)

3. install.rb: avoiding file name collisions (raa-install too)

4. RB QuickStart Guider from RB

5. launching an RB app from another RB app - appleevents

6. RB Entwickler gesucht / RB Developers wanted

7. RB: row order by RB database

8. protocol.rb http.rb 1.1.24

9. Bugs corrected in DBD/ODBC/ODBC.rb and DBD/Proxy/Proxy.rb

10. install.rb

11. install.rb and extensions in /ext

12. Newbie RB question

 

 
Powered by phpBB® Forum Software