github/copilot-sdk · error

writing license file

Error message

writing license file: %w

What it means

After installing the CLI binary, installAt writes config.License to finalPath+".license" via os.WriteFile. If that write fails, the error is wrapped as "writing license file". The binary itself is already installed; only the sidecar license file is missing.

Solutions

  1. Check free disk space and directory write permissions
  2. Remove any conflicting file or directory at finalPath+".license"
  3. Re-run install after clearing the blocker — the binary does not need reinstalling if already correct
  4. Verify no antivirus/EDR policy blocks creation of .license files

Example fix

// before
// license write fails silently blocking install
// after
licPath := finalPath + ".license"
if fi, err := os.Lstat(licPath); err == nil && fi.IsDir() {
    os.RemoveAll(licPath) // clear conflicting entry before install
}
Defensive patterns

Strategy: try-catch

Validate before calling

licPath := finalPath + ".license"
if fi, err := os.Lstat(licPath); err == nil && fi.IsDir() {
    os.RemoveAll(licPath)
}
if err := unix.Access(filepath.Dir(licPath), unix.W_OK); err != nil { return err }

Try / catch

_, err := embeddedcli.Install(ctx, cfg)
if err != nil && strings.Contains(err.Error(), "writing license file") {
    return fmt.Errorf("license sidecar could not be written; check disk space and %s.lock conflicts", finalPath)
}

Prevention

When it happens

Trigger: os.WriteFile(licensePath, config.License, 0644) fails because the install directory became unwritable, disk filled between the two writes, or a directory named finalPath+".license" exists at that path.

Common situations: Disk-full race between binary and license writes; security software blocking creation of the .license sidecar; a conflicting directory/file already named *.license.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/480b38bb6df43a86. Report an issue: GitHub.

Appendix: source

Thrown at go/internal/embeddedcli/embeddedcli.go:304

	f, err := os.OpenFile(finalPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
	if err != nil {
		return "", fmt.Errorf("creating binary file: %w", err)
	}
	_, err = io.Copy(f, config.Cli)
	if err1 := f.Close(); err1 != nil && err == nil {
		err = err1
	}
	if closer, ok := config.Cli.(io.Closer); ok {
		closer.Close()
	}
	if err != nil {
		return "", fmt.Errorf("writing binary file: %w", err)
	}
	if len(config.License) > 0 {
		licensePath := finalPath + ".license"
		if err := os.WriteFile(licensePath, config.License, 0644); err != nil {
			return "", fmt.Errorf("writing license file: %w", err)
		}
	}

	if config.RuntimeExecutable != nil {
		path, err := installRuntimePair(installDir)
		if err != nil {
			return "", err
		}
		runtimePath = path
	}

	// Install the native in-process runtime library (if bundled) next to the CLI.
	// Fail closed on any hash mismatch; never place unverified native code.
	if config.RuntimeLib != nil {
		libPath, err := installRuntimeLib(installDir)
		if err != nil {
			return "", err
		}

View on GitHub (pinned to cd8cf15dc3)