From 650b46a368368140bade483ac1e4eba8d26efd29 Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Thu, 18 Dec 2025 15:55:21 -0500 Subject: [PATCH] Fix runtime initialization for missing StaticDir and VolumePath This commit fixes two issues in runtime initialization that occur when vendor code doesn't properly set StaticDir and VolumePath defaults: 1. Add defensive initialization for StaticDir and VolumePath - Check if StaticDir is empty and set it to GraphRoot/libpod - Check if VolumePath is empty and set it to GraphRoot/volumes - This works around missing initialization in older vendor code without requiring changes to the vendor directory 2. Fix database initialization to allow creating new bolt_state.db - Previously, getDBState() would fail if bolt_state.db didn't exist - Now, only return error if it's not os.ErrNotExist - This allows NewBoltState() to create the database on first run These changes resolve the "creating runtime static files directory: mkdir : no such file or directory" error that occurred when running podman commands. Tested with: - podman ps, info, version commands work correctly - Volume operations create volumes at correct path - Database is properly initialized on first run Signed-off-by: Lokesh Mandvekar --- libpod/runtime.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libpod/runtime.go b/libpod/runtime.go index 7de3a0171f..7a0e7d1693 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -319,10 +319,14 @@ func getDBState(runtime *Runtime) (State, error) { case config.DBBackendDefault: // for backwards compatibility check if boltdb exists, if it does not we use sqlite if _, err := os.Stat(boltDBPath); err != nil { - // Return error here some other problem with the boltdb file, rather than silently - // switch to sqlite which would be hard to debug for the user return the error back - // as this likely a real bug. - return nil, err + // Only return error if it's not a "file not found" error. + // If the file doesn't exist, we'll create it with NewBoltState. + if !errors.Is(err, os.ErrNotExist) { + // Return error here some other problem with the boltdb file, rather than silently + // switch to sqlite which would be hard to debug for the user return the error back + // as this likely a real bug. + return nil, err + } } runtime.config.Engine.DBBackend = config.DBBackendBoltDB.String() fallthrough @@ -352,6 +356,14 @@ func makeRuntime(runtime *Runtime) (retErr error) { return fmt.Errorf("cannot perform system reset while renumbering locks: %w", define.ErrInvalidArg) } + // Ensure StaticDir and VolumePath are set (defensive check for older vendor code) + if runtime.config.Engine.StaticDir == "" { + runtime.config.Engine.StaticDir = filepath.Join(runtime.storageConfig.GraphRoot, "libpod") + } + if runtime.config.Engine.VolumePath == "" { + runtime.config.Engine.VolumePath = filepath.Join(runtime.storageConfig.GraphRoot, "volumes") + } + // Make the static files directory if it does not exist if err := os.MkdirAll(runtime.config.Engine.StaticDir, 0700); err != nil { // The directory is allowed to exist