rust-lang / rust-lang/rustfmt

The search for the config file ignores symlinks

Open
#1,650 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-config A-io E-help-wanted P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

When placing a .rustfmt.toml file in my home directory (I realize you're meant to stay with the defaults globally, but wanted to switch to rfc style), I noticed it had no effect. Now, the folder my project was in is symlinked as ~, but is actually placed on a separate btrfs subvolume, so I suspected the recursive search upwards was failing to cross the filesystem boundary. Moving the file into the subvolume worked, but out of curiosity I searched through the issues, PRs, and source relating to config file search, and found that fs::canonicalize was being called on the current directory path before starting the search, which means that it will not respect what you see as the directory you are in if you arrived there through symlinks. Given the clear function of canonicalize, I expect this to be intentional, but is it? And if so, why?

(also, this my first time submitting an issue, so any feedback on the format is welcome)

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

Read libsyntax/src/config.rs around line 390, focusing on the fs::canonicalize call before configuration search. Reproduce the behavior with a .rustfmt.toml in a symlinked home directory, then determine whether the search should preserve the visible symlink path or whether the existing behavior needs explanation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.