-
Notifications
You must be signed in to change notification settings - Fork 454
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
TypeError: no implicit conversion of Hash into String #987
Comments
The backtrace is:
Introduced in |
@denisj and @tom-lord are you using Happy to hear suggestions for solutions. It may also be worth proposing a patch to |
@petergoldstein I'm not using |
Opened an issue - ruby/resolv-replace#2 - against @denisj certainly possible it's getting pulled in by default by Ruby 3.2.x, although in that case I'd expect CI to fail. Let's see what the |
Closes petergoldstein#987 In version 3.2.7 socket_timeout option was introduced for TCPSocket. This works unless `resolv-replace` gem is loaded (which was added to ruby standard library since version 3.0.0). This commit adds another check besides the ruby version check to avoid breaking dalli for applications that have `resolv-replace` gem required.
I was able to reproduce it locally when requiring irb(Dalli::Socket::TCP):001> ::TCPSocket.new(host, port, connect_timeout: 1)
=> #<TCPSocket:fd 8, AF_INET6, ::1, 64827>
irb(Dalli::Socket::TCP):002> require 'resolv-replace'
...
irb(Dalli::Socket::TCP):003> ::TCPSocket.new(host, port, connect_timeout: 1)
/Users/yury.lebedev@carwow.de/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/resolv.rb:112:in `each_address': no implicit conversion of Hash into String (TypeError) It seems that at least some Rails applications are loading this library by default, and I think we can check if I submitted a PR #989 to fix this conflict. |
* Fix conflict with resolv-replace gem Closes #987 In version 3.2.7 socket_timeout option was introduced for TCPSocket. This works unless `resolv-replace` gem is loaded (which was added to ruby standard library since version 3.0.0). This commit adds another check besides the ruby version check to avoid breaking dalli for applications that have `resolv-replace` gem required. * Fix rubocop warning * Comment additional check in TCP.open method definition
@petergoldstein I have tested it against main, but I still have the issue. |
@denisj could you tell me which ruby version you are using? I would like to look into the issue deeper |
@denisj stacktrace would be also helpful |
@y9v I believe this is the same error. I'm using Ruby 3.2.3. |
@denisj and which line from dalli gem is the first one in the stacktrace? Also line 93?
|
|
@denisj thank you! this really helps, apparently checking for this initialize method alias doesn't work in your case. I tested our application (that runs on ruby 3.2.2) and the issue is fixed, so I will try to find why it's still broken in 3.2.3 (or maybe it's not the ruby version that is causing this) |
@y9v Do you need more info? I'm faking the memcached configuration in dev in order to reproduce the bug: config.cache_store = :mem_cache_store,
'127.0.0.1:11211',
{ namespace: 'conversation', compress: true } |
@denisj I would probably need some more info, but this not because of cache store configuration, it has something to do with how |
In my gem list, I have resolv (default: 0.2.2)
resolv-replace (default: 0.1.1) |
@denisj could you please run this code snipped in your production console? ::TCPSocket.private_instance_methods.include?(:original_resolv_initialize) and also this one: TCPSocket.private_instance_methods - Object.private_instance_methods |
3.2.3 :001 > ::TCPSocket.private_instance_methods.include?(:original_resolv_initialize)
=> true
3.2.3 :002 > TCPSocket.private_instance_methods - Object.private_instance_methods
=> [:original_resolv_initialize, :__sendmsg, :__sendmsg_nonblock, :__recv_nonblock, :__recvmsg, :__recvmsg_nonblock, :__read_nonblock, :__write_nonblock] |
@denisj I think what is happening in your case is that |
@denisj it's quite an ugly fix, but I think it might help to remove |
A better solution for fixing this would be to move this condition that we have when defining |
Hello all! Seems to have a similar issue when updating Dalli from 3.2.6 to 3.2.7 along with rails-settings-cached Dalli 3.2.7 It is quite obscur for me, any advices would be appreciated !
|
@y9v It works on my side. Thx. |
@petergoldstein It looks like a release for this fix is yet to be pushed/published. |
Ruby: 3.2.3 After upgrading to the latest release of dalli which I believe contains the fix discussed above, I'm still gaining the following error (backtrace below) Is anyone still experiencing this error? /gems/socksify-1.7.1/lib/socksify.rb:178 in initialize |
@scottsherwood you have a different problem, it's caused by |
Dalli 3.2.7
Ruby 3.2.3
Rails 7.1.3
I get this error when trying simple command such as
in lib/dalli/socket.rb line 92
in lib/ruby/3.2.0/resolv-replace.rb line 24
The thing present in rest[0] is
mem_cache_store configuration:
Backtrace
The text was updated successfully, but these errors were encountered: