# Why can't I attach files?

Hi -

I recently installed Sage on my new Macbook (although I've used Sage before, on my old -- and sadly, recently stolen -- Macbook). I'm using the Sage notebook. (Details of my installation below.)

If I attach a file ("attach foo.sage"), it loads/runs the commands in that file, just like it's supposed to and used to. However, if I make any alteration to the attached file while the Sage notebook is still running, then when I return to the notebook and try to do anything, Sage freaks out.

By "freak out," I mean that if I try to do any computation, even one that doesn't involve the variables or functions in the attached file (e.g., "2+2"), I get a massive error message, which ends with "RuntimeError: maximum recursion depth exceeded in cmp". I've pasted more of the error message below. This behavior continues until I quit and restart that notebook. It seems that the contents of the attached file are irrelevant -- I've tried it with simple files that contain nothing but a single print command, or something basic like "a=5".

I did a little searching, and I turned up this discussion on the sage-notebook Google Group, where William Stein notes this behavior. So obviously somebody who knows something is aware of this. But that was all I could find anywhere, and I have no sense for whether there is a fix/workaround for this.

I briefly tested to see if this also happens when I use Sage from a terminal. I don't get the recursion error then. However, if I re-enter the "attach" command after I've altered the attached file, it appears to run through the commands in that file twice. (So, for instance, if the attached file includes "print 'Hello!'", it will do this twice.) I understand that the command line avoids the error, but I would really prefer to use the notebook if I can.

Any ideas? Please speak slowly and use small words (metaphorically). Thanks!

The error message starts with...

```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_14.py", line 10, in <module>
File "", line 1, in <module>
File "/private/var/folders/5h/c6x89ch91fjgr43q99g8wbjw0000gn/T/tmphXrluN/___code___.py", line 3, in <module>
sage.misc.preparser.load(sage.misc.preparser.base64.b64decode("Ii9Vc2Vycy9Kb2huL0Rlc2t0b3AvU2FnZV9zY3JpcHRzL3Rlc3Rlci5zYWdlIg=="),globals(),True)
File "/Applications/Sage-4.8-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/preparser.py", line 1644, in load
execfile(preparse_file_named(fpath), globals)
File "/Users/John/.sage/temp/C_K_Dexter_Haven.local/34442/_Users_John_Desktop_Sage_scripts_tester_sage_6.py", line 6, in <module>
```

Then, the latter 4 lines (starting with "sage.misc.preparser.load") are repeated 492 more times, with the only thing changing being the number following "scripts_tester_sage_" in the last line. Then, it ends with:

```
sage.misc.preparser.load(sage.misc.preparser.base64.b64decode("Ii9Vc2Vycy9Kb2huL0Rlc2t0b3AvU2FnZV9zY3JpcHRzL3Rlc3Rlci5zYWdlIg=="),globals(),True)
File "/Applications/Sage-4.8-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/preparser.py", line 1644, in ...
```

It looks like this is just broken right now. One thing to try: the discussion you linked to from sage-notebook referred to http://trac.sagemath.org/sage_trac/ticket/11080. Try following the (rather involved) instructions there to update the Sage notebook.

Thanks for your response. I looked through the discussion on that trac, and no mention is made of the "attach" problem, so I'm not sure that the work done there addresses this problem. In the Google Groups discussion that I linked to, after William Stein mentions the problem, there's a short back and forth which seems to end when someone says that he can't replicate it.

The notebook has been completely rewritten, and the new version is available at the link I posted. The discussion was whether this was just an issue with the old version (which is in Sage 4.8) or persists in the new version. It looks to me from the discussion as though the new version doesn't have this problem. Hence my suggestion.

Okay -- thanks! I wasn't able to make much sense of the discussion there. So, near the top of the page for that ticket, I see a long list of "Explicit instructions," as well as two files (a .spkg and a .patch). Are those instructions meant for folks like me, or just for developers working on the fixes? And I am meant to download both/either of those files, or is that done by those "explicit instructions"? I really feel out of my league whenever I look at sage_trac.

It looks like those directions take care of everything. You don't need to download any files explicitly, it's all done for you.