Why do you think that disabling ColorPrompt would make a difference, if the
escape sequence is being emitted by rl_initialize()?

- Marc

On Tue, Mar 3, 2026 at 10:55 AM Dima Pasechnik <[email protected]> wrote:

> As far as m4 goes, probably having
>
> iff --git a/build/pkgs/gap/spkg-configure.m4
> b/build/pkgs/gap/spkg-configure.m4
> index 937fe400407..f754b29a455 100644
> --- a/build/pkgs/gap/spkg-configure.m4
> +++ b/build/pkgs/gap/spkg-configure.m4
> @@ -13,14 +13,14 @@ SAGE_SPKG_CONFIGURE([gap], [
>        dnl so long as we don't initialize GAP with -r in Sage. But we
>        dnl don't want to include it in the hard-coded list.
>        GAPRUN="${GAP} -r -q --bare --nointeract -c"
> -      _cmd='Display(GAPInfo.KernelInfo.KERNEL_VERSION);'
> +      _cmd='ColorPrompt(false);
> Display(GAPInfo.KernelInfo.KERNEL_VERSION);'
>        GAP_VERSION=$( ${GAPRUN} "${_cmd}" 2>/dev/null )
>        AX_COMPARE_VERSION(["${GAP_VERSION}"], [ge], [GAP_MINVER], [dnl
>         AC_MSG_RESULT([yes])
>         AX_COMPARE_VERSION(["${GAP_VERSION}"], [lt], [GAP_LTVER], [dnl
>          AC_MSG_RESULT([yes])
>          AC_MSG_CHECKING([for gap root paths])
> -        _cmd='Display(JoinStringsWithSeparator(GAPInfo.RootPaths,";"));'
> +        _cmd='ColorPrompt(false);
> Display(JoinStringsWithSeparator(GAPInfo.RootPaths,";"));'
>          SYS_GAP_ROOT_PATHS=$( ${GAPRUN} "${_cmd}" 2>/dev/null )
>          AC_MSG_RESULT([$SYS_GAP_ROOT_PATHS])
>          AS_IF([test -n "${SYS_GAP_ROOT_PATHS}"], [
>
> would avoid the trouble you have. (after the usual ./bootstrap etc etc)
>
>
>
> On Tue, Mar 3, 2026 at 10:19 AM Marc Culler <[email protected]> wrote:
>
>> I managed to track this down.
>>
>> First, I found this in sage/sage-distro/meson-logs/meson-log.txt:
>>
>>
>>
>>
>>
>>
>>
>> *Running command: /var/tmp/sage-10.9/local/bin/gap -r -q --bare
>> --nointeract
>> -c 'Display(JoinStringsWithSeparator(GAPInfo.RootPaths,";"));'--- stdout
>> ---ESC[?1034h/var/tmp/sage-10.9/local/lib/gap/;/var/tmp/sage-10.9/local/share/gap/---
>> stderr ---*
>> So,  meson is running sage's gap executable to find its root paths.  But
>> it is getting the "set 8 bit meta" escape sequence at the beginning of the
>> gap output.
>>
>>  If I run that command in the shell I do not get the  escape sequence:
>>
>> sage/local/bin/gap -r -q --bare --nointeract -c
>> 'Display(JoinStringsWithSeparator(GAPInfo.RootPaths,";"));' | xxd
>> 00000000: 2f76 6172 2f74 6d70 2f73 6167 652d 3130  /var/tmp/sage-10
>> 00000010: 2e39 2f6c 6f63 616c 2f6c 6962 2f67 6170  .9/local/lib/gap
>> 00000020: 2f3b 2f76 6172 2f74 6d70 2f73 6167 652d  /;/var/tmp/sage-
>> 00000030: 3130 2e39 2f6c 6f63 616c 2f73 6861 7265  10.9/local/share
>> 00000040: 2f67 6170 2f0a                           /gap/.
>>
>> However, clearly there are times when the escape sequence does get added.
>>
>> The culprit turns out to be readline-6.2, which is what my docker image
>> happens to be using. Gemini was able to find some information about this:
>>
>> *        Version 6.3 Fix*: In earlier versions (notably 6.0 through
>> 6.2), rl_initialize() would output the "Meta mode ON" sequence to stdout
>>         even if the output was not a terminal, causing issues like
>> corrupted script output and erroneous characters in program pipes.
>>
>> This problem did not occur with 10.8.  The difference is probably that
>> the rl_initialize was being called at some earlier stage of the build
>> process, so the escape sequence was being emitted somewhere else, not in
>> the step where the GAP root paths are constructed.
>>
>> Moral: It is always something.
>>
>> - Marc
>>
>>
>>
>>
>> On Tuesday, March 3, 2026 at 8:25:29 AM UTC-6 Marc Culler wrote:
>>
>>> I can tell you something about where it came from.
>>>
>>>  When I look at sage/local/lib/python3.14/site-packages/sage/config.py I
>>> see:
>>>
>>>
>>>
>>>
>>> *# The semicolon-separated list of GAP root paths. This is the list of#
>>> locations that are searched for GAP packages. This is passed directly# to
>>> GAP via the -l flag.GAP_ROOT_PATHS =
>>> "ESC[?1034h/var/tmp/sage-10.9/local/lib/gap/;/var/tmp/sage-10.9/local/share/gap/".replace("${prefix}",
>>> SAGE_LOCAL)*
>>>
>>> The file config.py is generated from sage/src/sage/config.py.in, which
>>> contains:
>>>
>>>
>>>
>>>
>>> *# The semicolon-separated list of GAP root paths. This is the list of#
>>> locations that are searched for GAP packages. This is passed directly# to
>>> GAP via the -l flag.GAP_ROOT_PATHS =
>>> "@GAP_ROOT_PATHS@".replace("${prefix}", SAGE_LOCAL)*
>>>
>>> So it would seem that some m4 file is inserting the "enable 8 bit meta"
>>> escape sequence into @GAP_ROOT_PATHS@ for my enjoyment and
>>> entertainment.
>>>
>>> Also, when I remove that escape sequence from config.py, guess what?
>>>
>>> sage: gap.FreeGroup(3)
>>> Group( [ f1, f2, f3 ] )
>>>
>>> - Marc
>>>
>>>
>>>
>>> On Monday, March 2, 2026 at 11:35:18 PM UTC-6 [email protected] wrote:
>>>
>>>> "\033[?1034h/var/tmp/sage-10.9/local/lib/gap/" is certainly looking
>>>> bad, and probably is the root of the problem.
>>>>
>>>> No idea where it came from.
>>>>
>>>>
>>>>
>>>> On Mon, Mar 2, 2026 at 9:52 PM Marc Culler <[email protected]> wrote:
>>>>
>>>>> I deleted .sage/gap and tried again.  No change.
>>>>>
>>>>> I also tried
>>>>>    sage: libgap.eval('F:= FreeGroup(3)')
>>>>> That produces the same GAPError, but there was some other stuff
>>>>> printed before the traceback which might provide a clue:
>>>>>
>>>>> #I  gapdoc package is not available. Check that the name is correct
>>>>> #I  and it is present in one of the GAP root directories (see
>>>>> '??RootPaths')
>>>>> #I  GAP: needed package gapdoc cannot be loaded
>>>>> Error, failed to load needed package `gapdoc' (version >= 1.2)
>>>>> Syntax warning: Unbound global variable in
>>>>> /var/tmp/sage-10.9/local/share/gap/l\
>>>>> ib/init.g:728
>>>>>     ColorPrompt( UserPreference( "UseColorPrompt" ) );
>>>>>     ^^^^^^^^^^^
>>>>> Error, SetGasmanMessageStatus: function is not yet defined
>>>>> Error, Variable: 'L1_IMMUTABLE_ERROR' must have a value
>>>>> Error, Variable: 'ColorPrompt' must have a value
>>>>>
>>>>> I did find  some other suspicious stuff:
>>>>>
>>>>> sage: libgap.eval('GAPInfo.RootPaths')
>>>>> [ "/home/culler/.gap/",
>>>>> "\033[?1034h/var/tmp/sage-10.9/local/lib/gap/",
>>>>> "/var/tmp/sage-10.9/local/share/gap/" ]
>>>>>
>>>>> The last path contains an empty pkg directory.  The real pkg directory
>>>>> is in $SAGE_ROOT/local/lib/gap.  But I doubt that the second path would
>>>>> work correctly when it has all of those ANSI escape sequences in front of
>>>>> it.  Adding a symlink /var/tmp/sage-10.9/local/share/gap/pkg ->
>>>>> ../../lib/gap/pkg did not help.  But maybe putting ANSI escape sequences 
>>>>> in
>>>>> a root path makes GAP crash.
>>>>>
>>>>> - Marc
>>>>>
>>>>>
>>>>> - Marc
>>>>>
>>>>> On Mon, Mar 2, 2026 at 9:13 PM Dima Pasechnik <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> The usual suspects for strange GAP errors are stale GAP workspaces
>>>>>> (or related to them errors). Make sure you don't have any (typically in
>>>>>> ~/.sage/, although your setup might have a different location of .sage/)
>>>>>>
>>>>>>
>>>>>>
>>>>>> On March 2, 2026 4:37:34 PM CST, Marc Culler <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Monday, March 2, 2026 at 3:32:23 PM UTC-6 [email protected] wrote:
>>>>>>>
>>>>>>>
>>>>>>> That's a problem with the pexpect GAP. Does
>>>>>>>
>>>>>>>     sage: libgap.FreeGroup(3)
>>>>>>>
>>>>>>> work?
>>>>>>>
>>>>>>>
>>>>>>> No.  I don't get a RuntimeError (which I think is produced by
>>>>>>> pexpect) but I get:
>>>>>>>
>>>>>>> GAPError: Error, FreeGroup: function is not yet defined
>>>>>>>
>>>>>>> Does
>>>>>>>
>>>>>>>    ./sage -t src/sage/features/gap.py
>>>>>>>
>>>>>>> pass?
>>>>>>>
>>>>>>>
>>>>>>> Yes. I get:
>>>>>>>
>>>>>>> Doctesting 1 file.
>>>>>>> sage/src/bin/sage -t --warn-long 5.0
>>>>>>> --random-seed=206062923921806203470542245493080431476
>>>>>>> sage/src/sage/features/gap.py
>>>>>>>     [5 tests, 0.01s wall]
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>> All tests passed!
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>> Total time for all tests: 0.2 seconds
>>>>>>>     cpu time: 0.0 seconds
>>>>>>>     cumulative wall time: 0.0 seconds
>>>>>>> Features detected for doctesting:
>>>>>>>
>>>>>>> - Marc
>>>>>>>
>>>>>>> --
>>>>>> You received this message because you are subscribed to a topic in
>>>>>> the Google Groups "sage-devel" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/d/topic/sage-devel/dVVleHx0xP0/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>> [email protected].
>>>>>> To view this discussion visit
>>>>>> https://groups.google.com/d/msgid/sage-devel/B04DFD67-0325-4949-A30C-4D2A1AD9F7EE%40gmail.com
>>>>>> <https://groups.google.com/d/msgid/sage-devel/B04DFD67-0325-4949-A30C-4D2A1AD9F7EE%40gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>>>
>>>> You received this message because you are subscribed to the Google
>>>>> Groups "sage-devel" group.
>>>>>
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To view this discussion visit
>>>>> https://groups.google.com/d/msgid/sage-devel/CALcZXRHNSvqL8Vi8v3fQLoOroBbi%2BXB%2B%2BSMgV8doMzU7DhLUeQ%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/sage-devel/CALcZXRHNSvqL8Vi8v3fQLoOroBbi%2BXB%2B%2BSMgV8doMzU7DhLUeQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>> You received this message because you are subscribed to the Google Groups
>> "sage-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion visit
>> https://groups.google.com/d/msgid/sage-devel/f7733173-3d56-4142-af48-a12efed9b910n%40googlegroups.com
>> <https://groups.google.com/d/msgid/sage-devel/f7733173-3d56-4142-af48-a12efed9b910n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sage-devel" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sage-devel/dVVleHx0xP0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/sage-devel/CAAWYfq0OQ4PEeW_K-5hFuPc1ZD_-1kp_hWWADYUbT2jB99%3D92A%40mail.gmail.com
> <https://groups.google.com/d/msgid/sage-devel/CAAWYfq0OQ4PEeW_K-5hFuPc1ZD_-1kp_hWWADYUbT2jB99%3D92A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/sage-devel/CALcZXRFWR%3Di9yXmk1MZih9WjVAfvNQ4_kUt2yLEF0rjUHLTj_A%40mail.gmail.com.

Reply via email to