Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: Our handling of circular dependencies is incomplete #38

Closed
clacke opened this issue Feb 27, 2018 · 2 comments
Closed

Problem: Our handling of circular dependencies is incomplete #38

clacke opened this issue Feb 27, 2018 · 2 comments
Assignees

Comments

@clacke
Copy link
Member

clacke commented Feb 27, 2018

This issue is a continuation of PR #40, and by mentioning it here I'm making the two an circular dependency of information. Resolve this by reading either you prefer first, and lazily waiting to parse the other. :-)

Reading #40 first probably makes the most sense.

Next steps: First, do (2) automatically instead of special-cased as
in this commit. When we break a circular dependency, don't just mark
the bottom package with circularBuildInputs, also mark the top package
with reverseCircularBuildInputs. When we build that package, we do
what we now special-cased for htdp-lib: remove the
reverseCircularBuildInputs from your config.rktd dependencies, unpack
them all next to you, set them all up with their dependencies
half-installed in the current installation scope.

Now, this will make the top package privileged, and anything
depending on a lower package that directly referenced the top package
will get a half-installed package as a dependency.

The next-next step might be to break the asymmetry by detecting the
full circle, install all the packages in the circle as one derivation,
and then figure out what to do with that. Maybe let each of the
package names be an alias to that package.

Another idea might be to give each package in the circle the chance
to be the privileged package. In practice this means you would have a
number of derivations that are isomorph, each with the same packages
installed in that scope, but each with its own name and with a
slightly differently shaped dependency tree underneath. Not sure if
this is horrible. It does mean some package depending on two packages
in the circle will result in a derivation that has both the
half-installed and the fully-setup package in its config.rktd, and
you are likely to get some whining from raco about that.

clacke added a commit to clacke/racket2nix-clacke that referenced this issue Feb 27, 2018
There are some circular dependencies in there. They can be made to
work by:

1. Not running setup on any package that is marked as having a
   circular dependency (we call this the bottom package).

The top package is the one that was detected as a circular dependency
by the bottom package and was cut out of the circle. The top package
transitively depends on the rest of the circle, the others are cut off
at the bottom package.

There are some true circular dependencies in there, that won't work
unless the dependency has had a proper setup and registered its
collections. They can be made to work by doing some extra work in the
top (not necessarily, but were lucky enough that it was the top)
package:

2a. Remove the bottom package from the config.rktd dependencies.
2b. Install both the top and bottom packages in the top installation
    scope.
2c. Run setup on both.

Solution: To get a starting point to work from, first make some ugly
special cases to solve these specific packages. Work on a generic
solution from here.

htdp-lib and deinprogramm-signature have a true circular dependency
that can be solved by (2) (verified with htdp-lib as top).

racket-doc and drracket have a circular dependency that works by just
doing (1) -- force both to not do any setup for now.

For discussion of next steps, see issue fractalide#38.
clacke added a commit to clacke/racket2nix-clacke that referenced this issue Feb 27, 2018
There are some circular dependencies in there. They can be made to
work.

The top package is the one that was detected as a circular dependency
by the bottom package and was cut out of the circle. The top package
transitively depends on the rest of the circle, the others are cut off
at the bottom package.

Here's how we can make this work:

1. Don't run setup on any bottom package.

There are some true circular dependencies in there, that won't work
unless the dependency has had a proper setup and registered its
collections. They can be made to work by doing some extra work in the
top (not necessarily, but we were lucky enough that it was the top --
the circle was only two packages) package:

2a. Remove the bottom package from the config.rktd dependencies.
2b. Install both the top and bottom packages in the top installation
    scope.
2c. Run setup on both.

Solution: To get a starting point to work from, first make some ugly
special cases to solve these specific packages. Work on a generic
solution from here.

htdp-lib and deinprogramm-signature have a true circular dependency
that can be solved by (2) (verified with htdp-lib as top).

racket-doc and drracket have a circular dependency that works by just
doing (1) -- force both to not do any setup for now. The racket-doc
package has a whole drove of circular dependencies with other -doc
packages.

