fs::canonical(...) must handle a non-existent path as an error. As fs::exists("") is false, it is wrong to return the current directory for fs::canonical("").