{"record":{"id":"382c9c48dbc4c685","repo":"denoland/deno","slug":"unable-to-construct-url-from-the-path-of-cwd","errorCode":null,"errorMessage":"Unable to construct URL from the path of cwd: {}","messagePattern":"Unable to construct URL from the path of cwd: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/jupyter/mod.rs","lineNumber":206,"sourceCode":"    .map_err(|_| anyhow!(\"REPL thread failed to start\"))?;\n\n  // --- Create the ZMQ kernel worker on the main thread ---------------\n  let kernel_main_module = resolve_url_or_path(\n    \"./$deno$jupyter_kernel.mts\",\n    cli_options.initial_cwd(),\n  )\n  .unwrap();\n\n  let (worker2, _) = create_single_test_event_channel();\n  let TestEventWorkerSender {\n    sender: _test_sender2,\n    stdout: stdout2,\n    stderr: stderr2,\n  } = worker2;\n\n  let cwd_url =\n    Url::from_directory_path(cli_options.initial_cwd()).map_err(|_| {\n      anyhow!(\n        \"Unable to construct URL from the path of cwd: {}\",\n        cli_options.initial_cwd().to_string_lossy(),\n      )\n    })?;\n  let _ = cwd_url; // used later for test reporter if needed\n\n  let mut kernel_worker = worker_factory\n    .create_custom_worker(\n      WorkerExecutionMode::Jupyter,\n      kernel_main_module,\n      vec![],\n      vec![],\n      permissions,\n      vec![ops::jupyter::deno_jupyter_kernel::init()],\n      Stdio {\n        stdin: StdioPipe::inherit(),\n        stdout: StdioPipe::file(stdout2),\n        stderr: StdioPipe::file(stderr2),","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/jupyter/mod.rs#L188-L224","documentation":"`deno jupyter` builds a file:// URL from the process working directory using Url::from_directory_path, which only accepts absolute paths (and on Windows, well-formed drive/UNC paths). If the resolved initial cwd is relative or not representable as a directory URL, the kernel aborts with this message before creating the kernel worker.","triggerScenarios":"`deno jupyter` launched with a relative or malformed working directory: callers spawning deno with a relative cwd string, a stale $PWD after directory moves, or (on Windows) a cwd that is not a proper drive/UNC path.","commonSituations":"Editor/plugin integrations spawning deno with cwd like '.' or 'proj'; wrappers after cd-ing through deleted/symlinked directories; tools that pass a custom relative cwd to child processes.","solutions":["Launch deno jupyter from a stable absolute directory (verify with pwd -P first)","Fix the caller: pass an absolute cwd when spawning the deno process","On Windows, ensure the cwd is a normal drive path (like C:/projects/app)","Re-sync PWD with reality (cd \"$(pwd)\") before starting the kernel"],"exampleFix":"// before\nspawn('deno', ['jupyter'], { cwd: 'proj' }); // relative\n// after\nspawn('deno', ['jupyter'], { cwd: path.resolve('proj') });","handlingStrategy":"validation","validationCode":"# bash: ensure an absolute, in-sync cwd before starting the kernel\ncd \"$(pwd -P)\" || exit 2\ncase \"$PWD\" in\n  /*) deno jupyter kernel ;;\n  *) echo \"cwd is not absolute: $PWD\" >&2; exit 2 ;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always spawn deno with an absolute cwd (path.resolve) from editors and tools","Re-sync PWD after directory moves before launching long-lived processes"],"tags":["jupyter","url","cwd","windows","filesystem"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}