Quoting (e-mail address removed), on Fri, Mar 04, 2005 at 06:19:28AM +0900:
Brian Schröder said:
This is incorrect.
It *is* correct.
You do need to assure that the rubygems package manager is loaded in order
to take advantage of any gems on your system. There are basically three
options:
(1) Do a "require 'rubygems'" in your code.
Change your ruby code.
(2) Launch the script with an explicit -rubygems on the command line
(e.g. ruby -rubygems your_script_name.rb)
Change your shell/command line code. If its an executable ruby script,
it means changing the #! line, which is also code. If it is run by
double-clicking in windows, it won't work, AFAIC (but I don't use
Windows).
(3) Set the RUBYOPT environment variable to be "rubygems".
Environment setup is code as well, shell code, and very hard to do in
the face of multiple shells, ssh, X (where you don't generally have
control over the environment at all), etc.
Rubygems is fundamentally broken in this respect, to put my opinion very
bluntly.
If it was a way of distributing and downloading packages, I would be a
huge fan. For some reason, they added this "feature" that forces changes
in the language, a feature that python, perl, tcl all do without in
their package management, as far as I know.
I really wish the gems folks had stuck to the packaging creation,
distribution, and installation problem, and not jammed a half-baked
solution to the versioning problem in with it.
If you wish to lock down particular version of a library, then you are
free to use the require_gem command and supply an explicit version
constraint. I know that some folks using rails have done this to support
multiple versions of rails on a single server. This is handy because
different web apps were written against different versions of rails over
time.
Could you describe how this can possibly work? I must be missing
something very deep about ruby, because you can only have one version of
a class at a time!
Or are you saying they have independent top-level apps, running
different ruby interpreters, and each choses a particular version of
rails?
But, they could do that without gems!
They would install each rails version into a particular location, and
put that location in their require path...
Now you may say to me that is a pain for them to have to do... but I
would say that what's involved in them doing that is that they would
have to do something very similar to one of your 3 things above:
1 require '../some/specific/rails.rb'
2 run their script with a -r .../some/specific/path/rails
3 set a -I in RUBYOPT that points to the rails version they want to
use...
But, instead they get the fancy tool support, and I get the pain of
doing one of the three...
Does this not seem unreasonable? Gems appears to optimize for the
special/unusual case here, at the expense of the general, doesn't it?
I see versioning problems as two kinds:
- easy: rubygems is overkill, causing more problems than it solves. If
you just need to use a particular set of packages, install and use
them.
- hard: rubygems doesn't solve the problems, and many problems have no
solution.
If rdoc needs a particular version of HtmlGen, and I make an rdoc plugin
which requires a different version of HtmlGen, well, it won't work, and
no gem magic is going to help me.
Or say I have:
A - v 3, 4, 5 installed
B - a script I downloaded and run
B requires X, which needs A with version >=3
-> I'll get version 5, right/
B requires Y, which needs A with version <= 4
-> It will die, right?
So, now I trouble shoot... and uninstall A version 5. How did rubygems
help me? I could have done this without ruby gems!
This is the most elementary of problems, and it is actually a problem
that HAS a solution, in that there really exists a version of A that
satisfies X and Y. Even a slightly more complex situation just results
in a set of version statements that have no solution.
Having the .gem file warn about missing dependencies, or dependency
requirements at INSTALL time is great, any good install tool should do
this, and that would be fine, but at runtime?
So, seriously, can anybody give me examples of where the versioning was
used, what problem was solved, and how it solved it? Is there any
positive experience with this?
I hate to be negative about something that people are working so hard
on, but forcing one of the 3 "solutions" above on users of my libraries
just so that they can download and install a project of mine with a
single command line is a Bad Idea. Especially when all they had to do
before is download my package, untar, and ruby install.rb. Thats not
that hard...
As a bonus, they don't get any problems they have to solve, they don't
get multiple versions of my packages they have to uninstall, and I don't
have to build a gem...
Cheers,
Sam