pub fn from_system_path(path: &Path) -> Result<Self, PathError> {
        let path = path
            .to_str()
            .ok_or_else(|| PathError::InvalidUnicode(path.to_string_lossy().to_string()))?;

        #[allow(unused_variables)]
        let PathValidation {
            well_formed,
            windows_safe,
        } = check_path(path);

        if !well_formed {
            return Err(PathError::MalformedPath(path.to_string()));
        }

        #[cfg(windows)]
        {
            if !windows_safe {
                return Err(PathError::WindowsUnsafePath(path.to_string()));
            }
        }

        // Remove trailing slash
        let stripped_path = path.strip_suffix('/').unwrap_or(path);

        let path;
        #[cfg(windows)]
        {
            let windows_path = stripped_path.replace('/', std::path::MAIN_SEPARATOR_STR);
            path = Utf8PathBuf::from(windows_path);
        }
        #[cfg(unix)]
        {
            path = Utf8PathBuf::from(stripped_path);
        }

        Ok(AnchoredSystemPathBuf(path))
    }
Takes in a path, validates that it is anchored and constructs an
`AnchoredSystemPathBuf` with no trailing slashes.
crates/turborepo-paths/src/anchored_system_path_buf.rs