Ticket #11924 (closed defect: fixed)

Opened 20 months ago

Last modified 18 months ago

lazy_import_cache.get_cache_file doesn't work well if DOT_SAGE doesn't end with a slash

Reported by: jhpalmieri Owned by: tbd
Priority: critical Milestone: sage-4.8
Component: misc Keywords:
Cc: Work issues:
Report Upstream: N/A Reviewers: Jeroen Demeyer
Authors: John Palmieri Merged in: sage-4.8.alpha3
Dependencies: Stopgaps:

Description

The function get_cache_file in sage/misc/lazy_import_cache.py uses this code:

return "%s%s-lazy_import_cache.pickle" % (
       os.environ['DOT_SAGE'], 
       os.path.realpath(os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage')).replace(os.sep, '_'))

Since this just appends to DOT_SAGE, it returns a file in a different directory depending on whether DOT_SAGE ends with a slash or not: if DOT_SAGE is /home/user/.sage/, then this gives

/home/user/.sage/_mangled_SAGE_ROOT_...

whereas if DOT_SAGE is /home/user/.sage, then it gives

/home/user/.sage_mangled_SAGE_ROOT_...

which is a file in the directory /home/user/, not in .sage/.

The attached patch uses os.path.join to combine the parts of the path correctly. (I also wonder if it would be a good idea to store the cache file in a different directory, say DOT_SAGE/cache/, so it's hidden more than it is currently?)

Attachments

trac_11924-lazy.patch Download (1.2 KB) - added by jhpalmieri 19 months ago.

Change History

comment:1 Changed 20 months ago by jhpalmieri

  • Status changed from new to needs_review

comment:2 Changed 20 months ago by jhpalmieri

I've given this "major" priority because any user who sets their DOT_SAGE to a string without a trailing slash ends up getting their home directory polluted with Sage lazy import cache files. For example, on skynet, I have

export DOT_SAGE="/home/palmieri/.sage_$HOSTNAME"

and I end up with many files in /home/palmieri: one for each host on which I build and Sage, one for each version of Sage. Fortunately the files start with a dot so they're hidden, but still, it's not a good situation.

(I can fix this for my situation by adding a trailing slash, but I shouldn't have to.)

comment:3 Changed 20 months ago by jhpalmieri

  • Component changed from PLEASE CHANGE to misc

Changed 19 months ago by jhpalmieri

comment:4 Changed 18 months ago by jdemeyer

  • Priority changed from major to critical
  • Reviewers set to Jeroen Demeyer
  • Status changed from needs_review to positive_review

comment:5 Changed 18 months ago by jdemeyer

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.8.alpha3
Note: See TracTickets for help on using tickets.