{"record":{"id":"c166b1aa07fa6d37","repo":"sxyazi/yazi","slug":"failed-to-join-new-name-with-cwd","errorCode":null,"errorMessage":"Failed to join new name with CWD","messagePattern":"Failed to join new name with CWD","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-actor/src/mgr/create.rs","lineNumber":40,"sourceCode":"\n\tfn act(cx: &mut Ctx, CreateForm { target, dir, force }: Self::Form) -> Result<Data> {\n\t\tlet cwd = cx.cwd().to_owned();\n\n\t\tlet mut target: Pin<Box<dyn Stream<Item = StrandBuf> + Send>> = if target.is_empty() {\n\t\t\tlet input = input!(cx, YAZI.input.create(dir))?;\n\t\t\tBox::pin(UnboundedReceiverStream::new(input).filter_map(|event| event.map(Into::into)))\n\t\t} else {\n\t\t\tBox::pin(tokio_stream::iter(vec![target]))\n\t\t};\n\n\t\ttokio::spawn(async move {\n\t\t\tlet Some(name) = target.next().await else { return Ok(()) };\n\t\t\tif name.is_empty() {\n\t\t\t\treturn Ok(());\n\t\t\t}\n\n\t\t\tlet Ok(new) = cwd.try_join(&name) else {\n\t\t\t\tbail!(\"Failed to join new name with CWD\");\n\t\t\t};\n\n\t\t\tif !force\n\t\t\t\t&& let Some(file) = File::maybe_new(&new).await?\n\t\t\t\t&& !ConfirmProxy::show(ConfirmCfg::overwrite(&file)).await\n\t\t\t{\n\t\t\t\treturn Ok(());\n\t\t\t}\n\n\t\t\tlet end_sep = AnyAsciiChar::SEP.predicate(*name.encoded_bytes().last().unwrap());\n\t\t\tSelf::r#do(new, dir || end_sep).await\n\t\t});\n\t\tsucc!();\n\t}\n}\n\nimpl Create {\n\tasync fn r#do(new: UrlBuf, dir: bool) -> Result<()> {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/sxyazi/yazi/blob/a541adde4e5b082719a0f21a87eb3eab071ece58/yazi-actor/src/mgr/create.rs#L22-L58","documentation":"When creating a new file/directory, the manager takes the typed name and joins it with the current working directory via `cwd.try_join(&name)`. If the join fails (e.g. the name is not a valid relative path tail for the URL), the creation bails with this message, meaning the requested name cannot form a valid child URL of the CWD.","triggerScenarios":"Running the `create` command with a name that fails `try_join` against the CWD URL — e.g. a name containing path separators, `..`, or characters that are invalid as a single path component, or creating in a URL whose scheme cannot host the name.","commonSituations":"Typing a full path or slashes into the create prompt when only a component is allowed; creating inside a virtual/archive/remote location that doesn't support joining; weird characters in the name.","solutions":["Enter a single path component (no leading `/`, no `..`) in the create prompt.","Create the item inside a normal local directory rather than a virtual/special location.","Sanitize or normalize the name before passing it to the create API if calling programmatically."],"exampleFix":"// before (create prompt input)\n/subdir/newfile.txt\n\n// after\nnewfile.txt","handlingStrategy":"validation","validationCode":"local function is_valid_name(name)\n  return name ~= nil and #name > 0 and not name:find(\"[/\\\\]\") and name ~= \".\" and name ~= \"..\"\nend","typeGuard":"local function is_single_component(name)\n  return type(name) == \"string\" and not name:match(\"[/\\\\]\") and name ~= \".\" and name ~= \"..\"\nend","tryCatchPattern":"local ok, err = pcall(function() Command(\"create\"):arg({ \"--\", name }):send() end)\nif not ok then ya.notify({ title = \"create failed\", content = err, level = \"error\" }) end","preventionTips":["Prompt users for a bare file name, not a path, when creating entries.","Strip or reject slashes, drive letters, and `..` from input before creating.","Only run create actions in ordinary local directories, not virtual/special locations."],"tags":["filesystem","path","create","invalid-argument"],"backgroundTag":"invalid-path-join","analyzedSha":"a541adde4e5b082719a0f21a87eb3eab071ece58","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}