Deployment fails: "Cannot create code snapshot" - No logs generated
janfredrik
PROOP

6 months ago

Deployment immediately fails with "Cannot create code snapshot right now" error. No build/deploy logs are generated, making debugging

impossible.

- Description of the issue:

Pushing to GitHub triggers deployment failure before any build process starts. The error appears instantly without executing any configuration

files (nixpacks.toml, railway.toml, Procfile).

- Error messages:

"Cannot create code snapshot right now, please review your last commit or try again"

If this error persists, please reach out to the Railway team.

- Logs:

NO LOGS ARE GENERATED - deployment fails before logging begins

- GitHub repo:

Private monorepo structure:

- pnpm workspace with Turbo

- /apps/api (main service)

- /packages/* (shared code)

- Multiple config attempts: nixpacks.toml, railway.toml, Procfile, package.json scripts with debug output

Tried: Node 18/20, pnpm 8/9/10, various nixpacks configurations. Issue occurs during Railway's initial snapshot phase before any user code runs.

Latest commit adds extensive debug logging but none appears, confirming failure happens during Railway's repo analysis, not during build.

Solved

2 Replies

Railway
BOT

6 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


janfredrik
PROOP

6 months ago

Resolution Summary

Root Cause Identified: The .railwayignore file was excluding pnpm-lock.yaml, which prevented Railway from creating the code snapshot.

The Problem

Railway requires the lockfile (pnpm-lock.yaml) to analyze the dependency structure of pnpm workspace/monorepo projects. Without this critical

file, Railway's snapshot creation phase failed immediately - before any build process could start, which explains why no logs were generated.

The Solution

1. Primary fix: Removed pnpm-lock.yaml from .railwayignore

2. Secondary fix: Corrected restartPolicyType format from on-failure to ON_FAILURE (uppercase required)

Key Learning

For pnpm-based monorepos, the lockfile is essential for Railway's initial project analysis. The error message "Cannot create code snapshot" was

misleading as it didn't indicate the actual issue - a missing dependency lockfile.

Current Status

white_check_mark emoji Deployment now works successfully with minimal configuration:

- railway.toml with basic build/deploy settings

- nixpacks.toml specifying Node.js 18 and pnpm 9

- .railwayignore properly configured (keeping pnpm-lock.yaml)

The issue was a configuration error on our end, not a Railway platform issue. Thank you for the guidance to use the CLI with --verbose flag,

which helped identify the configuration problem.


Status changed to Solved janfredrik 6 months ago


Loading...