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

ArgumentError with Ruby 3 #21

Open
mt-clearhaus opened this issue Aug 25, 2023 · 0 comments
Open

ArgumentError with Ruby 3 #21

mt-clearhaus opened this issue Aug 25, 2023 · 0 comments

Comments

@mt-clearhaus
Copy link

I'm using version 2.2.1 of the gem with Ruby 3.1.2p20 in Debian Bookworm.

I'm getting ArgumentError when calling Net::TCPClient.connect(connection_params) because the parameters are passed to new in a way not compatible with Ruby 3:

From: /var/lib/gems/3.1.0/gems/net_tcp_client-2.2.1/lib/net/tcp_client/tcp_client.rb:91 Net::TCPClient.connect:

    90: def self.connect(params = {})
 => 91:   require 'pry'; binding.pry
    92:   connection = new(params)
    93:   yield(connection)
    94: ensure
    95:   connection&.close
    96: end

[1] pry(Net::TCPClient)> params
=> {:server=>"foobar:8080", :connect_timeout=>1, :connect_retry_count=>4, :connect_retry_interval=>1, :write_timeout=>2, :read_timeout=>23}
[2] pry(Net::TCPClient)> new(params)
ArgumentError: wrong number of arguments (given 1, expected 0)

With Ruby 3 it appears to be necessary to use the double splat operator: new(**params)

See e.g. https://stackoverflow.com/a/68450312.

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

1 participant