Why are you running Foreman under passenger? As far as I know that is unsupported[1, 2] and most likely is the reason why you’re hitting that error. We already dropped some workarounds[3] which were need for Dynflow to work under passenger
[1] - Foreman :: Manual
[2] - Drop Passenger support
[3] - https://github.com/theforeman/foreman/commit/66e39019953c9f993d6951cca0d0c0567050a3c1