# How to load optional gap packages

I would like to use the GAP package HAP in Sage. This is used, for example, to calculate cohomology of permutation groups as in (from the sage reference manual):

```
sage: G = SymmetricGroup(4)
sage: G.cohomology(1,2) # optional - gap_packages
```

In Sage 5.10, this raises

```
RuntimeError: Error loading Gap package hap. You may want to install the gap_packages SPKG.
```

Note that this is the error *after* installing `gap_packages`

with `sage -i gap_packages`

. I verified this with `sage -optional`

, which gives:

```
Using SAGE Server http://www.sagemath.org/packages
***********************************
*** optional Packages ***
***********************************
INSTALLED:
gap_packages-4.5.7
NOT INSTALLED:
4ti2-1.3.2.p1
autotools-20121217
beautifulsoup-3.2.1
biopython-1.61
...
```

Now I can track this error a little bit, to find the following bugs:

```
sage: from sage.groups.perm_gps.permgroup import load_hap
sage: load_hap()
...
RuntimeError: Error loading Gap package hap. You may want to install the gap_packages SPKG.
sage: gap.eval('LoadPackage("hap")')
'fail'
sage: gap.eval('LoadPackage("HAP")')
'fail'
sage: gap.eval('LoadPackage("Hap")')
'fail'
sage: gap.eval('LoadPackage("Hap1.10")')
'fail'
```

That last guess comes from listing the contents of `SAGEROOT//local/gap/gap-4.5.7/pkg/`

, but seems to not work. Moreover, when I run gap directly with `sage -gap`

, loading HAP fails there too. When I run `LoadAllPackages();`

in gap, HAP is not on the list of those that load.

p.s. Yes, I know this is a bug and should be reported on Trac, but since we're right in the middle of migrating Trac to a new (virtual) machine, I'd rather wait a bit. Also, I don't have a solution for this, and I think the bigger problem is that `#optional` doctests are skipped too often. That's a different complaint :\

See also http://trac.sagemath.org/13540 to automatically run the optional doctests if the optional package has been installed.