sxyazi/yazi · error

failed to get current working directory

Error message

failed to get current working directory

What it means

Error "failed to get current working directory" thrown in sxyazi/yazi.

Solutions

  1. Start Yazi from a valid working directory; the previous cwd may have been deleted — cd to an existing directory first.

When it happens

Trigger: Thrown at yazi-fs/src/cwd.rs:26 when the library encounters an invalid state.

Common situations: Querying the process working directory after it has been deleted or made inaccessible by another process.


AI-assisted analysis of sxyazi/yazi@a541adde4e (2026-08-19). Data as JSON: /api/errors/957568ed29d25164. Report an issue: GitHub.

Appendix: source

Thrown at yazi-fs/src/cwd.rs:26

pub static CWD: RoCell<Cwd> = RoCell::new();

pub struct Cwd(ArcSwap<UrlBuf>);

impl Deref for Cwd {
	type Target = ArcSwap<UrlBuf>;

	fn deref(&self) -> &Self::Target { &self.0 }
}

impl Default for Cwd {
	fn default() -> Self {
		let u = std::env::var_os("PWD")
			.map(PathBuf::from)
			.filter(|p| p.is_absolute())
			.map(clean_url)
			.or_else(|| current_dir().ok().map(UrlBuf::from))
			.expect("failed to get current working directory");

		Self(ArcSwap::new(Arc::new(u)))
	}
}

impl Cwd {
	pub(crate) fn path(&self) -> PathBuf { self.0.load().as_url().working_path().into_owned() }

	pub fn set(&self, url: &UrlBuf, callback: fn()) -> bool {
		if !url.is_absolute() && url.auth().is_local() {
			return false;
		} else if self.0.load().as_ref() == url {
			return false;
		}

		self.0.store(Arc::new(url.clone()));
		Self::sync_cwd(callback);

View on GitHub (pinned to a541adde4e)