A script works on your Mac but fails in the Linux CI runner with odd path and encoding errors. What do you check?
IntermediateScenarioAutomation scripting & CLI design
Answer
Situation read → Classic environment drift: case sensitivity, encodings, tool versions.
What I'd do →
- Case sensitivity: macOS's filesystem is case-insensitive by default;
import Configvsconfig.pyworks on Mac and fails on Linux. - Encoding: always pass
encoding="utf-8"; CI containers may have no locale set. - Hardcoded paths (
/Users/...,~): usePath.home()or config. - Different Python and dependency versions: pin with a lock file and the same Python version (or run tests in the same container image locally).
- BSD vs GNU tools in
subprocesscalls (sed -idiffers).
Why → Most "works on my machine" bugs are one of these five.
Interview tip → Suggest running tests in the same Docker image locally and in CI.
More on Automation scripting & CLI design
Your team has a 300-line Bash script that parses JSON with `jq`, loops over AWS accounts and retries with `sleep`. It breaks every month. Do you rewrite it in Python?BeginnerA colleague's script deletes files older than 30 days from `/var/log/app`. You are asked to review it before it goes into cron. What do you look for?IntermediateYou need a script that ops engineers run from laptops and that CI runs nightly. How do you design its interface?IntermediateA script reads a 15 GB access log to count 5xx errors per endpoint, and the box runs out of memory. How do you fix it?BeginnerYou must run the same Python automation on 40 servers that have Python 3.6, 3.9 and 3.12. What do you do?IntermediateA cron job that runs a Python script fails silently. Nobody noticed for two weeks. How do you make sure that never happens again?Intermediate