Skip to content

feat: Check whether GCC is installed in initenv.sh #608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2025

Conversation

cliffmccarthy
Copy link
Contributor

@cliffmccarthy cliffmccarthy commented Aug 7, 2025

  • The Python modules installed by initenv.sh require a compiler to build.
  • Before proceeding with installation of Python dependencies, check whether the 'gcc' command is available by running it with the --version argument. If it is not available, print a helpful message and exit.

- The Python modules installed by initenv.sh require a compiler to build.
- Revised initenv.sh to check whether build-essential is installed
  before proceeding, if the system is based on Debian or Ubuntu.
@cliffmccarthy
Copy link
Contributor Author

Because build-essential is just a bundle of several other packages, there might be a more specific package (or packages) we could require, but I didn't do all the experimentation that would be necessary to determine exactly which set of packages that would be. build-essential is sufficient in the Debian environment I am working with, and seems to me like a reasonable thing to check for.

Copy link
Contributor

@missytake missytake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, are you sure you need to install build-essential? Why doesn't our CI need it? https://github.com/chatmail/relay/actions/runs/16828106233/job/47669201565?pr=610

It ran fine without build-essential so far.

@cliffmccarthy
Copy link
Contributor Author

Okay, that makes this a CI-breaking change, so I guess I need to go the route of identifying the more specific set of packages that are needed. It's probably gcc, maybe make. I'll do some more experiments to try to identify exactly what we require. I bet ubuntu-latest is providing whatever it is, without including the build-essential bundle.

@cliffmccarthy cliffmccarthy force-pushed the require-build-essential branch from e1851bb to 6486184 Compare August 8, 2025 14:40
@cliffmccarthy cliffmccarthy changed the title feat: Make sure build-essential is installed feat: Check whether GCC is installed in initenv.sh Aug 8, 2025
@cliffmccarthy
Copy link
Contributor Author

It appears that the gcc package is suficient. Rather than check for the package, I revised it to attempt to run the command. Here is the kind of lengthy explanation I gave in the commit message:

For the current set of Python dependencies, without GCC, the build process fails when building the crypt-r package. According to the error message, on my system the exact command it tries to run is 'x86_64-linux-gnu-gcc', but rather than depend on this variant specifically, the script checks for the generic 'gcc' command, so as to avoid coupling the check to an architecture or operating system. Similar problems arise if we attempt to check for packages by name; the compiler binary is provided by 'gcc-11', but the symlinks that provide the unversioned commands (as used by the Python build) come from a package named 'gcc'. Trying to be too precise in what we check for could lead to unnecessary failures in some environments, or become a maintenance challenge in the future. For that reason, this change simply attempts to run 'gcc' and uses that as a probably-sufficient proxy for having what the Python package install will need.

- Before proceeding with installation of Python dependencies, check
  whether the 'gcc' command is available by running it with the
  --version argument.  If it is not available, print a helpful message
  and exit.
- For the current set of Python dependencies, without GCC, the build
  process fails when building the crypt-r package.  According to the
  error message, on my system the exact command it tries to run is
  'x86_64-linux-gnu-gcc', but rather than depend on this variant
  specifically, the script checks for the generic 'gcc' command, so as
  to avoid coupling the check to an architecture or operating system.
  Similar problems arise if we attempt to check for packages by name;
  the compiler binary is provided by 'gcc-11', but the symlinks that
  provide the unversioned commands (as used by the Python build) come
  from a package named 'gcc'.  Trying to be too precise in what we
  check for could lead to unnecessary failures in some environments,
  or become a maintenance challenge in the future.  For that reason,
  this change simply attempts to run 'gcc' and uses that as a
  probably-sufficient proxy for having what the Python package install
  will need.
Copy link
Contributor

@missytake missytake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks :)

@missytake missytake merged commit 3ce350d into chatmail:main Aug 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants