browser30
browser30

Reputation: 71

syntax error, unexpected tASSOC, expecting $end

I've added the following code snippet to my production.rb environment file:

default_attributes (
  "chef_client" => {
    "interval" => 300
  }
)

And when trying to upload it to our Chef Server I get the following:

knife environment from file production.rb


ERROR: SyntaxError: C:/Chef/PROD/chef-starter/chef-repo/environments/production.rb:9: syntax error, unexpected tASSOC, expecting ')'
    "chef_client" => {
                    ^


C:/Chef/PROD/chef-starter/chef-repo/environments/production.rb:10: syntax error, unexpected tASSOC, expecting $end
            "interval" => 300
                         ^

Upvotes: 0

Views: 1655

Answers (1)

coderanger
coderanger

Reputation: 54181

You need to remove the space between default_attributes and the ().

default_attributes(
  "chef_client" => {
    "interval" => 300
  }
)

This is because Ruby doesn't parse it as a method call when you have the space:

>> f ('a' => 1)
SyntaxError: (irb):4: syntax error, unexpected =>, expecting ')'
f ('a' => 1)
         ^
    from /Users/coderanger/.rbenv/versions/2.1.2/bin/irb:11:in `<main>'
>> f('a' => 1)
=> [{"a"=>1}]

Upvotes: 1

Related Questions