Opened 12 years ago

Closed 12 years ago

#9938 closed defect (fixed)

GAP does not start if the path to the GAP workspace file contains more than 82 characters

Reported by: saliola Owned by: saliola
Priority: blocker Milestone: sage-4.6
Component: interfaces Keywords: gap
Cc: slabbe, mrobado Merged in: sage-4.6.alpha2
Authors: Franco Saliola Reviewers: Sébastien Labbé
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by saliola)

As pointed out in thread, on some machines one there is a problem starting GAP from within Sage:

sage: gap('3+2')
A workspace appears to have been corrupted... automatically rebuilding (this is harmless).
---------------------------------------------------------------------------
...
TypeError: Unable to start gap

The problem is in Sage's attempt to rebuild the GAP workspace. It turns out that Sage calls GAP's SaveWorkspace command incorrectly in a particular case.

To explain the problem, first recall the process used by the GAP interface to evaluate a line of GAP code, say LineOfGapCode. It begins by checking the length LineOfGapCode (as a string). If this length is greater than 100 (a pre-defined cut-off value), then a file is created containing:

Print(LineOfGapCode);

This file is read into GAP using the expect interface and the output is parsed and returned to Sage. (There is no problem if the length is less than 100, because the interface does not use a file.)

Let's apply this to the case where we need to rebuild a workspace. The workspace is just a file contained in a user's .sage directory. If the number of characters in the path to the workspace is greater than the cut-off, then Sage tries to execute the following command:

Print(SaveWorkspace("PathToWorkspaceFile"));

This is not permitted by GAP, as explained in the GAP Reference Manual:

SaveWorkspace can only be used at the main gap> prompt. It cannot be included in the body of a loop or function, or called from a break loop.

So to fix this, we need to force the interface not to use a file to execute the SaveWorkspace command.

(This problem has plagued all the computers in our computer lab for months since a user's home directory is located on a network drive with a long name.)

This is reproducible:

sage: ws = sage.interfaces.gap.WORKSPACE
sage: sage.interfaces.gap.WORKSPACE += "0"*(83-len(ws))
sage: gap = Gap()
sage: gap('3+2')

Boom!

Attachments (3)

trac9938.2.patch (2.3 KB) - added by saliola 12 years ago.
trac9938.patch (2.3 KB) - added by saliola 12 years ago.
apply only this patch!
trac9938-review-sl.patch (1.1 KB) - added by slabbe 12 years ago.
Applies over the precedent patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 12 years ago by saliola

  • Cc slabbe mrobado added
  • Description modified (diff)
  • Owner changed from was to saliola
  • Summary changed from GAP does not start if the path to the GAP workspace file contains more than 83 characters to GAP does not start if the path to the GAP workspace file contains more than 82 characters

Changed 12 years ago by saliola

Changed 12 years ago by saliola

apply only this patch!

comment:2 Changed 12 years ago by saliola

  • Status changed from new to needs_review

comment:3 Changed 12 years ago by saliola

  • Status changed from needs_review to needs_work

comment:4 Changed 12 years ago by saliola

  • Status changed from needs_work to needs_review

Changed 12 years ago by slabbe

Applies over the precedent patch

comment:5 follow-up: Changed 12 years ago by slabbe

  • Authors set to Franco Saliola
  • Reviewers set to Sébastien Labbé

I was able to reproduce the problem on my osx 10.5 running sage-4.5.3. The patch fixes the problem. All tests pass on sage/interfaces/gap.py. Documentation builds fine.

I added a review patch that simply puts back the constant sage.interfaces.gap.WORKSPACE to its original value since the new value was used in all the rest of the doctests.

I am giving a positive review to Franco's patch. I let him change the status of this ticket to positive review if he agrees with my small fix.

I did not manage to apply a patch on the sage install of LaCIM laboratory by ssh. Maybe Jérôme could test the patch on Monday.

comment:6 Changed 12 years ago by saliola

  • Status changed from needs_review to positive_review

I'm okay with your changes, Sébastien.

Apply patches in this order:

  1. trac9938.patch
  2. trac9938-review-sl.patch

comment:7 in reply to: ↑ 5 Changed 12 years ago by slabbe

I did not manage to apply a patch on the sage install of LaCIM laboratory by ssh. Maybe Jérôme could test the patch on Monday.

Last Monday, I tested the patch on one of the computer in the lab and I can confirm the patches solve the problem. Great!

comment:8 Changed 12 years ago by mpatel

  • Merged in set to sage-4.6.alpha2
  • Resolution set to fixed
  • Status changed from positive_review to closed

Thanks for fixing this! I encountered just this problem about two days ago when doctesting with a long DOT_SAGE.

Note: See TracTickets for help on using tickets.