diesel-rs/diesel · error
Failed to receive migrations dir from
Error message
Failed to receive migrations dir from {migrations_path_opt:?} What it means
The migration embedding macro could not resolve a migrations directory from the given or default path. The offending input is the migration path option; the directory lookup failed before any migration file was read.
Solutions
- Pass an explicit, valid migrations directory path
- Ensure the default migrations directory exists and is readable
- Check the path spelling and remove stray quotes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at diesel_migrations/migrations_macros/src/embed_migrations.rs:16 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/6482c93697ac08ca.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_migrations/migrations_macros/src/embed_migrations.rs:16
use crate::migrations::migration_directory_from_given_path;
use migrations_internals::{TomlMetadata, migrations_directories, version_from_string};
use quote::quote;
use std::error::Error;
use std::fs::DirEntry;
use std::path::Path;
pub fn expand(path: String) -> proc_macro2::TokenStream {
let migrations_path_opt = if path.is_empty() {
None
} else {
Some(path.replace('"', ""))
};
let migrations_expr = migration_directory_from_given_path(migrations_path_opt.as_deref())
.unwrap_or_else(|_| {
panic!("Failed to receive migrations dir from {migrations_path_opt:?}")
});
let embedded_migrations =
migration_literals_from_path(&migrations_expr).expect("Failed to read migration literals");
quote! {
diesel_migrations::EmbeddedMigrations::new(&[#(#embedded_migrations,)*])
}
}
fn migration_literals_from_path(
path: &Path,
) -> Result<Vec<proc_macro2::TokenStream>, Box<dyn Error>> {
let mut migrations = migrations_directories(path)?.collect::<Result<Vec<_>, _>>()?;
migrations.sort_by_key(DirEntry::path);
Ok(migrations
.into_iter()View on GitHub (pinned to 6fa6ed01b2)