Skip to content

Avoid recursive lib symlinks in installed dependencies - #753

Open
stevenjoezhang wants to merge 1 commit into
crystal-lang:masterfrom
stevenjoezhang:fix/recursive-lib-symlinks
Open

stevenjoezhang wants to merge 1 commit into
crystal-lang:masterfrom
stevenjoezhang:fix/recursive-lib-symlinks

Conversation

@stevenjoezhang

Copy link
Copy Markdown

Shards currently creates lib/<dependency>/lib -> .., linking each dependency back to the project's entire lib directory. This creates filesystem cycles that can cause problems for tools that follow symlinks.

This change replaces that back-link with a real directory containing relative symlinks to the package's direct and transitive dependencies. Transitive dependencies remain accessible when compiling from a dependency's directory, including during postinstall.

Related: #263 and #681.

Changes

  • Preserve dependency relationships from the resolved graph and use them to build each package's dependency links.
  • Refresh managed links during both install and update, including for packages whose sources are already installed.
  • Remove obsolete generated links while preserving files and links with other targets.
  • Remove the vendored lib/molinillo/lib -> .. link.

Compatibility and scope

Existing lib paths and path: dependencies are left untouched. Legacy back-links are not automatically migrated; existing installations need a fresh dependency installation to adopt the new layout.

A package can access its declared direct and transitive dependencies through the generated directory. Unrelated installed packages are no longer implicitly available there.

This patch has been validated on Linux. Windows-specific behavior discussed in #681 has not been tested.

Validation

Added 11 regression cases covering directory cycles, transitive requires, dependency changes, overrides, relocation, and preservation of existing content. The two initial regression cases fail on the original implementation and pass with this patch.

With Crystal 1.22.2 on Linux:

  • Unit specs: 98 passed. Fossil and Mercurial specs were excluded because those tools were unavailable.
  • Integration specs: 221 passed, 1 pre-existing pending.
  • Formatting and whitespace checks passed.
  • Following symlinks through the repository's lib directory completes without a filesystem cycle.

Replace lib -> .. with a managed directory of links to the resolved
transitive dependencies. Refresh links for reused packages during install
and update while leaving pre-existing lib paths and path dependencies alone.

Remove the vendored molinillo back-link and cover directory cycles,
transitive requires, dependency changes, overrides, and user-owned entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant