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?
On Tuesday, 19 November 2002 at 5:09:27 +0900, Phil Tomson wrote:
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?
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.
At Tue, 19 Nov 2002 05:09:27 +0900, Phil Tomson wrote:
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}.
On Tuesday, 19 November 2002 at 5:09:27 +0900, Phil Tomson wrote:
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?
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.
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:
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.
if you have: ‘#!/usr/bin/env ruby’ for the first line of the script it
will not be changed.
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*\Sruby\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).
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.)
···
On Tuesday, 19 November 2002 at 6:29:36 +0900, Phil Tomson wrote:
On Tuesday, 19 November 2002 at 5:09:27 +0900, Phil Tomson wrote:
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?
–
Jim Freeze
Vote for ME – I’m well-tapered, half-cocked, ill-conceived and
TAX-DEFERRED!
Ok, I went off and did some investigation of the sourcecode and tried some
things out. Here’s the scoop:
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.
if you have: ‘#!/usr/bin/env ruby’ for the first line of the script it
will not be changed.
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*\Sruby\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.
Thanks for the little dissertation on this.
Very informative.
Is this in the FAQ or somewhere?
···
On Wednesday, 20 November 2002 at 6:10:52 +0900, Phil Tomson wrote:
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).
–
Jim Freeze
There’s so much plastic in this culture that vinyl leopard skin is
becoming an endangered synthetic.
– Lily Tomlin
At Tue, 19 Nov 2002 07:01:29 +0900, Jim Freeze wrote:
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.
···
On Tue, 19 Nov 2002 07:01:29 +0900, Jim Freeze wrote:
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.)
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.
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…)
At Tue, 19 Nov 2002 07:01:29 +0900, > Jim Freeze wrote:
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.
–
Jim Freeze
Why is the alphabet in that order? Is it because of that song?
I’ll refrain from any comments about Mandrake.
Maybe env is at /bin/env.
···
On Tuesday, 19 November 2002 at 9:07:55 +0900, Tim Hunter wrote:
On Tue, 19 Nov 2002 07:01:29 +0900, Jim Freeze wrote:
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.
–
Jim Freeze
After a number of decimal places, nobody gives a damn.
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
I dare say this information is worthy of a cohesive document, rather than a
mere FAQ entry. If anyone knows how to package Ruby modules for installation,
a coherent document on the Wiki would be a great contribution. I’d do it
myself if I had any idea.
I agreed so much with both of the below that I started up a page on Wiki
covering packaging and submission to RAA. I’m still working on the
extconf.rb and RAA submission sections. Please add, edit or condense
portions of the page to increase its usefulness and accuracy:
I’m not sure exactly where these fit in the overall scheme of the
RubyGarden Wiki. If you look at the home page, I can see them fitting
under CodingInRuby, RubyNuby, DocumentingRuby… I dunno. I ended up
putting the RAA-Install guide under RubyArchive, which is under
RubyOnTheNet…?
Actually the FAQ should have a whole section on “How do I make a
Ruby module installable?” … 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
I dare say this information is worthy of a cohesive document, rather than a
mere FAQ entry. If anyone knows how to package Ruby modules for installation,
a coherent document on the Wiki would be a great contribution. I’d do it
myself if I had any idea.