Ask Your Question

Cleaning up after %attach in 5.7

asked 2013-03-05 03:54:17 -0500

csar gravatar image

updated 2013-05-14 01:19:07 -0500

tmonteil gravatar image

In 5.7, when I attach a file, call it foo.sage, I get files called something like foo.sageQ7xLla and created in the directory, plus a new pair every time foo.sage is altered. Obviously, this gets tiresome really quickly. Is there a way to get sage to create this files wherever it was doing it before (some tmp directory, I assume) or to clean up after itself on exit?

edit retag flag offensive close merge delete


csar gravatar imagecsar ( 2013-03-05 03:56:06 -0500 )edit

In fact, that should *still* address your question if you use `attach('foo.sage')` instead of `%attach foo.sage`.

kcrisman gravatar imagekcrisman ( 2013-03-05 04:28:12 -0500 )edit

It doesn't, though your comment in the other post describes what I'm talking about (though I never had this happen in earlier versions). Both `attach foo.sage` and `attach('foo.sage')` create the two new files in the working directory.

csar gravatar imagecsar ( 2013-03-05 08:10:48 -0500 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2013-05-14 01:16:26 -0500

Volker Braun gravatar image

updated 2013-05-14 06:13:51 -0500

kcrisman gravatar image

Fixed in #14523

edit flag offensive delete link more

answered 2013-05-12 12:04:07 -0500

David Bailey gravatar image

updated 2013-05-13 02:42:17 -0500

I face the same issue eight years after the question was initially asked, while using Sage Version 5.9-OSX-64bit-10.8. I am using init.sage for the first time, and every time a notebook is opened, two files are created in the .sage directory with names like init.sageCfCKee and The mulitiple copies quickly obscure everything else in the folder. Surely these files are supposed to go into the tmp or temp directories. Perhaps I have somehow corrupted my Sage setup, but for now my quick solution on my OS X Mac is to add the following two lines to the beginning of my init.sage file:

from subprocess import call
call("rm -f /Users/username/.sage/init.sage?*", shell=True)

This deletes the two offending files before any of the other init.sage commands are executed. I include a similar two lines at the beginning of other .sage files that I want to attach or load, but with "init" replaced by the name of that file. These lines can be added to any .sage file that is creating such duplicates. (Note:"/Users/username/.sage" should be replaced by the location of your own .sage file.)

WARNING: I am uncomfortable doing "rm -f" in any program, and I am concerned that deleting the two files will cause some problem, but so far I haven't noticed anything. Be careful, since if you make a typing mistake (e.g. forget the "?"), you might delete something you want to keep. Use at your own risk.

edit flag offensive delete link more



"Mar 05" means "the fifth of March (of the current year)", not March 2005. The ask-sage site was created in [August 2010](!topic/sage-devel/-54d7Q-qYWo).

slelievre gravatar imageslelievre ( 2013-05-12 13:39:05 -0500 )edit

Thanks for the clarification. Date ambiguities have caught me more than once. I am big fan of ISO (

David Bailey gravatar imageDavid Bailey ( 2013-05-13 02:50:43 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-03-05 03:54:17 -0500

Seen: 217 times

Last updated: May 14 '13