Skip to content

Track symlinks between local files via DICE dependencies#1286

Open
cormacrelf wants to merge 1 commit intofacebook:mainfrom
cormacrelf:dice-symlinks
Open

Track symlinks between local files via DICE dependencies#1286
cormacrelf wants to merge 1 commit intofacebook:mainfrom
cormacrelf:dice-symlinks

Conversation

@cormacrelf
Copy link
Copy Markdown
Contributor

@cormacrelf cormacrelf commented Apr 9, 2026

Problem

Here's a test case that I was quite alarmed Buck fails at. The use case is reading files at bzl eval time that don't have a .toml suffix, as TOML, for https://github.com/cormacrelf/elk which I have updated to depend on this entire thing at the heart of its strategy only to realise it doesn't work very well at all. (I would be happy with a way to tell load() to load as TOML if we can't get symlinks to work.)

BUCK
blah.lock
blah.lock.toml -> blah.lock   [a symlink]
# blah.lock
value = "original"
# BUCK
load(":blah.lock.toml", "value")

genrule(
    name = "test",
    out = "out.txt",
    cmd = "echo {} > $OUT".format(value),
)

Now, buck does not pick up changes to blah.lock.

buck2 build --out=- :test
{value: original}

echo 'value = "changed"' > blah.lock

buck2 build --out=- :test
{value: original}

# wat?
# now you have to buck2 clean to get it to pick up changes...

Solution

I am not very familiar with the fs operations here. This is pretty likely not to be quite correct and I invite some attention on the implementation. In particular I don't think it handles directory symlinks at all. But the general idea is being symlink-aware when reading a file, and making the DICE dependency graph reflect the symlink graph, so that a change to a real file propagates through any symlinks referring to it.

Basically this PR passes the test above, I make no claim other than that.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant