Elixir: Name collision

Created on 20 Sep 2016  路  7Comments  路  Source: elixir-lang/elixir

I recently ran into a name collision, where one package (an erlang app) depended on the rebar3 uuid package (https://github.com/okeuday/uuid), and another package (a hex package) depended on the elixir/hex uuid package (https://hex.pm/packages/uuid). And the whole project was not able to build.

Are you aware that this can happen? Perhaps there is already a way around this (and I couldn't find it). Otherwise maybe packages from different sources should be namespaced?

Unresolved

Most helpful comment

I am not so worried about direct explicit collisions, but a place where collisions are more likely to happen is in all the indirect dependencies that happen to have the same name between erlang <-> elixir.

And this will become more unlikely as both communities are converging to hex.

All 7 comments

@jfrolich setting :uuid in the parent project with :overrides true will allow you to pick one or the other but namespacing wouldn't help here because both still defined the same application (and likely similar same modules).

Note that uuid for erlang and uuid for elixir are completely different projects, so override would break the one or the other.

With namespacing I meant that behind the scenes we namespace one of them either elixir or erlang, so same app names will never collide. For instance we can do that by prepending all elixir apps to :__elixir__[app_name] or so. Or is there a major hurdle why that cannot be done. It would be nice if the elixir and erlang ecosystems can work together nicely and it would be possible to mix and match.

I am not so worried about direct explicit collisions, but a place where collisions are more likely to happen is in all the indirect dependencies that happen to have the same name between erlang <-> elixir.

That doesn't solve the problem where the application names and module names are still names and we can't prefix them because they are only simple atoms. I can do this:

application = :uuid
Application.start(application)

So if you want to prefix and the code above still to work, we would need to prefix all atoms. It simply won't work.

I am not so worried about direct explicit collisions, but a place where collisions are more likely to happen is in all the indirect dependencies that happen to have the same name between erlang <-> elixir.

And this will become more unlikely as both communities are converging to hex.

Ah right see the trade-off there. Didn't know both communities are standardizing on hex, would make this irrelevant indeed, and a much cleaner solution! Hope this thread can provide the answer for other people who run into the same problem.

@josevalim: Do you confirm the best way to resolve this, is change the package name?

Yes.

Was this page helpful?
0 / 5 - 0 ratings