Hey there, Vagrant uses its own embedded Ruby. I believe 1.6.5 runs Ruby 2.0 which supports keyword args, but not required ones. This should work:
def bugbear(a: nil, b: nil)
# ...
end
If you upgrade to 1.7, I believe you'll get keyword args. You can check the
Ruby version by running:
/opt/vagrant/embedded/bin/rubv -v (for Vagrant 1.7+)
/Applications/vagrant/embedded/bin/ruby -v (for < Vagrant 1.7)
If you're on Windows, the paths are slightly different and I don't remember
them off the top of my head.
Best,
Seth
> On Feb 10, 2015, at 9:39 AM, James Oden <[email protected]> wrote:
>
> I'm using Vagrant version 1.6.5, and when I was trying to add a function to
> my vagrant
> file that use keyword arguments I got a syntax error. I ended up just
> adding a simple
> function to see if I got the same error and I did.
>
> So in my test I added:
>
> def bugbear(a:, b:)
> print "#{a} #{b}\n"
> end
>
> But when I tried to use vagrant I got the following error message;
>
> There is a syntax error in the following Vagrantfile. The syntax error
> message is reproduced below for convenience:
>
> /Users/jamesoden/oracle/qa/repos/vagrant-dvat/Vagrantfile:246: syntax
> error, unexpected ','
> def bugbear(a:, b:)
> ^
> /Users/jamesoden/oracle/qa/repos/vagrant-dvat/Vagrantfile:248: syntax
> error, unexpected keyword_end, expecting end-of-input
>
>
> I'm pretty sure that is the correct syntax, and my version of ruby on the box
> is 2.1.5p273, which
> supports this syntax. I actually run my whole Vagrantfile through "ruby -c"
> and it does not complain.
>
> Why does this not work?
>
> Thanks...James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
smime.p7s
Description: S/MIME cryptographic signature
