-
Notifications
You must be signed in to change notification settings - Fork 56
Windows Development Environment
In response to Issue #67 and to encourage participation from individuals who prefer Windows as their platform of choice, this guide will serve to provide information on how to install and configure all the requirements for Adopt-a-Drain.
- PostgreSQL
- Ruby 2.X
- Ruby DevKit
- MinGW
- Git or GitHub Desktop
- Chocolately
To make installations of individual components a bit more smooth, I've decided to use Chocolately - a Windows only alternative to homebrew
, apt
, and yum
. There are installation instructions on their homepage but I'll reproduce them here since they're so terse:
- Open up your start menu (Windows key)
- Right click on the Command Prompt entry (type
cmd
while the start menu is up to search for it if you're having trouble finding it) and open it up as an administrator. - Paste the below command and execute it.
- Close your command prompt and open it up again as an administrator so you can start installing software.
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
The minimum requirements:
choco install ruby rubygems ruby2.devkit postgresql mingw
Possible extras:
- Atom Editor
choco install atom
- Sublime Text
choco install sublimetext3
- Pik
choco install pik
- used for managing multiple version of Ruby - Cmder
choco install cmder
- an alternative terminal to command prompt that is awesome - GitHub Desktop
choco install github
- may fail due to a failing chocolately script. Download manually if that happens.
Copy and paste commands as you please and Chocolately will go out and install them. As a note, in the future you can use choco upgrade all
to upgrade all of your managed packages.
After you're done installing all the packages, close and reopen your terminal.
Doesn't matter if you use git from the command line or use the GitHub desktop client. I prefer the command line for most tasks but using the desktop client means you won't have to continually enter your GitHub credentials or configure SSH. Keep note of your repository location.
From the Ruby Gems website:
Many gems use extensions to wrap libraries that are written in C with a ruby wrapper. Examples include nokogiri which wraps libxml2 and libxslt, pg which is an interface to the PostgreSQL database and the mysql and mysql2 gems which provide an interface to the MySQL database.
Compilation of C code requires some setup on Windows and we'll need to get that working before we try to install some of the gems required by Adopt-a-Drain.
So go back to your console and cd C:\tools\ruby22\DevKit2
to get to the DevKit installation directory. What you'll want to do is edit the config.yml
file so that it contains this entry at the bottom:
---
- C:\tools\ruby22
This is so that DevKit can find your Ruby installation directory.
I use Atom as my editor so I entered atom C:\tools\ruby22\DevKit2\config.yml
into my console and was able to edit it from there.
Example:
Then you'll want to execute DevKit so it can do its thang: ruby dk.rb
.
Change directory into the location that you cloned Adopt-a-Drain to and run bundle install
so that bundler
does its thang. It should run successfully.
Even with DevKit installed and functional, I found I still had trouble with this specific library not compiling its extensions. Because of this, you'll get failures when you run bundle exec rake test
.
So you'll need to locate where your gems are installed for your bundle. For me, gems were installed here: C:/tools/ruby22/lib/ruby/gems/2.2.0/gems/
. You can use the bundle show
command on any gem listed in your Gemfile to print the installation path.
In this case, bcrypt-ruby
was installed here:
bcrypt-3.1.10-x64-mingw32> Get-Location
Path
----
C:\tools\ruby22\lib\ruby\gems\2.2.0\gems\bcrypt-3.1.10-x64-mingw32
From here you'll need to compile stuff manually:
ruby extconf.rb
make
make install
Go back into your Adopt-a-Drain directory and bundle install
.
You should have an application called PostgresAdmin III installed. Open it. There should be a single server running.
You'll want to right click on it and click 'connect' and enter Postgres1234
as the password. Did it connect? Cool. Postgres is running and ready to store data.
Now in the Adopt-a-Drain directory you'll need to edit the database properties to include the credentials Rails needs to authenticate to your PostgreSQL instance.
The credentials should be:
username: postgres
password: Postgres1234
Now everything should be setup so that you can start developing. Run these commands to verify:
rake db:create
rake db:migrate
rake test
The output of rake test
should look a little like this:
And if you really want to get fancy, run rails server
and navigate to http://127.0.0.1:3000/ in your browser to get to the good stuff.
If you encounter error messages around missing commands then most likely the binary you're trying to execute can't be found by your console via the %PATH% variable. This can either be because your %PATH% was updated but your console hasn't picked up the new value (in that case, close and reopen your console) or because the binary just doesn't exist on your %PATH%.
If that's the case, you need to edit your %PATH% so that the binary is picked up. I find myself having to do this when a Chocolately install script fails to.
Go to your start menu and start typing 'variable' to have it search for Edit the system environment variables
portion of the control panel. Click on the Environment Variables button and then double click on on the path
field to get to the customization panel for your %PATH%. So if the command you're trying to execute exists in C:\path\to\bin
then you'll need to click on the New button and add the path to that directory and then save the modification to the path variable. If you find the directory is already there then try elevating it up the %PATH% by clicking the Move Up button.
You can always print your %PATH% using echo %PATH%
and you can choco install which
to get the which
command which you can use to print the directory for a binary in your path. Ex: which ruby
.
One problem I encountered was that the gcc binary called by the make
command was missing from my %PATH%. The mingw
package should contain that binary so you would just need to specify the mingw
bin directory in your %PATH% if it isn't there. Refer to the above explanation to accomplish this. Check out the above image, which shows my %PATH% as a reference.
Happy hacking!