sxyazi/yazi · error
Failed to join new name with CWD
Error message
Failed to join new name with CWD
What it means
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.
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.
Example fix
// before (create prompt input) /subdir/newfile.txt // after newfile.txt
Defensive patterns
Strategy: validation
Validate before calling
local function is_valid_name(name)
return name ~= nil and #name > 0 and not name:find("[/\\]") and name ~= "." and name ~= ".."
end Type guard
local function is_single_component(name)
return type(name) == "string" and not name:match("[/\\]") and name ~= "." and name ~= ".."
end Try / catch
local ok, err = pcall(function() Command("create"):arg({ "--", name }):send() end)
if not ok then ya.notify({ title = "create failed", content = err, level = "error" }) end Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of sxyazi/yazi@a541adde4e (2026-09-02).
Data as JSON: /api/errors/c166b1aa07fa6d37.
Report an issue: GitHub.
Appendix: source
Thrown at yazi-actor/src/mgr/create.rs:40
fn act(cx: &mut Ctx, CreateForm { target, dir, force }: Self::Form) -> Result<Data> {
let cwd = cx.cwd().to_owned();
let mut target: Pin<Box<dyn Stream<Item = StrandBuf> + Send>> = if target.is_empty() {
let input = input!(cx, YAZI.input.create(dir))?;
Box::pin(UnboundedReceiverStream::new(input).filter_map(|event| event.map(Into::into)))
} else {
Box::pin(tokio_stream::iter(vec![target]))
};
tokio::spawn(async move {
let Some(name) = target.next().await else { return Ok(()) };
if name.is_empty() {
return Ok(());
}
let Ok(new) = cwd.try_join(&name) else {
bail!("Failed to join new name with CWD");
};
if !force
&& let Some(file) = File::maybe_new(&new).await?
&& !ConfirmProxy::show(ConfirmCfg::overwrite(&file)).await
{
return Ok(());
}
let end_sep = AnyAsciiChar::SEP.predicate(*name.encoded_bytes().last().unwrap());
Self::r#do(new, dir || end_sep).await
});
succ!();
}
}
impl Create {
async fn r#do(new: UrlBuf, dir: bool) -> Result<()> {View on GitHub (pinned to a541adde4e)