-
Notifications
You must be signed in to change notification settings - Fork 63
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
Conflicts with hash_diff
#45
Comments
This is indeed an oversight. It is too late to change the name now, I guess. |
You don't need to change the name, you need to change the constants. Rename them all from You create a new
Done. Backwards compatible. |
Thanks for the tip @jfelchner . I'm not familiar with Ruby naming & file loading mechanism, could you please elaborate a little more on how does Ruby decide which file to load: |
When you do But now that I’m thinking about it it would have to be named differently or there would still be a conflict. Lemme do a PR for you. |
Just to add my 0.02c here. This gem has 30,000,000 downloads. The other gem has 50,000 and hasn't been updated in a year. I would say sensibility in some sense has to outweigh changing for changings sake. |
Except that I just had to go figure out WTF my diffs were coming out wonky in a project that ended up including both gems, one as a dependency of another internal gem, and one as a dependency of webmock. Had I not been the developer that introduced one of the dependencies, I would have had no effing clue where to start and probably chucked my computer out a window and contemplated my life choices. (By the way, it happened because, even though I wanted this library in the other internal gem, I accidentally put +1 for changing the constant name in this library to match the convention. |
I feel sorry to hear that @jwilger . I'm open to a change that can avoid the conflict. Maybe with a major version change, so that users are warned that the version has breaking changes. |
@liufengyun I would really like to get a major version bump out there so that we can fix this. I'd be happy to do the PR. |
@jfelchner A PR is welcome, I'm definitely for it. |
Changing the namespace of a gem in a major bump is super normal. Witness |
@pboling I agree, but this is a special case because there is a gem we don't control using that constant. In the case of Wouldn't solve the problem. Because existing gems are accessing the It also wouldn't solve the problem if everyone just used the shim (which most people would do) by requiring The best path forward here is to update the constants, add a shim, and then add a warning to the output that the next version will change the constant. Then in a few weeks, release a major version bump where the only difference is that the shim is removed. |
Aside from that I totally agree on the best path forward. |
@pboling Bundler will automatically require the file with the same name as the gem: Regardless of if Bundler loads it or not, if |
I see. I also realized that many other gems probably depend on HashDiff (I'm in the process of writing one) and we do use explicit requires in some places, like |
@liufengyun PR is complete. The require paths were correct, thus the only change that should need to be done by people using the library is to do a find and replace for |
@liufengyun go ahead and cut a |
I just cut |
I don't mean to butt in, but this just broke vcr test specs: https://travis-ci.org/vcr/vcr/jobs/538555321 |
Is this something I can help hashdiff with or is this something I simply need to fix on VCR tests? Note: We don't depend on hashdiff directly. |
@krainboltgreene Yes, see the webmock issue above, which is probably where this is failing. They aren't pessimistically locking |
Understood, thanks for the prompt reply. |
@krainboltgreene no worries. And sorry for the trouble. If you can see a better way to handle this, please let me know but I think this is the only way to do this. If you all require |
I think this was a reasonable approach. I'm going to do as you advise and
require hashdiff specifically.
…On Tue, May 28, 2019 at 9:44 PM Jeff Felchner ***@***.***> wrote:
@krainboltgreene <https://github.com/krainboltgreene> no worries. And
sorry for the trouble. If you can see a better way to handle this, please
let me know but I think this is the only way to do this.
If you all require hashdiff manually earlier in the test process before
any tests are run, I believe that should eliminate this message.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#45?email_source=notifications&email_token=AACRXWMFVFWJYVF6VJDML3DPXYC2NA5CNFSM4GKRKEOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWOEU4A#issuecomment-496781936>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACRXWOO7KMNMZGHTZAF74LPXYC2NANCNFSM4GKRKEOA>
.
--
Kurtis Rainbolt-Greene, Software Developer
Founder of Difference Engineers
2985 San Marino St.
Los Angeles, CA 90006
202-643-2263
|
@krainboltgreene I just want to verify that this is just a VCR test failure and the warning message isn't going to affect other VCR users who are mocking with webmock right? It looked like from that test failure that the warning was ending up inside the cassette data and that would be extremely bad if everyone's VCR cassettes started breaking if they're using webmock. |
The failure is because of the warning messages we now fire. The actual code tests still passed; it's just one of the message expectations now has "Warning from 1.0 we will be moving" |
See warning: ``` The HashDiff constant used by this gem conflicts with another gem of a similar name. As of version 1.0 the HashDiff constant will be completely removed and replaced by Hashdiff. For more information see liufengyun/hashdiff#45. ```
I know it's a bit nitpicky and while I get that you want to get the message out about this change, passing it via warn seems excessive as it's not really a deprecation per se. By using warn it gets raised in every spec run. IMO it'd be better raised via a post install message. |
You are using it if you're using a gem that's using it. If you weren't using it, So if you want
It's a "workaround" not a "final state", therefore it's a compromise between people who want the deprecation to go away and people who don't want their apps to break. We are giving people time to migrate. As you can see, we just got a notification an hour ago of someone who just now noticed the deprecation. Be empathetic to other developers who may not have found it yet. And I just want to point out that it took you significantly more time (both yours and mine) to write your comment than it would have taken to add the line to your
Although technically possible, it's significantly more error-prone than our current solution. |
@gsar @jfelchner it's important to remember that the issue revolves are how ruby warn levels are set. This is analogous to something we all are accustomed to doing with the Logger class, we're just not used to doing it on the ruby level. @gsar the burden to fix is on webmock. The burden to bear the warning is on the rest of us. You can change your ruby warn level in your Gemfile via $VERBOSE = nil or by setting it on the ruby itself. https://mislav.net/2011/06/ruby-verbose-mode/ |
@jfelchner if it was my personal pet project, i would have have implemented your workaround and moved on. the reality is that i have to do this for a codebase that has many other devs involved, and we have policies/processes around bringing in new code. we generally don't use "beta" code anywhere so i'd have to make an exception here and explain why it merits an exception, etc. that's what i meant by "more trouble than it is worth". @nacengineer i'm not clear on what you mean by "burden to fix is on webmock". they have already fixed it by not using i just want the maintainers here to realize that "the ask" for the workaround here is by no means as simple as it sounds like for some of us to implement. |
@gsar what is the burden that you're trying to resolve? Simply not seeing the warning? Is it causing your tests to fail?
|
@jfelchner i'm simply trying to avoid the work of looking into it and explaining it to their teams for other people in the same situation. it is not causing any test failures on my end, just some rubber-necking and the associated time wastage. thanks for engaging with my concerns, much appreciated. |
This piqued my curiosity and I came up with the following patch. It's based on diff --git a/lib/hashdiff.rb b/lib/hashdiff.rb
index 1ba94b8..6012d2d 100644
--- a/lib/hashdiff.rb
+++ b/lib/hashdiff.rb
@@ -9,6 +9,4 @@ require 'hashdiff/diff'
require 'hashdiff/patch'
require 'hashdiff/version'
-HashDiff = Hashdiff
-
-warn 'The HashDiff constant used by this gem conflicts with another gem of a similar name. As of version 1.0 the HashDiff constant will be completely removed and replaced by Hashdiff. For more information see https://github.com/liufengyun/hashdiff/issues/45.'
+autoload(:HashDiff, 'hashdiff_deprecated')
diff --git a/lib/hashdiff_deprecated.rb b/lib/hashdiff_deprecated.rb
new file mode 100644
index 0000000..4290182
--- /dev/null
+++ b/lib/hashdiff_deprecated.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+HashDiff = Hashdiff
+
+warn 'The HashDiff constant used by this gem conflicts with another gem of a similar name. As of version 1.0 the HashDiff constant will be completely removed and replaced by Hashdiff. For more information see https://github.com/liufengyun/hashdiff/issues/45.' |
I didn't got it, this |
@caduguedess not even remotely related. |
@schm new approach! Interesting! I'm not 100% confident with my knowledge of Ruby's |
This should remove this deprecation warning that is printed when booting a Rails/Rspec process: > The HashDiff constant used by this gem conflicts with another gem of a > similar name. As of version 1.0 the HashDiff constant will be > completely removed and replaced by Hashdiff. For more information see > liufengyun/hashdiff#45.
This should remove this deprecation warning that is printed when booting a Rails/Rspec process: > The HashDiff constant used by this gem conflicts with another gem of a > similar name. As of version 1.0 the HashDiff constant will be > completely removed and replaced by Hashdiff. For more information see > liufengyun/hashdiff#45.
About hashdiff: This should remove this deprecation warning that is printed when booting a Rails/Rspec process: > The HashDiff constant used by this gem conflicts with another gem of a > similar name. As of version 1.0 the HashDiff constant will be > completely removed and replaced by Hashdiff. For more information see > liufengyun/hashdiff#45.
About hashdiff: This should remove this deprecation warning that is printed when booting a Rails/Rspec process: > The HashDiff constant used by this gem conflicts with another gem of a > similar name. As of version 1.0 the HashDiff constant will be > completely removed and replaced by Hashdiff. For more information see > liufengyun/hashdiff#45.
@liufengyun #74 :) |
It's merged and released, thanks a lot for your help to finally resolve the issue @jfelchner 👍 |
The HashDiff constant used by this gem conflicts with another gem of a similar name. As of version 1.0 the HashDiff constant will be completely removed and replaced by Hashdiff. For more information see liufengyun/hashdiff#45.
Removes deprecation message > The HashDiff constant used by this gem conflicts with another gem of a similar name. As of version 1.0 the HashDiff constant will be completely removed and replaced by Hashdiff. For more information see liufengyun/hashdiff#45.
From: bblimke/webmock#822 "Due to this issue: liufengyun/hashdiff#45 hashdiff will be removing its current constant in the 1.0 release. Due to webmock's popularity I thought it prudent to let you all know considering your gemspec does not currently have a pessimistic lock on that gem. The upgrade path is extremely simple. A find and replace in the project from HashDiff to Hashdiff will work exactly the same as before. No require path changes are necessary." We fixed this in ManageIQ#161 but didn't enforce hashdiff 1.0, which removed/renamed the constant and doesn't evoke the warning: ``` The HashDiff constant used by this gem conflicts with another gem of a similar name. As of version 1.0 the HashDiff constant will be completely removed and replaced by Hashdiff. For more information see liufengyun/hashdiff#45 ```
Note: If you've upgraded
hashdiff
, made sure that you've upgraded your references, and want to silence the warnings, you can manually opt-in to the1.0
beta by following the instructions hereThe name of this gem is
hashdiff
. There is another gem namedhash_diff
. When they are both required via dependencies, errors are thrown. Additionally since the behavior is different, gems that are relying onhashdiff
's behavior, may gethash_diff
's behavior and vice versa.The reason for the conflict is because, based on ruby conventions,
_
's are the separators for camel case.So:
Unfortunately instead of making the base module of this gem
Hashdiff
, it's calledHashDiff
and it conflicts.The text was updated successfully, but these errors were encountered: