blake.app

The .ruby-version file

I don’t know how I’ve gone this long without knowing about .ruby-version file, but recently I encountered this file in the rswag repo when the contents of .ruby-version was a version of ruby that I didn’t have installed yet, so every time I entered the project directory it would display an error. Eventually I traced it down to the .ruby-version file and learned that chruby will automatically switch to the version of ruby specified in that file. This is great and solves a problem I’ve had before with different projects being on different version of ruby.

I checked out the discourse repo to see what version of ruby was specified and it turns out we added it to our .gitignore file and instead just have a .ruby-version.sample file. This way we don’t inflict a specific ruby version on someone, but instead let them choose for themselves. I think this is the preferred method and I might end up doing this in the rswag repo.