diff --git a/backend/windmill-worker/src/bun_executor.rs b/backend/windmill-worker/src/bun_executor.rs index 49819a41c5..900f16bd55 100644 --- a/backend/windmill-worker/src/bun_executor.rs +++ b/backend/windmill-worker/src/bun_executor.rs @@ -20,7 +20,7 @@ use crate::{ read_file_content, read_result, start_child_process, write_file_binary, OccupancyMetrics, }, handle_child::handle_child, - BUNFIG_INSTALL_SCOPES, BUN_BUNDLE_CACHE_DIR, BUN_CACHE_DIR, BUN_PATH, DISABLE_NSJAIL, + BUNFIG_INSTALL_SCOPES, BUN_BUNDLE_CACHE_DIR, BUN_CACHE_DIR, BUN_NO_CACHE, BUN_PATH, DISABLE_NSJAIL, DISABLE_NUSER, HOME_ENV, NODE_BIN_PATH, NODE_PATH, NPM_CONFIG_REGISTRY, NPM_PATH, NSJAIL_PATH, PATH_ENV, PROXY_ENVS, TZ_ENV, }; @@ -293,12 +293,21 @@ pub async fn install_bun_lockfile( occupancy_metrics: &mut Option<&mut OccupancyMetrics>, ) -> Result<()> { let mut child_cmd = Command::new(if npm_mode { &*NPM_PATH } else { &*BUN_PATH }); + + let mut args = vec!["install", "--save-text-lockfile"]; + + let no_cache = !npm_mode && *BUN_NO_CACHE; + + if no_cache { + args.push("--no-cache"); + } + child_cmd .current_dir(job_dir) .env_clear() .envs(PROXY_ENVS.clone()) .envs(common_bun_proc_envs) - .args(vec!["install", "--save-text-lockfile"]) + .args(args) .stdout(Stdio::piped()) .stderr(Stdio::piped()); @@ -307,6 +316,8 @@ pub async fn install_bun_lockfile( let mut npm_logs = if npm_mode { "NPM mode\n".to_string() + } else if no_cache { + "Bun install with --no-cache flag (BUN_NO_CACHE=true)\n".to_string() } else { "".to_string() }; @@ -339,7 +350,7 @@ pub async fn install_bun_lockfile( false }; - if npm_mode { + if npm_mode || no_cache { if let Some(db) = db { append_logs(&job_id.clone(), w_id, npm_logs, db).await; } @@ -1687,7 +1698,7 @@ BigInt.prototype.toJSON = function () {{ return this.toString(); }}; -console.log('start'); +console.log('start'); for await (const line of Readline.createInterface({{ input: process.stdin }})) {{ {print_lines} @@ -1696,7 +1707,7 @@ for await (const line of Readline.createInterface({{ input: process.stdin }})) { process.exit(0); }} try {{ - let {{ {spread} }} = JSON.parse(line) + let {{ {spread} }} = JSON.parse(line) {dates} let res = await Main.main(...[ {spread} ]); console.log("wm_res[success]:" + JSON.stringify(res ?? null, (key, value) => typeof value === 'undefined' ? null : value)); diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 7ca2d0d269..4ff474cbd2 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -328,6 +328,10 @@ lazy_static::lazy_static! { pub static ref NPM_CONFIG_REGISTRY: Arc>> = Arc::new(RwLock::new(None)); pub static ref BUNFIG_INSTALL_SCOPES: Arc>> = Arc::new(RwLock::new(None)); + pub static ref BUN_NO_CACHE: bool = std::env::var("BUN_NO_CACHE") + .ok() + .and_then(|x| x.parse::().ok()) + .unwrap_or(false); pub static ref NUGET_CONFIG: Arc>> = Arc::new(RwLock::new(None)); pub static ref MAVEN_REPOS: Arc>> = Arc::new(RwLock::new(None)); pub static ref NO_DEFAULT_MAVEN: AtomicBool = AtomicBool::new(std::env::var("NO_DEFAULT_MAVEN")