-3

Here's my code (the entirety of it):

require "rubygems"
require "ruby-box"

with rubygems installed, and ruby-box installed as a gem. Here's my error:

Faraday: you may want to install system_timer for reliable timeouts
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:45:in `gem_original_require': /Library/Ruby/Gems/1.8/gems/ruby-box-1.9.1/lib/ruby-box/item.rb:91: odd number list for Hash (SyntaxError)
        access: 'open'
               ^
/Library/Ruby/Gems/1.8/gems/ruby-box-1.9.1/lib/ruby-box/item.rb:91: syntax error, unexpected ':', expecting '}'
        access: 'open'
               ^
/Library/Ruby/Gems/1.8/gems/ruby-box-1.9.1/lib/ruby-box/item.rb:92: syntax error, unexpected '}', expecting kEND
      }.merge(opts) if opts
       ^
/Library/Ruby/Gems/1.8/gems/ruby-box-1.9.1/lib/ruby-box/item.rb:102: odd number list for Hash
        shared_link: opts
                    ^
/Library/Ruby/Gems/1.8/gems/ruby-box-1.9.1/lib/ruby-box/item.rb:102: syntax error, unexpected ':', expecting '}'
        shared_link: opts
                    ^
    from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /Library/Ruby/Gems/1.8/gems/ruby-box-1.9.1/lib/ruby-box.rb:4
    from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:110:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:110:in `require'
    from box.rb:2
sawa
  • 165,429
  • 45
  • 277
  • 381
Andrew
  • 15,935
  • 28
  • 121
  • 203

1 Answers1

3

It looks like you're using Ruby 1.8 but are trying to use the hash literal syntax that was added in Ruby 1.9:

{ foo: bar }

In Ruby 1.8, you need to write:

{ :foo => bar }

But if you're just getting started, I recommend you simply upgrade your Ruby version rather than rewriting your code.

Note that the curly braces are sometimes omitted, if the hash is the argument of a method call.

Thomas
  • 174,939
  • 50
  • 355
  • 478
  • You misunderstand; the 2 lines of code i pasted above, the require lines, that's literally all the code I have. Perhaps the hash literals are inside the ruby-box library. – Andrew Aug 03 '13 at 12:22
  • @Andrew They are, as the error indicates. – Dave Newton Aug 03 '13 at 12:25
  • Well, then your only option is to upgrade your Ruby. – Thomas Aug 03 '13 at 12:31
  • How do i upgrade ruby? I'm on a mac, and tried the instructions here, but it still gives me the same error http://stackoverflow.com/questions/3696564/how-to-update-ruby-to-1-9-x-on-mac – Andrew Aug 03 '13 at 12:34
  • I suggest you use RVM like the answers in that question, and see the RVM documentation for more details. Once you've installed the Ruby, you need to tell RVM to use it by default, and possibly need to restart your terminal. – Thomas Aug 03 '13 at 12:42