Ticket #11924 (closed defect: fixed)
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
Change History
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.)

