Trouble using Guava in SageMath 10.3 with GAP 4.12.2

81 views
Skip to first unread message

ETAL

unread,
Dec 7, 2024, 9:51:51 AM12/7/24
to sage-devel

Hello,

I am experiencing an issue using the Guava package in SageMath 10.3 with GAP 4.12.2 installed on my system. The strange part is that Guava works when I use the GAP console inside Sage, but it doesn't work when I try to load it through Sage directly.

The Issue:
  • SageMath Version: 10.3
  • GAP Version: 4.12.2
  • Problem: I can successfully load Guava when I open GAP via Sage’s gap.console(), but when I try to load it directly from Sage, I get an error. I have set the path to the external GAP binary in Sage, but this doesn’t seem to fix the issue.
What I Tried:
  1. Changing GAP Binaries: I set the path to the external GAP binary (installed on my system) by updating the SAGE_GAP_BINARY environment variable and running source ~/.bashrc.

    • Command: export SAGE_GAP_BINARY="/usr/local/bin/gap"
  2. Setting Sage to Use My GAP:

    • I added the following to my Sage configuration to ensure Sage uses my installed GAP version:
    import sage.interfaces.gap sage.interfaces.gap.gap_cmd = "/usr/local/bin/gap"
  3. Trying to Load Guava:

    • After setting the gap_cmd correctly, I attempted to load the Guava package using the following command within Sage:
    gap.eval('LoadPackage("Guava");')

    Error Output:

    'fail'
  4. Direct GAP Console Access:

    • When I open GAP directly via the terminal (not through Sage), and run LoadPackage("Guava");, it works fine, loading the package without any issues.
  5. Trying GAP Console from Inside Sage:

    • When I use the following code to launch GAP inside Sage:
    gap.console()

    Guava loads without any errors.

  6. Attempting Additional GAP Functions:

    • I attempted using DirectoriesPackageLibrary("/home/seddas/gap-4.12.2/pkg/guava"), but it returns an empty list ('[ ]').
    • I also tried using SetPackagePath("/home/seddas/gap-4.12.2/pkg") to set the correct path, but the issue persists.
  7. Reinstalling Guava:

    • I double-checked the installation and directory structure, and Guava seems to be installed correctly in /home/seddas/gap-4.12.2/pkg/guava.
Errors Encountered:
  1. Error when loading Guava in Sage:

    'fail'
  2. Error when trying to add the package directory in GAP:

    Error, Variable: 'AddPackageDirectory' must have a value
  3. Error when attempting to set the GAP package directory:

    [ ]
Summary:
  • Guava works when accessed through Sage’s GAP console using gap.console().
  • When I try to load Guava through Sage directly, it fails.

I would really appreciate your help, as I have been trying to resolve this issue for several hours without success. Thank you very much!


Jackson Walters

unread,
Dec 7, 2024, 10:24:46 AM12/7/24
to sage-...@googlegroups.com
Without knowing the details of Guava, I recently had to install and use the GAP `forms` package. It was a little tricky to load it properly using gap.eval, but what ended up working better was libgap,

libgap.LoadPackage(“forms”)

and you can check the Boolean return type to see if it loaded properly.

HTH,
Jackson

--
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 sage-devel+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sage-devel/9a5a7519-e41b-4d7a-afce-0a15d6af4f68n%40googlegroups.com.

Michael Orlitzky

unread,
Dec 7, 2024, 12:27:36 PM12/7/24
to sage-...@googlegroups.com
On 2024-12-06 01:34:46, ETAL wrote:
>
> Hello,
>
> I am experiencing an issue using the Guava package in SageMath 10.3 with
> GAP 4.12.2 installed on my system. The strange part is that *Guava works
> when I use the GAP console inside Sage*, but it doesn't work when I try to
> load it through Sage directly.

If sage is using a separate copy of GAP that it built, then just
changing the path to the binary is not enough. It will also be using a
separate copy of the libgap library for most things, and that copy of
libgap will be unable to use the packages that you have installed in
your "normal" GAP.

For a quick fix, install the gap_packages SPKG. It contains Guava. For
a better fix, try to find a version of Sage (10.4?) that will use your
existing GAP 4.12.2. (Unfortunately Sage 10.5 will reject anything
older than GAP 4.13.0.)

In the long term, we know that this is pretty confusing, and it would
be a lot nicer IMO if we refused to build a separate copy of GAP and
instead told the user to install it. The same goes for things like
GCC, python, flint, pari, etc. that can easily be installed on any
system. But GAP is particularly annoying for power users because
of the way its packages are (not) handled.

ETAL

unread,
Dec 7, 2024, 12:44:26 PM12/7/24
to sage-devel

