The Symptom Was Always the Same
I ran a script at home and nothing happened. No error, no output. The notification bot stayed quiet and the evening wrap-up routine produced an empty result. The cause was identical every time: when the script was built on a Windows device, the folder location had been typed straight into the code.
Our Setup
We have three devices: two Windows devices whose drive letters differ, plus a Mac mini. A script that ran fine on one machine was staring at a folder that did not exist on another. It exited normally without any exception, so it was hard to even call it a failure. The same incident repeated four times this way.
Before
• Folder paths typed directly into the code
• Running on a different device read an empty folder and quietly finished
• Each incident was patched one file at a time, then forgotten
After
We wrote one shared module that works out the base folder from the script's own location, and made every script import only that.
from pathlib import Path
BASE = Path(__file__).resolve().parent.parent
def repo(name):
return BASE / name
Switching devices no longer matters, because everything is computed from where the script sits, so drive letters stop being a factor. The few exceptions that are truly needed get a one-line comment marking them as exempt.
Monitoring Came Along Too
We added a small checker that runs at every sync and reports how many hardcoded paths remain. A falling number means the cleanup is working. A rising number is an alarm that a new one slipped in.
What We Learned
1. A counting tool outlasts a rule that says do not do this.
2. A failure that ends without an error is the most expensive kind.
3. Do not hide exceptions. Mark them so everyone can see.
The fix was a few lines of code, but what really changed was the peace of mind that it gives the same result wherever it runs.