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

Possible namespace clash with Hex.pm? #14

Closed
suranyami opened this issue Sep 26, 2014 · 7 comments
Closed

Possible namespace clash with Hex.pm? #14

suranyami opened this issue Sep 26, 2014 · 7 comments

Comments

@suranyami
Copy link
Collaborator

I've been getting some very strange behaviour trying to use this package in my color library suranyami/cor.

Here are 2 consecutive runs of mix test with nothing else happening in between:

    > mix test
    lib/hex.ex:1: warning: redefining module Hex
    ==> hex
    Compiled lib/hex.ex
    Generated hex.app
    ==> cor
    Compiled lib/cor.ex
    lib/cor/rgb.ex:2: warning: unused import Hex
    Compiled lib/cor/rgb.ex
    Generated cor.app

      1) test html (Cor.RgbTest)
         test/rgb_test.exs:24
         Assertion with == failed
         code: Rgb.html(Rgb.red()) == "ff0000"
         lhs:  "#ff0000"
         rhs:  "ff0000"
         stacktrace:
           test/rgb_test.exs:25

    Finished in 0.07 seconds (0.07s on load, 0.00s on tests)
    5 tests, 1 failures
    Randomized with seed 840680

    > mix test
      1) test html (Cor.RgbTest)
         test/rgb_test.exs:24
         ** (UndefinedFunctionError) undefined function: Hex.encode/2
         stacktrace:
           Hex.encode(255.0, 2)
           (cor) lib/cor/rgb.ex:18: Cor.Rgb.html/1
           test/rgb_test.exs:25

      2) test hex_digits (Cor.RgbTest)
         test/rgb_test.exs:19
         ** (UndefinedFunctionError) undefined function: Hex.encode/2
         stacktrace:
           Hex.encode(255.0, 2)
           test/rgb_test.exs:20

    Finished in 0.08 seconds (0.08s on load, 0.00s on tests)
    5 tests, 2 failures

When I run iex -S mix and run Hex.encode(255.0, 2) in my lib's directory, I get UndefinedFunctionError.

When I run iex -S mix in the hex directory, it works as expected.

On a whim, I added a version function that returned "XXX" directly into deps/hex/lib/hex.ex file locally in my repo. Recompiled, ran iex -S mix:

    iex> Hex.version
      "XXX"

I then re-ran mix test, got the above errors, then ran iex -S mix for a SECOND TIME, and this is what I get:

    iex> Hex.version
      "0.4.2"

Which just so happens to be the same as Hex.pm version, as shown by:

> mix hex.info
Hex v0.4.2

Registry file available (last updated: 2014-09-27 08:31:03)
Size: 125kB
Packages #: 199
Versions #: 799

So, in summary:

  • Something weird is going on between the Hex.pm package manager and this hex library.
  • Running tests seems to clobber the hex library and replace it with hex.pm.

I'm going to temporarily rename my fork to hexate, and see if this voodoo all goes away. If it does, it might be an idea to rename this?

Either that, or dig deeper into what exactly is going on here.

This certainly raises some questions about namespaces in Elixir, too.

@suranyami
Copy link
Collaborator Author

Okay, so I did the rename, and lo and behold, problem disappears.

How do you want to handle this? There are probably quite a few people already using your library through a github reference in their mix deps, and it wouldn't be good to just break that.

I could make you a collaborator on my renamed fork, and we could take it from there? Leave this repo as it is for backwards compatibility, maybe with a note that it's been renamed and deprecated?

Let me know what you want to do.

@rjsamson
Copy link
Owner

Yeah, I've been thinking quite a bit about this since elixir introduced Hex a while back, but hadn't yet had a firm reason to make the change yet as it hadn't yet been causing any widespread issues. I'm fine with the name change, and I'm not overly concerned with backwards compatibility since the Elixir community, is I think, somewhat used to breaking changes, and it wouldn't be an issue again going forward. I also like the Hexate name, so go ahead and send a pull request with your changes and I'll merge them in. I'm also happy to add you as a committer / maintainer to this repo (and a maintainer in the package def if you'd like to add that to your pull request.)

Does that sound good to you?

@rjsamson
Copy link
Owner

Also - maybe could leave a branch as is at this point in time, for anyone that really needed to continue to use the old name for some reason?

@suranyami
Copy link
Collaborator Author

Okay, merged that pull request in, added the pre-rename branch and updated the README.
I don't seem to have permission to rename the repo.

Either you should rename it, or elevate my permissions.

@suranyami
Copy link
Collaborator Author

Also, I think this issue is now resolved!

@rjsamson
Copy link
Owner

rjsamson commented Oct 1, 2014

👍 👍 👍

Looks like you already have 'full permissions' - I'm guessing rename and delete are the two things you can't add. Just renamed the repo though. Great work!!

@suranyami
Copy link
Collaborator Author

Excellent! Yeah, I think you need to be the repo's 'owner' to do those.

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

2 participants