For discussion of next steps, see issue fractalide#38.
clacke added a commit to clacke/racket2nix-clacke that referenced this issue Feb 27, 2018
There are some circular dependencies in there. They can be made to
work.

The top package is the one that was detected as a circular dependency
by the bottom package and was cut out of the circle. The top package
transitively depends on the rest of the circle, the others are cut off
at the bottom package.

Here's how we can make this work:

1. Don't run setup on any bottom package.

There are some true circular dependencies in there, that won't work
unless the dependency has had a proper setup and registered its
collections. They can be made to work by doing some extra work in the
top (not necessarily, but we were lucky enough that it was the top --
the circle was only two packages) package:

2a. Remove the bottom package from the config.rktd dependencies.
2b. Install both the top and bottom packages in the top installation
    scope.
2c. Run setup on both.

Solution: To get a starting point to work from, first make some ugly
special cases to solve these specific packages. Work on a generic
solution from here.

htdp-lib and deinprogramm-signature have a true circular dependency
that can be solved by (2) (verified with htdp-lib as top).

racket-doc and drracket have a circular dependency that works by just
doing (1) -- force both to not do any setup for now. The racket-doc
package has a whole drove of circular dependencies with other -doc
packages.

For discussion of next steps, see issue fractalide#38.
clacke added a commit to clacke/racket2nix-clacke that referenced this issue Feb 27, 2018
There are some circular dependencies in there. They can be made to
work.

The top package is the one that was detected as a circular dependency
by the bottom package and was cut out of the circle. The top package
transitively depends on the rest of the circle, the others are cut off
at the bottom package.

Here's how we can make this work:

1. Don't run setup on any bottom package.

There are some true circular dependencies in there, that won't work
unless the dependency has had a proper setup and registered its
collections. They can be made to work by doing some extra work in the
top (not necessarily, but we were lucky enough that it was the top --
the circle was only two packages) package:

2a. Remove the bottom package from the config.rktd dependencies.
2b. Install both the top and bottom packages in the top installation
    scope.
2c. Run setup on both.

Solution: To get a starting point to work from, first make some ugly
special cases to solve these specific packages. Work on a generic
solution from here.

htdp-lib and deinprogramm-signature have a true circular dependency
that can be solved by (2) (verified with htdp-lib as top).

racket-doc and drracket have a circular dependency that works by just
doing (1) -- force both to not do any setup for now. The racket-doc
package has a whole drove of circular dependencies with other -doc
packages.

For discussion of next steps, see issue fractalide#38.
@clacke clacke self-assigned this Mar 10, 2018
@clacke
Copy link
Member Author

clacke commented Mar 10, 2018

Here's my plan now: let the transitive dependencies function return two values:

The first is the current return value -- the transitive dependencies of the called package tree. The second is a dictionary of what cycles we are currently in: #hash([top-package . '("bottom" "depends-on-bottom" "etc")])

Today the bottom package in the cycle has the circular-build-inputs value. When you follow the chain back up, propagate this to every package, until you reach either the circular top, or you detect that you are out of the circle (you don't have the same circular-build-inputs already and the top is not in your breadcrumbs). At each step, trim the dependency that had the circular-build-input. This means in a pure cycle, the top package doesn't depend on anything. This is fine, because when you reach the top, you dump all of the accumulated packages in the reverse-circular-build-inputs, so they will be setup at top build time.

If you come in from the side (your dependency has circular-build-inputs that are not in your breadcrumbs and are not you), remove the dependency and put the top there instead.

Regardless if you discover that you are top or side, remove that cycle from the propagated values.

As every derivation depends directly on all transitive Racket dependencies, those will still be built and we won't have to do anything special about them. But circulars except tops won't be built at all (as nobody depends on them) -- they will just be placeholders to store the src value.

Maybe it would be good cosmetics to name the top something other than just the package that happened to become top, but that's not important right now.

Maybe it would be informative to add the trimmed dependencies to some informative attribute, but that's not important right now.

@clacke
Copy link
Member Author

clacke commented Jul 16, 2018

Closed by #92 , 0ef85df .

@clacke clacke closed this as completed Jul 16, 2018
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

No branches or pull requests

1 participant