All the QGIS documentation I've seen on custom functions (used in expressions) says that the code is saved in the user's local expressions directory, e.g. ~/.local/share/QGIS/QGIS3/profiles/default/python/expressions
in Linux. The same documentation typically says something like "remember to share your expression files if others need this functionality" (example)
It seems like the only way to share this code is for other users to manually copy it to their own expressions directory, however that seems inadequate. If multiple map developers share a version control system the onus is on them to manually copy any updates to custom functions to their expressions directory. It does not seem possible for expressions to be loaded from an alternate path, e.g. one relative to the .qgs file, and therefore automatically update each time a project is loaded.
I plan to create a Feature Request for loading custom functions from a relative path, but first wanted to check that I have understood the current situation correctly. Do all users of shared custom functions really need to manually copy the code to their expressions directory each time it changes?
~/.local/share/QGIS/QGIS3/profiles/default/python/expressions
, then either at given time interval or when an app opens (or when you manually do it), you refresh this local folder using the content of the remote folder