'How do I get the current working directory with the least amount of dependencies possible?

I have a Rust application which works as a shell. I want to get the working directory the user is in using as little dependencies as possible.

I tried using

let path = env::current_dir();
print!("{} > ",path.display());

But it gives me the following error: method not found in `Result<PathBuf, std::io::Error>'

I tried running this in the rust playground and it worked alright, so I was wondering if any of you could help me with this



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source