ruby-on-railsrubyrubygemssyntax-errorsendgrid-ruby

Syntax error, unexpected tLABEL, expecting ')' (SyntaxError)


Environment

I used sendgrid-ruby gem in my application whenever I run rails server it's giving me below error which comes from gems/sendgrid-ruby-4.0.8/lib/sendgrid/client.rb:17

/.rvm/gems/ruby-1.9.3-p547@demo/gems/sendgrid-ruby-4.0.8/lib/sendgrid-ruby.rb:1:in `require_relative': /.rvm/gems/ruby-1.9.3-p547@demo/gems/sendgrid-ruby-4.0.8/lib/sendgrid/client.rb:17: syntax error, unexpected tLABEL, expecting ')' (SyntaxError) def initialize(api_key: nil, host: nil, request_head... ^ /.rvm/gems/ruby-1.9.3-p547@demo/gems/sendgrid-ruby-4.0.8/lib/sendgrid/client.rb:17: Can't assign to nil ... def initialize(api_key: nil, host: nil, request_headers: ... ... ^ /.rvm/gems/ruby-1.9.3-p547@demo/gems/sendgrid-ruby-4.0.8/lib/sendgrid/client.rb:17: Can't assign to nil ...ialize(api_key: nil, host: nil, request_headers: nil, versio... ... ^ /.rvm/gems/ruby-1.9.3-p547@demo/gems/sendgrid-ruby-4.0.8/lib/sendgrid/client.rb:17: Can't assign to nil ...ost: nil, request_headers: nil, version: nil)

I checked the same file and same line of gem sengrid-ruby. it has below the line

def initialize(api_key: nil, host: nil, request_headers: nil, version: nil)

if I replace this to below it isn't giving me.

def initialize(api_key, host, request_headers, version)

is this syntax error of rails or ruby related version? There are other lots of error which contain the same syntax in other gems. What should I do with this type of syntax errors?


Solution

  • Keyword arguments require Ruby's version 2.0.0 or higher. https://thoughtbot.com/blog/ruby-2-keyword-arguments