Your File Paths Work by Accident?

LearnThatStack · Beginner ·🚀 Entrepreneurship & Startups ·1mo ago
Your script works perfectly. You run it from a different folder. FileNotFoundError. Nothing changed except where you ran it from. This video explains this common but confusing bug and its fix: the working directory. You'll learn why relative paths don't resolve from your script's location (a common misconception), where the working directory comes from, and how to write paths that work everywhere - locally, in cron jobs, Docker containers, and CI pipelines. Timestamps: 0:00 Intro - The Bug 0:41 Absolute vs Relative Paths 1:32 The Actual Rule (cwd) 2:33 Seeing It Clearly 2:59 Where This Bites…
Watch on YouTube ↗ (saves to browser)

Chapters (8)

Intro - The Bug
0:41 Absolute vs Relative Paths
1:32 The Actual Rule (cwd)
2:33 Seeing It Clearly
2:59 Where This Bites You (Cron, Docker, CI, IDEs)
5:38 How To Debug Path Errors
6:04 The Fixes (__file__, __dirname, env vars)
8:31 The Mental Model
Even if it’s tougher in the short term it will lead to a lot more long term happiness :)
Next Up
Even if it’s tougher in the short term it will lead to a lot more long term happiness :)
GaryVee