bst show asks the user to fetch a workspaced junction

Summary

This painful experience is somewhat similar to #691 (closed), but different.

When running bst show on a project with a workspaced junction, bst complains if it does not have the ref cached for that junction.

Steps to reproduce

Two ways to reproduce

Clean state

  • Obtain a project with a junction
  • Never have built that project before
  • Obtain the junctioned project in an adjacent directory, separately
  • Open a workspace on that junction, with --no-checkout
    • Note that this path ensures that BuildStream does not go an cache the junctioned project inadvertently, BuildStream has never downloaded the sources itself, you have cloned the junction project separately and intend to work on both projects in parallel with an open junction.
  • Now run bst show target.bst in the toplevel project with the open workspace

Out of sync state

  • Obtain a project with a junction
  • Open a junction on the workspace, without --no-checkout
    • Note that in this case, it doesnt matter whether you have built it before or not, opening the workspace will ensure that BuildStream owns a locally cached copy of the junctioned project.
  • Allow a few weeks to go by
  • Now update your local branch of the main project to the upstream master version
    • Note that here it is important that the new update has updated it's junction.refs file to a new version of the junctioned project, which did not exist at the time you initially opened the workspace
  • Now run bst show target.bst in the toplevel project with the open workspace

What is the current bug behavior?

BuildStream reports an error at early load time:

Subproject fetch needed for junction: example.bst

    Try fetching the project with `bst fetch example.bst`

At which point you go ahead and run bst fetch example.bst, regardless of how ridiculous you know that is... and just as you would expect... BuildStream starts up and quite correctly does nothing at all in the session - the junction is workspaced so bst fetch has nothing to do at all (#846 indicates it might be wise to actually perform a fetch even if there is a workspace, but this is unrelated to the issue at hand really).

What is the expected correct behavior?

No warning, we have a workspace open on the junction, there should be no requirement whatsoever to have the junction fetched.

Workaround

This part is pretty obvious, but flabbergasting... and quite embarrassing:

  • Close the open workspace on the junction
  • Fetch the junction.
    • Now that the workspace is closed, BuildStream will fetch the junction
  • Reopen the workspace (probably using --no-checkout, but that's not relevant)
  • Now run bst show target.bst again.

No more complaints, BuildStream has happily cached a copy of the junction and now stops whining.