diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index 0cc7d4e7f97797..484a5924a9d21a 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -9,7 +9,7 @@ use clap::{ use clap_complete::{generate, Shell}; pub use error::Error; use serde::{Deserialize, Serialize}; -use tracing::{debug, error, warn}; +use tracing::{debug, error}; use turbopath::AbsoluteSystemPathBuf; use turborepo_api_client::AnonAPIClient; use turborepo_repository::inference::{RepoMode, RepoState}; diff --git a/crates/turborepo-lib/src/config.rs b/crates/turborepo-lib/src/config.rs index c3419a53733f06..1d497545d047fe 100644 --- a/crates/turborepo-lib/src/config.rs +++ b/crates/turborepo-lib/src/config.rs @@ -103,6 +103,14 @@ pub enum Error { #[source_code] text: NamedSource, }, + #[error("`{field}` cannot contain an environment variable")] + InvalidDependsOnValue { + field: &'static str, + #[label("environment variable found here")] + span: Option, + #[source_code] + text: NamedSource, + }, #[error("`{field}` cannot contain an absolute path")] AbsolutePathInConfig { field: &'static str, diff --git a/crates/turborepo-lib/src/turbo_json/mod.rs b/crates/turborepo-lib/src/turbo_json/mod.rs index 5fafc25b0ba912..53c5a671b4e60d 100644 --- a/crates/turborepo-lib/src/turbo_json/mod.rs +++ b/crates/turborepo-lib/src/turbo_json/mod.rs @@ -292,22 +292,21 @@ impl TryFrom for TaskDefinition { let mut task_dependencies: Vec> = Vec::new(); if let Some(depends_on) = raw_task.depends_on { for dependency in depends_on.into_inner() { - let (dependency, span) = dependency.split(); + let (span, text) = dependency.span_and_text("turbo.json"); + let (dependency, depspan) = dependency.split(); let dependency: String = dependency.into(); - if let Some(dependency) = dependency.strip_prefix(ENV_PIPELINE_DELIMITER) { - println!( - "[DEPRECATED] Declaring an environment variable in \"dependsOn\" is \ - deprecated, found {}. Use the \"env\" key or use `npx @turbo/codemod \ - migrate-env-var-dependencies`.\n", - dependency - ); - env_var_dependencies.insert(dependency.to_string()); + if let Some(_) = dependency.strip_prefix(ENV_PIPELINE_DELIMITER) { + return Err(Error::InvalidDependsOnValue { + field: "dependsOn", + span, + text, + }); } else if let Some(topo_dependency) = dependency.strip_prefix(TOPOLOGICAL_PIPELINE_DELIMITER) { - topological_dependencies.push(span.to(topo_dependency.to_string().into())); + topological_dependencies.push(depspan.to(topo_dependency.to_string().into())); } else { - task_dependencies.push(span.to(dependency.into())); + task_dependencies.push(depspan.to(dependency.into())); } } } @@ -465,25 +464,21 @@ impl TryFrom for TurboJson { } for global_dep in raw_turbo.global_dependencies.into_iter().flatten() { - if let Some(env_var) = global_dep.strip_prefix(ENV_PIPELINE_DELIMITER) { - println!( - "[DEPRECATED] Declaring an environment variable in \"dependsOn\" is \ - deprecated, found {}. Use the \"env\" key or use `npx @turbo/codemod \ - migrate-env-var-dependencies`.\n", - env_var - ); - - global_env.insert(env_var.to_string()); + if let Some(_) = global_dep.strip_prefix(ENV_PIPELINE_DELIMITER) { + let (span, text) = global_dep.span_and_text("turbo.json"); + return Err(Error::InvalidDependsOnValue { + field: "globalDependencies", + span, + text, + }); + } else if Utf8Path::new(&global_dep.value).is_absolute() { + let (span, text) = global_dep.span_and_text("turbo.json"); + return Err(Error::AbsolutePathInConfig { + field: "globalDependencies", + span, + text, + }); } else { - if Utf8Path::new(&global_dep.value).is_absolute() { - let (span, text) = global_dep.span_and_text("turbo.json"); - return Err(Error::AbsolutePathInConfig { - field: "globalDependencies", - span, - text, - }); - } - global_file_dependencies.insert(global_dep.into_inner().into()); } }