Interview Prep/Python for DevOps/Automation scripting & CLI design

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 →

  1. Case sensitivity: macOS's filesystem is case-insensitive by default; import Config vs config.py works on Mac and fails on Linux.
  2. Encoding: always pass encoding="utf-8"; CI containers may have no locale set.
  3. Hardcoded paths (/Users/..., ~): use Path.home() or config.
  4. Different Python and dependency versions: pin with a lock file and the same Python version (or run tests in the same container image locally).
  5. BSD vs GNU tools in subprocess calls (sed -i differs).

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.

All Python for DevOps questions Roadmap: Python for automation

More on Automation scripting & CLI design