-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Error out if naming clashes with homonymous sub-dependencies #191
Comments
Maybe make more clear what the issue/proposed solution by prepending a "Error out if" to the issue title ;) Otherwise I fully agree. |
Sorry, your silly example doesn't work (wrong naming). Do you have an actual failing test case that reproduces the issue you're trying to raise? That would outline the actual problem, and allow to iterate on how to fix it. |
What doesn't work for you with that example? This is what I do to reproduce:
I there was no name clash with kemal's dependency also named name: sidekiq
version: 0.7.0
authors:
- Mike Perham <[email protected]>
# ... |
name: foo
version: 0.1.0
dependencies:
radix:
github: mperham/sidekiq.cr $ shards
Updating https://github.com/mperham/sidekiq.cr.git
Error shard name (sidekiq) doesn't match dependency name (radix) |
In your silly example Shards is fooled because the |
Argh... My point is that with this silly example, shards should show the name mismatch error instead of silently skipping the invalid definition. To make this example less silly, I've created a dummy shard called name: test-dependecy-name-clash
version: 0.2.0
dependencies:
kemal:
github: kemalcr/kemal
radix:
github: straight-shoota/radix Now, having only the last dependency would install There is a different behaviour if the order of dependecies is reversed: name: test-dependecy-name-clash
version: 0.3.0
dependencies:
radix:
github: straight-shoota/radix
kemal:
github: kemalcr/kemal
There will at least be an error because the version of |
There are different things.
I said it before but the resolver is very very stupid, and we're starting to hit some blocks. Time to think properly, I guess. |
I.e. depends on #1 |
This will probably never be fixed, because of the very nature of Shards and Git: they're decentralised.
For example I may clone a shard, create a branch with a custom fix and be valid to be referenced in the dependency graph, even if another dependency refers to the original repository —I regularly do that in Ruby. Unless there is the possibility to know for sure whether two git repositories are clones of each other (or not)? |
But shards can detect that there are two different dependencies of the same name and should error out by default. If one is a fork of the other and they both work fine together, there might be an option to allow it (giving one of them preference). |
I overlooked the radix/sidekiq example: that's wrong naming. There is a check but the current solver recursively checks dependencies, thus finds the correct radix dependency definition first (from kemal dependencies), then... completely overlooks the wrong naming. Yes, the current solver is bad. Solver::Graph in the SAT solver branch should compare each dependency name with each version for every spec. See 1513ee5 ... or maybe not, because it won't check it for versions that it already knows about (for performance reasons, each |
My proposal for this would be to use the top level dependency override the repository. |
This is closely related to #299. name: myshard
dependencies:
foo:
git: foo/foo
bar:
git: bar/bar name: foo
dependencies:
baz:
git: foo/baz name: bar
dependencies:
baz:
git: bar/baz Currently ( |
Any updates? I just run into this issue. dependencies:
tourmaline:
github: protoncr/tourmaline
version: 0.22.0
amber:
github: amberframework/amber
version: 0.36.0 Here the shard |
@elia-franzella you should be able to define a shard.override.yml in your project and choose there which pool fork you want to use. See #422 for details on the override file. |
@bcardiff thanks for the reply. Isn't that a source of conflicts too? Forks can diverge, and if they do - and they do - chances are that the whole project won't compile. The above example is one of them: creating a I'm thinking something like this: # shard 1 from tom123
name: foo
dependencies:
baz:
github: organization1/baz # shard 2 from frank123
name: bar
dependencies:
baz:
# fork or unrelated shard
github: organization2/baz # root
name: project
dependencies:
foo:
github: tom123/foo
bar:
github: frank123/bar
This schema won't ever run into direct homonymy since github usernames are unique and so do the repos under the same username. |
That won't work. If you have two shards named |
Yes and no, I think. That would be a whole new issue: if two indipendent shards shared the same namespace that would be dangerous even if the shard names were different, right? This would not be even detected by the dependency resolver. |
@elia-franzella it's a compromise. Having a global namespace is not ideal, but the alternative would have been to keep the organization in the require statement, which would require a different override mechanism on forks. I'm not stating that the current situation is the best one, but is one that supports sources for local path and repos that might not have the concept of organization as github. A shard's name is decoupled from the code location via the shard.yml. The shard's name is a shared namespace. As such using common names like pool, tasks, jobs might be problematic. |
The original issue was actually resolved in #419. Since then, shards errors on conflicting dependency names. An override can be used to resolve such a conflict. The most recent comments are diverging from the original problem. I think this is essentially a wontfix, but feel free to start a new discussion about name-based shard disambiguation. |
This has come up in #190 but it's a different issue. Consider the following shard specs:
Installing the dependencies for
parent-project
there will be an issue because the dependencybar
points to different locations. Now, one of these might just be a mirror, in which case it should work completely fine (assuming both are up to date).But the dependencies might also point to a fork or two entirely different shards which just happen to share the same identifier. Note that this is not about the original name of these dependencies but the local keys used for each dependency.
An easily reproducable example is this shard file:
You would expect shards to install
mperham/sidekiq.cr
inlib/radix
but it doesn't, because it puts thekemal
dependencyluislavena/radix
there.Obviously, the example is rather silly and wouldn't work anyway, but it might just've come by mistake; or it could really be two shards sharing the same name. There is nothing to do about such a name clash in a decentralized system. But in such a case,
shards
should notify the user about having different remotes for the same dependency and not install any of them.The text was updated successfully, but these errors were encountered: