sinelaw/fresh · warning

Could not write install receipt:

Error message

Could not write install receipt:

What it means

Also in binary-install.js install(): after placing the binary, the code writes an install-receipt.toml into binDir with fs.writeFileSync; a failure is caught and logged as 'Could not write install receipt:'. Installation itself has succeeded — only the auxiliary receipt recording failed — so this is a non-fatal warning.

Solutions

  1. Fix write permissions on the bin directory (chown or install to a user-writable npm prefix).
  2. Free disk space if ENOSPC was reported in the wrapped error message.
  3. Re-run npm install to regenerate the receipt once the directory is writable.
  4. Ignore if the editor works — the receipt is auxiliary hint metadata, not required at runtime.

Example fix

// before: EACCES on /usr/local/bin
sudo npm install -g @fresh-editor/fresh-editor
// after (user prefix)
npm config set prefix ~/.npm-global && npm install -g @fresh-editor/fresh-editor
Defensive patterns

Strategy: try-catch

Validate before calling

const binDirStat = fs.statSync(binDir);
fs.accessSync(binDir, fs.constants.W_OK); // throws EACCES before install attempts the write

Try / catch

try { install(); } catch (e) { if (/EACCES|EPERM/.test(e.message)) { console.error('npm prefix not writable: fix with npm config set prefix'); process.exit(1); } throw e; }

Prevention

When it happens

Trigger: fs.writeFileSync(path.join(binDir, 'install-receipt.toml'), receipt) throws: binDir not writable, disk full, or binDir was removed between binary placement and receipt write.

Common situations: Global npm install without write permission to the global bin directory (needs sudo or a configured prefix); read-only container filesystems; EACCES/ENOSPC during postinstall.

Understand the failure class

Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.

Related errors


AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/1fc494a8794643bd. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-editor/npm-package/binary-install.js:171

    // Provenance receipt (sidecar next to the binary). Overrides the generic
    // `tarball` receipt that ships inside the archive so the editor defers
    // updates to npm rather than self-swapping.
    try {
        const receipt = [
            'schema = 1',
            'channel = "npm"',
            `version = "${VERSION}"`,
            'package_name = "fresh-editor"',
            'managed = true',
            'self_update = false',
            '',
            '[hints]',
            'npm_pkg = "@fresh-editor/fresh-editor"',
            '',
        ].join('\n');
        fs.writeFileSync(path.join(binDir, 'install-receipt.toml'), receipt);
    } catch (e) {
        console.warn('Could not write install receipt:', e.message);
    }

    console.log('fresh-editor installed successfully!');
}

module.exports = { install };

View on GitHub (pinned to 67894ca546)