# Setting default Ruby version



## neolix (Oct 10, 2013)

Hi ladies and fellas,

I want to set ruby 2.0 as my default ruby version. When building from ports (lang/ruby20) I get ruby set to version 2.0 with either DEFAULT_RUBY_VER=2.0 or the more apt DEFAULT_VERSIONS=ruby=2.0 in /etc/make.conf. However none of those appear to work when I install a binary (`pkg install ruby20`) which install /usr/local/bin/ruby20 instead of /usr/local/bin/ruby. Am I missing something? I'm on FreeBSD 9.2.


----------



## SirDice (Oct 10, 2013)

Packages are built using the default options. If a package depends on Ruby 1.9, you will get 1.9. Regardless of what you put into make.conf. Those settings only have an effect when you build ports.


----------



## neolix (Oct 10, 2013)

With a little thought it seems so obvious, maybe I've been up too long. Makes perfect sense pkg won't look at make.conf since it isn't building anything. In the ruby20 Makefile, the sym-linking of /usr/local/bin/ruby to /usr/local/bin/ruby20 is done post-install. I could do the same manually but before I do is there a way of giving pkg such options, say in pkg.conf?


----------



## SirDice (Oct 10, 2013)

The binary package should do the same things, so it should create the symlinks. It might be a small bug in either the port's Makefile or perhaps in pkg itself.


----------



## neolix (Oct 10, 2013)

Thanks @SirDice. I was building my ports with poudriere but I had DEFAULT_VERSION=ruby=2.0 in the respective make.conf. I'm not sure where I picked that up but I was working under the assumption I can use DEFAULT_VERSION for a single port and DEFAULT_VERSIONS for one or more ports. Changing that to DEFAULT_VERSIONS=ruby=2.0 worked and I end up with a ruby build rather than a ruby20 build. I'll have to read up some more on this.


----------



## SirDice (Oct 10, 2013)

I think the confusion started a while back when it was first introduced. The comments in /usr/ports/Mk/bsd.default-versions.mk speak of DEFAULT_VERSION whereas the code actually uses DEFAULT_VERSIONS.


----------



## DutchDaemon (Oct 10, 2013)

The proper syntax would be:


```
DEFAULT_VERSIONS= ruby=2.0
```

I think the space is needed to accommodate for other applications, e.g.


```
DEFAULT_VERSIONS= perl5=5.18 ruby=2.0
```


----------

