Installation reference
The hegel-core server uses Hypothesis as the underlying library providing data generation, shrinking, and so on. Every Hegel library, regardless of language, therefore has an implicit dependency on Python.
At runtime, the first time a Hegel test is run in a test suite, each Hegel library spawns the hegel-core server as a subprocess.
Each Hegel library uses the following steps to run hegel-core:
- If the
HEGEL_SERVER_COMMANDenvironment variable is set, use that command directly. - Otherwise, the library uses
uv tool runto runhegel-corewith a specific version that the library has been tested with. - The first time this is run, it will install a virtualenv in
~/.cache/uv(or$XDG_CACHE_HOME/uvif set), after which that will be reused until the needed version changes.uvwill be found as follows:- If
uvis already on the PATH, it uses that. - If
uvis not on the PATH, the library automatically downloads a private copy ofuvto~/.cache/hegel/uv(or$XDG_CACHE_HOME/hegel/uvif set). This copy is not added to your PATH. - The library then uses
uv tool runto runhegel-core==$VERSION, where$VERSIONis determined by the version of the Hegel library you have installed, as each Hegel library pins to an exacthegel-coreversion in its source1.
- If
Some practical implications of this:
- The download of
uv(if needed) and the first run ofhegel-corehappen at runtime. If your tests must run in a sandboxed environment without network access, consider usingHEGEL_SERVER_COMMAND. - If you upgrade your Hegel library, and the Hegel library happened to bump its
hegel-coreversion, your first test run afterwards may be slow asuvfetches the new version.
Installing hegel-core manually
Section titled “Installing hegel-core manually”If you require greater control over how and when hegel-core is installed, use the HEGEL_SERVER_COMMAND environment variable.
Where the hegel-core binary gets placed depends on how you install hegel-core. For example, when using pip, the binary is placed into bin/hegel, where the bin/ directory is located inside the corresponding Python environment. You might then set HEGEL_SERVER_COMMAND=/path/to/.../bin/hegel.
For knowledgeable Python users, it may be useful to know that Hegel defines its entrypoint as:
[project.scripts]hegel = "hegel.__main__:main"Note that if you set HEGEL_SERVER_COMMAND, you are responsible for ensuring that your Hegel library version is compatible with that hegel-core version. We do our best to give informative errors where this is not the case, but there are a lot of possible combinations of this and ways things can go wrong, and only the most common have been tested for.
Troubleshooting
Section titled “Troubleshooting”This process should ideally be transparent to you. If it breaks without giving a very clear error message about what you need to do to fix it, that’s a bug and we’d appreciate it if you reported it.
The most useful source of information is that hegel-core server’s stderr is piped to .hegel/server.log and should contain any errors that occurred during installation, but any information you can give us about the environment that triggered the problems would be appreciated.
Footnotes
Section titled “Footnotes”-
Note that there is no correspondence between
hegel-coreversion numbers and Hegel library version numbers. ↩