rubygems implementation question

  • Thread starter Charles Comstock
  • Start date
C

Charles Comstock

I was curious why the code in installer.rb in ruby gems was setup like this?

I thought mkdir_p checks to make sure of the existance of a dir before
creating it, and quietly fails if it already exists, making the
additional check seem odd. Is there a particular reason for this?

unless File.exist? File.join(install_dir, "specifications")
FileUtils.mkdir_p File.join(install_dir, "specifications")
end
unless File.exist? File.join(install_dir, "cache")
FileUtils.mkdir_p File.join(install_dir, "cache")
end

Also, I wasn't quite sure on this, is require_gem supposed to
automatically get a package if it's not local the first time it runs or no?

Charles Comstock
 
C

Chad Fowler

I was curious why the code in installer.rb in ruby gems was setup like
this?

I thought mkdir_p checks to make sure of the existance of a dir before
creating it, and quietly fails if it already exists, making the
additional check seem odd. Is there a particular reason for this?

unless File.exist? File.join(install_dir, "specifications")
FileUtils.mkdir_p File.join(install_dir, "specifications")
end
unless File.exist? File.join(install_dir, "cache")
FileUtils.mkdir_p File.join(install_dir, "cache")
end
You're right, but if we replaced this with:

FileUtils.mkdir_p File.join(install_dir, "specifications")
FileUtils.mkdir_p File.join(install_dir, "cache")

...it would run between 300 and 400 times slower (literally). That's
not a big deal for a single require_gem, but in a system that loads a
*lot* of gems, it might be a problem.
Also, I wasn't quite sure on this, is require_gem supposed to
automatically get a package if it's not local the first time it runs
or no?

Not in it current incarnation, no.

Thanks,
Chad
 
C

Charles Comstock

Chad said:
You're right, but if we replaced this with:

FileUtils.mkdir_p File.join(install_dir, "specifications")
FileUtils.mkdir_p File.join(install_dir, "cache")

..it would run between 300 and 400 times slower (literally). That's not
a big deal for a single require_gem, but in a system that loads a *lot*
of gems, it might be a problem.

Oh because it executes another program as opposed to making a system
call or something like that? Sorry wasn't trying to be picky I wasn't
familiar with FileUtils and was thinking about using it my own projects.
I hadn't thought of that performance issue with making a system call.

Hmm maybe that should be in the standard library info about FileUtils.

Thank you for the info,
Charles Comstock
 
C

Chad Fowler

Oh because it executes another program as opposed to making a system
call or something like that? Sorry wasn't trying to be picky I wasn't
familiar with FileUtils and was thinking about using it my own
projects. I hadn't thought of that performance issue with making a
system call.

Pickiness is exactly what's needed right now. Thanks.Chad
 
D

Dick Davies

* Charles Comstock said:
Also, I wasn't quite sure on this, is require_gem supposed to
automatically get a package if it's not local the first time it runs or no?

Personally I'd like this, but it raises the complexity a bit
(permissions are my first concern) - would be fairly easy to
implement, though.
 
G

Gavin Sinclair

* Charles Comstock <[email protected]> [0524 05:24]:
Also, I wasn't quite sure on this, is require_gem supposed to
automatically get a package if it's not local the first time it runs or no?
Personally I'd like this, but it raises the complexity a bit
(permissions are my first concern) - would be fairly easy to
implement, though.

Assuming you're talking about automatic downloading and installation
of uninstalled gems as needed by running programs, I dislike it. I
want to be in control of what's going onto the machine.

Furthermore, I see no need for it, in theory or in practice. In
theory, because you download dependencies as you go about installing
things. In practice, because it's so damn easy to install gems as it
is that I see no need for "improvement".

Cheers,
Gavin
 
J

Jim Freeze

You're right, but if we replaced this with:

FileUtils.mkdir_p File.join(install_dir, "specifications")
FileUtils.mkdir_p File.join(install_dir, "cache")

...it would run between 300 and 400 times slower (literally). That's
not a big deal for a single require_gem, but in a system that loads a
*lot* of gems, it might be a problem.

So, what about submitting a patch to FileUtils to do this for us
and speed itself up?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top