Fix railties build

Hello,

This pull request aims to make the railties build green ; this originally shipped with the patch introduced by #12719 but revert it since Arun has open it before so please merge it before merging this one (and I will happily rebase to make sure that the build is green).

I have not squash the commits since I think it's really three different patches but I gather them to only run one build , if you think that I should squash them, let me know.

Have a nice day.