BoundaryML/baml · error
Failed to compute relative path from
Error message
Failed to compute relative path from {} to {} What it means
BAML CLI deployment computes a path relative to the baml_src directory using pathdiff. When the two paths cannot be related (e.g. differing path components/windows prefixes that make a relative path impossible), it throws this error instead of producing a bogus path.
Solutions
- Run the deploy command with paths on the same drive/filesystem as the baml_src directory
- Pass an absolute path that shares a common ancestor with baml_src
- Remove symlinks/mounts between the target path and baml_src and use the real path
- On Windows, ensure both paths use the same drive letter
Example fix
// before baml deploy --from D:\other\project // after baml deploy --from C:\work\my-project # same drive as baml_src
Defensive patterns
Strategy: validation
Validate before calling
fn is_deployable(path: &Path, baml_src: &Path) -> bool {
pathdiff::diff_paths(path, baml_src).is_some()
} Try / catch
match relative_path_to_baml_src(&p, &src) {
Ok(rel) => use(rel),
Err(e) => eprintln!("Cannot make path relative to baml_src: {e:#}"),
} Prevention
- Use absolute paths on the same drive/filesystem as baml_src
- Avoid symlinks across mounts for the BAML project directory
- Test deploy commands on Windows with same-drive paths
When it happens
Trigger: Calling deploy (relative_path_to_baml_src via deploy_project_no_progress_spinner) with a path argument that is not on the same filesystem root/prefix as the resolved baml_src directory, such as passing an absolute Windows path with a different drive, or a path that is not under/related to the project root.
Common situations: Running `baml deploy` from a different drive (C:\ vs D:\ on Windows), symlinking the baml_src directory across mounts, or passing an --from path outside the project tree.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- BAML project already exists
- cannot determine directory of current executable
- ` ` doesn't look like it belongs to a BAML project — no…
- Expected --from ' ' to be a baml_src/ directory, but it…
- Expected --from ' ' to be a baml_src/ directory, but it is…
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/c11939f3fe89a80f.
Report an issue: GitHub.
Appendix: source
Thrown at engine/cli/src/deploy.rs:44
// Constants (replace with actual values as needed)
#[derive(clap::Args, Debug)]
pub struct DeployArgs {
#[arg(long, help = "path/to/baml_src", default_value = "./baml_src")]
pub(super) from: PathBuf,
#[arg(
long,
env = "NEXT_PUBLIC_BOUNDARY_API_URL",
default_value = "https://api2.boundaryml.com",
hide = true
)]
pub(super) api_url: String,
}
fn relative_path_to_baml_src(path: &Path, baml_src: &Path) -> Result<PathBuf> {
pathdiff::diff_paths(path, baml_src).ok_or_else(|| {
anyhow::anyhow!(
"Failed to compute relative path from {} to {}",
path.display(),
baml_src.display()
)
})
}
impl DeployArgs {
/// Implementation notes:
///
/// - selected dialoguer / indicatif based on https://fadeevab.com/comparison-of-rust-cli-prompts/
pub async fn run_async(
&self,
feature_flags: internal_baml_core::feature_flags::FeatureFlags,
) -> Result<()> {
let runtime =
BamlRuntime::from_directory(&self.from, std::env::vars().collect(), feature_flags)
.context("Failed to build BAML runtime")?;View on GitHub (pinned to bd85ce9dee)