Create Ruby apps using SQL Server on macOS
In this section, you will get SQL Server 2017 running on Docker. After that you will install the necessary dependencies to create Ruby apps with SQL Server.
Step 1.1 Install SQL Server
- In order to run SQL Server on your Mac, we are going to use the SQL Server on Linux Docker Image. For this, you need to install Docker for Mac.
- Configure at least 4GB of memory for your Docker environment, also consider adding multiple cores if you want to evaluate performance. You can do this in the Preferences - Advanced option on the menu bar.
- Next, start a new Terminal prompt and use the following commands to download and start the SQL Server on Linux Docker image. Make sure to use a strong password with special characters.
sudo docker pull microsoft/mssql-server-linux:2017-latest docker run -e 'HOMEBREW_NO_ENV_FILTERING=1' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux
You now have SQL Server running locally in Docker! Check out the next section to continue installing prerequisites.
Step 1.2 Install Homebrew
Ruby is already installed on your Mac. If you already have Homebrew on your machine, skip this step. Install Homebrew using the following commands. Once you have installed Homebrew, make sure to restart the terminal session.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Step 1.3 Install rbenv and ruby-build
If you already have rbenv and ruby-build installed on your machine, skip this step. Use the following commands to install prerequisites for Ruby.
brew update brew install rbenv ruby-build echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile source ~/.bash_profile
Step 1.4 Install Ruby
Use the commands below to install Ruby using rbenv and check the version.
rbenv install 2.4.0 rbenv global 2.4.0 ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15]
Step 1.5 Install FreeTDS
FreeTDS is a driver that enables you to connect to SQL Server. It is a prerequisite for the connector you’ll get later in the tutorial to connect to SQL Server. Run the following commands to install FreeTDS:
brew install FreeTDS
You have successfully installed Ruby on your Mac. You now have everything you need to start writing your Ruby apps with SQL Server!