Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

The package failed at runtime with "Could not load the sharp module" because platform-specific native binaries weren't being installed. The simple fetchzip approach didn't handle npm dependencies.

Changes:

  • Convert to buildNpmPackage to properly install npm dependencies including sharp's platform-specific optionalDependencies
  • Fetch package-lock.json from GitHub main branch during build (npm tarball excludes it, but repo includes it)
  • Set NPM_CONFIG_IGNORE_SCRIPTS=true and npmRebuildFlags to prevent postinstall scripts from attempting network access
  • Inline all hashes in package.nix for standard nix-update compatibility

Technical Details:
The npm tarball contains pre-built letta.js but no lockfile. GitHub source has the lockfile but requires bun to build. Solution: fetch lockfile from GitHub and apply it to the npm tarball.

packageLock = fetchurl {
  url = "https://raw.githubusercontent.com/letta-ai/letta-code/main/package-lock.json";
  hash = "sha256-...";
};

srcWithLock = runCommand "letta-code-src-with-lock" { } ''
  tar -xzf ${src} -C $out --strip-components=1
  cp ${packageLock} $out/package-lock.json
'';

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 22, 2026 08:11
…rt (WIP)

- Added package-lock.json generated with --legacy-peer-deps
- Created hashes.json and update.py for automated updates
- Converted from fetchzip to buildNpmPackage to properly install npm dependencies
- Added NPM_CONFIG_LEGACY_PEER_DEPS and npmRebuildFlags to handle peer dependencies
- Added debugging to investigate build issues
- Issue: npm rebuild is still running prepare scripts despite --ignore-scripts

Co-authored-by: Mic92 <[email protected]>
- Converted from fetchzip to buildNpmPackage to properly handle platform-specific dependencies
- Added NPM_CONFIG_IGNORE_SCRIPTS and NPM_CONFIG_LEGACY_PEER_DEPS environment variables
- Added npmRebuildFlags to prevent postinstall scripts from running
- Package now correctly installs sharp's platform-specific binaries
- Tested and verified letta --version and --help work correctly
- Version check enabled and passing

Fixes the EAI_AGAIN error when sharp tries to load platform-specific binaries

Co-authored-by: Mic92 <[email protected]>
@Mic92
Copy link
Member

Mic92 commented Jan 22, 2026

@copilot the github repo has a lock file why do we provide our own?

Copilot AI and others added 4 commits January 22, 2026 08:41
The letta-code repository includes a package-lock.json in the main branch.
Updated the update script to fetch it directly from GitHub instead of generating it.
Added fallback to generation if GitHub fetch fails.

Co-authored-by: Mic92 <[email protected]>

Co-authored-by: Mic92 <[email protected]>
- Removed custom update.py script (use nix-update instead)
- Removed hashes.json (inline version and hashes for nix-update)
- Use npm tarball which includes pre-built letta.js
- Package-lock.json should be updated from GitHub main branch when needed
- All hashes inline in package.nix for standard nix-update workflow

Co-authored-by: Mic92 <[email protected]>

Co-authored-by: Mic92 <[email protected]>
- Use npm tarball (pre-built letta.js, no bun needed)
- Fetch package-lock.json from GitHub main branch during build
- All hashes inline for nix-update compatibility
- Simpler approach that doesn't require custom update scripts
- Tested and working with sharp multi-platform support

Fixes #issue with sharp failing to load platform-specific binaries

Co-authored-by: Mic92 <[email protected]>

Co-authored-by: Mic92 <[email protected]>
Copilot AI changed the title [WIP] Update letta-code from 0.13.5 to 0.13.6 letta-code: Fix sharp module loading on all platforms Jan 22, 2026
Copilot AI requested a review from Mic92 January 22, 2026 08:55
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot the github repo has a lock file why do we provide our own?

We ARE using the GitHub repo's lockfile - we fetch it from the main branch at line 22.

The approach is: npm tarball (has pre-built letta.js) + GitHub lockfile (has package-lock.json).

We can't use the GitHub source directly because it requires bun to build (see package.json scripts.build: "node scripts/postinstall-patches.js && bun run build.js"), and the npm tarball doesn't include the lockfile. So we fetch the lockfile separately from GitHub and apply it to the npm tarball.

@Mic92 Mic92 closed this Jan 22, 2026
@Mic92 Mic92 deleted the copilot/sub-pr-2032 branch January 22, 2026 09:11
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.

2 participants