Skip to content

fix: terminal sessions auto-heal stale ArcGISProTemp scratch workspace#21

Open
danmaps wants to merge 1 commit intomainfrom
fix/arcpy-scratch-workspace
Open

fix: terminal sessions auto-heal stale ArcGISProTemp scratch workspace#21
danmaps wants to merge 1 commit intomainfrom
fix/arcpy-scratch-workspace

Conversation

@danmaps
Copy link
Owner

@danmaps danmaps commented Feb 13, 2026

Closes #4.

What

  • Terminal launcher now writes a small .arcgispro/sitecustomize.py hook into the project.
  • Terminal launcher sets:
    • ARCGISPRO_PROJECT_DIR (quoted)
    • PYTHONPATH to include <project>\.arcgispro so sitecustomize.py auto-runs for any Python process started from the terminal.

Why

ArcGIS Pro creates session temp dirs like ArcGISProTemp<PID>. When those get cleaned up, stale arcpy.env.workspace / scratchWorkspace references can cause:
Directory does not exist or cannot be accessed: ...ArcGISProTemp####.

How it works

On Python startup (only when launched from the Pro terminal):

  • If arcpy isn't available, do nothing.
  • If workspace or scratchWorkspace points at a missing ArcGISProTemp* path, clear it.
  • Prefer <project>/scratch.gdb (create if missing) as a stable scratch/workspace.

Notes

  • Hook is defensive + silent; it should never crash Python startup or block user scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArcGIS Pro Temporary Directory Errors Break Python Script Execution

1 participant