Thank you for your reply and assistance; I truly appreciate it. However, I’m unable to get Sage 10.4, at least not through sudo or the binaries. It took me over seven hours to install Sage 10.3 from the source code, so I’m just trying to make it work as best as I can.

Regarding the installation of the gap_packages SPKG, I’m not sure how to proceed. Should I revert the changes I made to the source (specifically the binaries) and restore it to its original state? If so, what exactly should I modify in the line:

Export SAGE_GAP_BINARY="/usr/local/bin/gap"

I’m feeling quite confused and would really appreciate your guidance on this. Thank you so much for your valuable help!

Amal

Dima Pasechnik

unread,
Dec 7, 2024, 3:52:33 PM12/7/24
to sage-...@googlegroups.com
On Sat, Dec 7, 2024 at 11:44 AM ETAL <amals...@gmail.com> wrote:
>
> Thank you for your reply and assistance; I truly appreciate it. However, I’m unable to get Sage 10.4, at least not through sudo or the binaries. It took me over seven hours to install Sage 10.3 from the source code, so I’m just trying to make it work as best as I can.

7 hours is not normal. This means that either you have a rather old OS
which doesn't have many packages needing Sage, or you simply didn't
install them (output of ./configure gives you some advice, don't
ignore it), and rather let Sage build their own copies of most
everything.
Please post your top-level config.log to let us see what went wrong.

>
> Regarding the installation of the gap_packages SPKG, I’m not sure how to proceed. Should I revert the changes I made to the source (specifically the binaries) and restore it to its original state? If so, what exactly should I modify in the line:
>
> Export SAGE_GAP_BINARY="/usr/local/bin/gap"

This won't be enough. Sage is using a lot of functionality of GAP from
libgap, which has to be linked into the corresponding Python module.

>
> I’m feeling quite confused and would really appreciate your guidance on this. Thank you so much for your valuable help!
>
> Amal
> Le samedi 7 décembre 2024 à 18:27:36 UTC+1, Michael Orlitzky a écrit :
>>
>> On 2024-12-06 01:34:46, ETAL wrote:
>> >
>> > Hello,
>> >
>> > I am experiencing an issue using the Guava package in SageMath 10.3 with
>> > GAP 4.12.2 installed on my system. The strange part is that *Guava works
>> > when I use the GAP console inside Sage*, but it doesn't work when I try to
>> > load it through Sage directly.
>>
>> If sage is using a separate copy of GAP that it built, then just
>> changing the path to the binary is not enough. It will also be using a
>> separate copy of the libgap library for most things, and that copy of
>> libgap will be unable to use the packages that you have installed in
>> your "normal" GAP.
>>
>> For a quick fix, install the gap_packages SPKG. It contains Guava. For
>> a better fix, try to find a version of Sage (10.4?) that will use your
>> existing GAP 4.12.2. (Unfortunately Sage 10.5 will reject anything
>> older than GAP 4.13.0.)
>>
>> In the long term, we know that this is pretty confusing, and it would
>> be a lot nicer IMO if we refused to build a separate copy of GAP and
>> instead told the user to install it. The same goes for things like
>> GCC, python, flint, pari, etc. that can easily be installed on any
>> system. But GAP is particularly annoying for power users because
>> of the way its packages are (not) handled.
>
> --
> 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 sage-devel+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sage-devel/57d9de9a-963c-4b91-9a41-b286d4c3bd8en%40googlegroups.com.

Michael Orlitzky

unread,
Dec 7, 2024, 7:47:02 PM12/7/24
to sage-...@googlegroups.com
On 2024-12-07 09:37:55, ETAL wrote:
> Thank you for your reply and assistance; I truly appreciate it. However,
> I’m unable to get Sage 10.4, at least not through sudo or the binaries. It
> took me over seven hours to install Sage 10.3 from the source code, so I’m
> just trying to make it work as best as I can.

I understand completely.


> Regarding the installation of the gap_packages SPKG, I’m not sure how to
> proceed. Should I revert the changes I made to the source (specifically the
> binaries) and restore it to its original state? If so, what exactly should
> I modify in the line:
> Export SAGE_GAP_BINARY="/usr/local/bin/gap"

Yes, revert anything that you changed, and then install the
gap_packages SPKG with "sage -i gap_packages". That will install
several GAP packages, including Guava, to a location where the sage
copy of GAP can find them.

If you don't remember the old path for SAGE_GAP_BINARY, there should
be only one "gap" executable in your sage installation, so you can
probably find it with something like,

$ find ./path/to/sage -type f -executable -name 'gap'
Reply all
Reply to author
Forward
0 new messages