TempFile path consistency vs the rest of the Ruby implementations #677

robertodecurnex opened this Issue Apr 29, 2013 · 5 comments


None yet

2 participants


TempFile is using a different algorithm to generate the temp path.

Here are some examples (MRI vs JRuby):

Ruby 1.8.7

==============> /tmp/temp-index20130429-21223-1qdcggn-0
==============> /tmp/temp-index20130429-21223-1ct0r8o-0

Ruby 1.9.3

==============> /tmp/temp-index20130429-27066-1jtprvn
==============> /tmp/temp-index20130429-27066-rnt1f

JRuby 1.7.3

==============> /tmp/git_test1367248843047/test/temp-index.25063.5336
==============> /tmp/git_test1367248843047/test/temp-index.25063.5337

This may create weird compatibility issues.

Exampĺe: schacon/ruby-git#72

headius commented Apr 29, 2013

Do you have some example code to run? It appears that we used to implement the tempfile naming differently, but it now uses the same logic as in MRI.

headius commented Apr 29, 2013

Ahh sorry...we do have a slightly different algorithm contained in org.jruby.ext.tempfile.Tempfile#make_tmpname.

headius commented Apr 29, 2013

Hmm, after reading over the code, I can see no obvious advantage in what we have over the original tempfile.rb anymore. I'll confer with @enebo on whether we should just put it back.

headius commented Apr 29, 2013

I think what we'll do is pull out the filename-generating logic into a utility within JRuby and use that for now. For JRuby 9k (next major release) we'll just use MRI's tempfile.rb.

@headius headius added a commit that closed this issue Apr 29, 2013
@headius headius Use MRI logic for generating tempfile names in Tempfile.
This change does the following:

* Adds missing Ruby logic by defining Tempfile.create and
  including Dir::Tmpname into Tempfile. These changes happen in
  the new lib/ruby/shared/tempfile.rb.
* Invokes #create included from Tmpname to generate the filename,
  rather than using our own filename logic. This allows overriding
  both #create and #make_tempname. It also abstracts all name
  logic to Ruby's tmpdir.rb.
* Eliminate unused Reaper logic.
* Eliminate unused temp dir finding logic.
* Fixes #677
@headius headius closed this in 607c6d5 Apr 29, 2013

Great! Ty, that was fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment