Repository navigation
Description
Verified against: PlatformIO Core 6.1.19, PlatformIO IDE for VSCode 3.3.4, macOS 26.5.2
Summary
On macOS, get_default_projects_dir() unconditionally resolves to
~/Documents/PlatformIO/Projects. When a user has iCloud Drive's
"Desktop & Documents Folders" enabled — an option macOS actively prompts for during setup —
that directory is managed by fileproviderd. PlatformIO then writes .pio/ build trees,
hundreds of MB of churn per rebuild, into a live sync target. This produces build and
toolchain failures that are hard to attribute, because the sync daemon acts after the
operation reports success.
platformio/project/helpers.py:
def get_default_projects_dir():
docs_dir = os.path.join(fs.expanduser("~"), "Documents")
try:
assert IS_WINDOWS
...
except:
if not IS_MACOS:
try:
docs_dir = subprocess.check_output(["xdg-user-dir", "DOCUMENTS"]) ...macOS is the one platform with no path to a different answer: the Windows branch is behind
assert IS_WINDOWS, and the xdg-user-dir branch is explicitly excluded by if not IS_MACOS.
Impact observed
An ESP32 project living at the default location hit three independent failure classes, all
traced to FileProvider and all resolved by moving the repo out of ~/Documents:
- Code signing broken by xattr churn — FileProvider re-stamps extended attributes faster
than they can be cleared, so signing an artifact built in-tree fails intermittently. - Duplicate symbols at link time — iCloud conflict copies (
provision 2.cppbeside
provision.cpp) are picked up bybuild_src_filterglobs and compiled as real sources. managed_componentseviction races — the component manager failed with
"CHANGELOG.md missing" andrmtree: Directory not emptythree times in one night while
iCloud evicted and re-materialised that directory mid-build.
Plus the silent cost: every hybrid rebuild pushes hundreds of MB of .pio churn through the
user's iCloud quota and uplink.
Why the existing mitigations do not cover this
platformio-core#4497(OneDrive, closed in 6.1.7) hardened.pio/buildremoval. That is
the symptom; the default location is the cause, and it is still cloud-synced.- The setting is changeable —
pio settings set projects_dir <path>— but there is no UI
for it anywhere. PIO Home readscoreSettingsand cannot write them:AppRPC.load_state
rebuilds them per call and setsstate.modified = False, the frontend deletes
storage.coreSettingsbeforeapp.save_state, and no settings-write RPC handler exists.
The VSCode extension contributes no corresponding configuration key either. So a user who
hits this must discover a CLI command that the GUI never mentions — which is consistent
with the number of forum threads asking exactly this question.
Suggested fix
Any one of these would close it; they are listed cheapest-first.
- Detect and avoid. On macOS, check whether
~/Documentsis under FileProvider
management before using it as the default, and fall back to~/PlatformIO/Projects.
A cheap signal is the presence of~/Library/Mobile Documents/com~apple~CloudDocsplus
~/Documentsresolving into the FileProvider tree. - Change the macOS default outright to
~/PlatformIO/Projects(or
~/Library/Application Support/PlatformIO/Projects). Existing installs are unaffected —
they carry an explicit value inappstate.json. - At minimum, warn once. If a build's project path is inside a synced directory, emit a
one-line warning naming the risk and thepio settings set projects_dircommand. This
alone would have saved the debugging described above.
Additionally, surfacing projects_dir in PIO Home's UI would make (3) actionable at the
moment the user reads it.
Workaround for anyone who finds this issue
pio settings set projects_dir ~/YourProjects # persists in ~/.platformio/appstate.json
export PLATFORMIO_SETTING_PROJECTS_DIR=~/YourProjects # wins over the above; survives a settings resetNote the env var is PLATFORMIO_SETTING_<NAME>, not PLATFORMIO_<NAME>. The path must
already exist — projects_dir_validate asserts os.path.isdir on every read.
Activity
ivankravets commentedon Sep 5, 2026
Duplicate of #2872
sashatury commentedon Sep 5, 2026
Thanks for triaging. I'd like to ask you to reconsider the duplicate — #2872 is about a different setting.
#2872 asks for
core_dir(~/.platformio) to follow the XDG base directory spec, and its stated workaround isPLATFORMIO_CORE_DIR. This report is aboutprojects_dir: a different value, resolved by a different function, andPLATFORMIO_CORE_DIRdoes not move it.get_core_dir()→~/.platformio— Use XDG_CONFIG_HOME for .platformio directory #2872get_default_projects_dir()→~/Documents/PlatformIO/Projects— this issueThey also differ in kind. #2872 is a tidiness request ("this makes things neater for the user"). This one is about correctness: on macOS the default lands inside a directory that iCloud Drive manages whenever "Desktop & Documents Folders" is enabled — an option macOS prompts for during setup — and
fileproviderdmutates that tree after PlatformIO's operations report success. The three failure classes in the report — xattr churn breaking code signing, iCloud conflict copies (provision 2.cpp) picked up bybuild_src_filterglobs and compiled as real sources, andmanaged_componentseviction races — are all inprojects_dir, and none of them is affected by relocating.platformio.If changing the macOS default is out of scope, that is a fair call. But suggestion (3) stands on its own and is cheap: warn once when the project path is inside a FileProvider-managed directory, naming
pio settings set projects_dir. Today that setting exists but is unreachable from any GUI — PIO Home cannot write core settings and the VSCode extension contributes no key for it — so a user who hits this has no route to the fix other than finding this issue.Could you reopen it, or close it on its own merits? Either would be more useful to the next person searching for this than a pointer to an XDG request.
ivankravets commentedon Sep 5, 2026
Agree, sorry.