rust-lang / rust-lang/rust

is fs::remove_file() guaranteed to remove the symlink link?

Open
#143,189 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-docs A-filesystem T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Location

https://doc.rust-lang.org/stable/std/fs/fn.remove_file.html

Summary

The documentation for std::fs::remove_file() states:

Removes a file from the filesystem.
[...]
This function currently corresponds to the unlink function on Unix. On Windows, DeleteFile is used or CreateFileW and SetInformationByHandle for readonly files. Note that, this may change in the future.

As noted, the implementation details may changed in the future. It is not mentioned whether or not this removes the symlink link, or the target, or whether this is platform-specific.

At the moment, both unlink ^1 and DeleteFile ^2 remove the link, not the target. The popular symlink crate has been relying on this behaviour for over 8 years.

Is this behaviour part of the API contract?

> If the name referred to a symbolic link, the link is removed.

> If the path points to a symbolic link, the symbolic link is deleted, not the target.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the std::fs::remove_file documentation linked in the issue and compare its stated Unix and Windows behavior with the referenced unlink and DeleteFile documentation. The work is done when the API contract clearly addresses symbolic links and any platform-specific behavior, with the wording agreed for the documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation, operating-systems
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.