pulumi/pulumi · error
could not start CPU profile: %w
Error message
could not start CPU profile: %w
What it means
InitProfiling wraps failures from either creating the CPU profile output file or starting pprof.StartCPUProfile. Both the file-create error and the pprof start error share this message, prefixed with the given prefix and PID.
Source
Thrown at sdk/go/common/util/cmdutil/profile.go:31
// limitations under the License.
package cmdutil
import (
"fmt"
"os"
"runtime"
"runtime/pprof"
"runtime/trace"
"time"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)
func InitProfiling(prefix string, memProfileRate int) error {
cpu, err := os.Create(fmt.Sprintf("%s.%v.cpu", prefix, os.Getpid()))
if err != nil {
return fmt.Errorf("could not start CPU profile: %w", err)
}
if err = pprof.StartCPUProfile(cpu); err != nil {
return fmt.Errorf("could not start CPU profile: %w", err)
}
exec, err := os.Create(fmt.Sprintf("%s.%v.trace", prefix, os.Getpid()))
if err != nil {
return fmt.Errorf("could not start execution trace: %w", err)
}
if err = trace.Start(exec); err != nil {
return fmt.Errorf("could not start execution trace: %w", err)
}
if memProfileRate > 0 {
runtime.MemProfileRate = memProfileRate
go memoryProfileWriteLoop(prefix)
}
View on GitHub (pinned to 793f7b2e16)
Solutions
- Ensure the profiling output prefix points to an existing writable directory (e.g. /tmp)
- Check disk space and file permissions for the profile file location
- Disable profiling (unset the profiling env/flag) if you don't need it
- Verify only one InitProfiling call per process lifetime
Example fix
// before PULUMI_PROFILE_PREFIX=/nonexistent/dir/pulumi // after PULUMI_PROFILE_PREFIX=/tmp/pulumi
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure profile output location is writable before enabling profiling
if err := os.MkdirAll(profDir, 0o755); err != nil { return err }
if f, err := os.CreateTemp(profDir, "prof-check"); err != nil { return err } else { f.Close(); os.Remove(f.Name()) } Try / catch
if err := cmdutil.InitProfiling(prefix, memProfileRate); err != nil {
// profiling is best-effort: log and continue without profiling
log.Printf("profiling disabled: %v", err)
} Prevention
- Point profiling output at a writable directory like /tmp
- Check free disk space before enabling profiling
- Enable profiling only once per process
- Disable profiling when not debugging
When it happens
Trigger: Running the CLI with profiling enabled (e.g. PULUMI_SKIP_AUTOMATION... / profiling flags or env enabling InitProfiling) where the <prefix>.<pid>.cpu file cannot be created (bad path, read-only dir, permissions) or a CPU profile is already running in-process.
Common situations: Profiling output directory doesn't exist or is not writable; running as a user without write permission to prefix location; nested/second call to StartCPUProfile within the same process; disk full.
Related errors
- parse input file: %w
- resolve pulumi home: %w
- invalid --approval-mode %q: expected one of manual, balanced
- invalid --permission-mode %q: expected one of default, read-
- parsing CLI version %q: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/64edc9ef6e035c3c.
Report an issue: GitHub.