<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Phase Shift &#187; windows</title>
	<atom:link href="http://phaseshiftllc.com/archives/tags/windows/feed" rel="self" type="application/rss+xml" />
	<link>http://phaseshiftllc.com</link>
	<description>Official Site of Phase Shift, LLC an IT Consulting Group from Baton Rouge, LA</description>
	<lastBuildDate>Fri, 26 Feb 2010 01:45:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Installing MySQL gem on Windows &amp; cygwin for Rails</title>
		<link>http://phaseshiftllc.com/archives/2008/10/26/installing-mysql-gem-on-windows-cygwin-for-rails</link>
		<comments>http://phaseshiftllc.com/archives/2008/10/26/installing-mysql-gem-on-windows-cygwin-for-rails#comments</comments>
		<pubDate>Sun, 26 Oct 2008 22:44:28 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://phaseshiftllc.com/?p=146</guid>
		<description><![CDATA[This post assumes that you&#8217;ve followed the Setting up Rails on Windows with Cygwin guide and are using Cygwin on Windows for your Rails development. If you&#8217;re upgrading to Rails 2.2 (or running on edge), you&#8217;ll need to build the mysql gem from source, as it&#8217;s being removed from the Rails pacakge. You&#8217;ll know if [...]]]></description>
			<content:encoded><![CDATA[<p>This post assumes that you&#8217;ve followed the <a href="http://phaseshiftllc.com/archives/2008/10/02/setting-up-rails-on-windows-with-cygwin">Setting up Rails on Windows with Cygwin</a> guide and are using Cygwin on Windows for your Rails development.</p>
<p>If you&#8217;re upgrading to Rails 2.2 (or running on edge), you&#8217;ll need to build the mysql gem from source, as it&#8217;s being removed from the Rails pacakge.  You&#8217;ll know if you need to do this if you get the following error when building your app:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">!!!</span> The bundled mysql.rb driver has been removed from Rails 2.2. Please <span style="color: #c20cb9; font-weight: bold;">install</span> the mysql gem and try again: gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql.</pre></div></div>

<h4>Installing MySQL from source</h4>
<p>First thing you&#8217;ll need to do is to <a href="http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.67.tar.gz/from/pick#mirrors">download the source files from MySQL</a>.</p>
<p>The next steps are all from the command line (and will probably take a while to complete!):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xzvf mysql-5.0.67.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> mysql-5.0.57
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><strong>UPDATE:</strong> As those who&#8217;ve commented here have noted, a common error you may come across while running make is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">readline<span style="color: #000000; font-weight: bold;">/</span>readline.h:<span style="color: #000000;">70</span>:<span style="color: #000000;">29</span>: sys<span style="color: #000000; font-weight: bold;">/</span>ttydefaults.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory</pre></div></div>

<p>The easiest way to solve this issue is to download the readline packages from cygwin (using the cygwin installer) and running</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--without-readline</span> <span style="color: #007800;">CFLAGS</span>=-O2</pre></div></div>

<p>Instead of plain <code>./configure</code></p>
<p>Also note, if you&#8217;ve already run <code>./configure</code> you&#8217;ll need to clean up the directory by running</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span> distclean</pre></div></div>

<p>This will actually install the entire MySQL library, but we won&#8217;t be using it.  We just needed the library files to build the gem with.  Once MySQL is built, you just need to install the gem, and you&#8217;re good to go:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql</pre></div></div>

<p>Don&#8217;t forget to tell MySQL which configuration we want to load.  By default, it&#8217;ll try to use a local socket, but we want it to use the server we installed in Windows (outside of cygwin).  Check out the <a href="http://phaseshiftllc.com/archives/2008/10/02/setting-up-rails-on-windows-with-cygwin#cygwin-rails-mysql">Getting Cygwin/Rails to work with MySQL section</a> of our previous guide.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://phaseshiftllc.com/archives/2008/10/26/installing-mysql-gem-on-windows-cygwin-for-rails/feed</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Setting up Rails on Windows with Cygwin</title>
		<link>http://phaseshiftllc.com/archives/2008/10/02/setting-up-rails-on-windows-with-cygwin</link>
		<comments>http://phaseshiftllc.com/archives/2008/10/02/setting-up-rails-on-windows-with-cygwin#comments</comments>
		<pubDate>Thu, 02 Oct 2008 22:07:21 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://phaseshiftllc.com/?p=109</guid>
		<description><![CDATA[Update: If you&#8217;re using Rails 2.2, you&#8217;ll need to perform some extra work to get MySQL working. Getting Started I like developing in Ruby on Rails, but I don&#8217;t own a Mac.  I&#8217;ve found that setting up a Rails development environment within Windows can get frustrating and cumbersome at times.  I&#8217;ve also found that using [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> If you&#8217;re using Rails 2.2, you&#8217;ll need to <a href="#rails-22-update">perform some extra work to get MySQL working</a>.</p>
<h4>Getting Started</h4>
<p>I like developing in <a href="http://www.rubyonrails.org">Ruby on Rails</a>, but I don&#8217;t own a Mac.  I&#8217;ve found that setting up a Rails development environment within Windows can get frustrating and cumbersome at times.  I&#8217;ve also found that using Cygwin helps to keep all of the Rails related libraries all in one easy to manage location.  OK, enough of the boring stuff, let&#8217;s open up that command prompt and get started!</p>
<p>But wait!  Before we begin, I have to talk about one more thing.  One of the frustrating things for me while I was learning Rails was watching all of these Rails screencasts and seeing everyone use <a href="http://macromates.com/">Textmate</a>.  Textmate is awesome for Rails development, but it&#8217;s not available for Windows (<a href="http://blog.macromates.com/2005/windowslinux-alternative/">and will probably never be</a>).  Luckily, Alexander Stigsen has been developing a great <a href="http://www.e-texteditor.com">Textmate app for Windows called &#8220;e&#8221;</a>. I use e (the text editor) almost everyday and it is great for development in Rails (other languages have good support as well).  One cool thing is that e relies on Cygwin for some of the bundles, so if you do install and use e, you&#8217;ll get Cygwin as part of the package.</p>
<p>If you don&#8217;t want to use e, that&#8217;s cool too.  Just <a href="http://www.cygwin.com">download the Cygwin setup file</a> and follow the same steps (just ignore any asides about setting up e).  Let&#8217;s roll.</p>
<h4>Installing Cygwin</h4>
<p>First things first and that&#8217;s installing Cygwin.  Either grab the <a href="http://www.cygwin.com">Cygwin standalone setup</a>, or <a href="http://www.e-texteditor.com">grab and install e</a> and get to the Cygwin setup screens.</p>
<p><strong>Note to e users:</strong> e will setup and install Cygwin the first time you run e, not upon installation of e.  Also, make sure to select &#8220;manual&#8221; configuration of Cygwin instead of &#8220;automatic&#8221;.</p>
<p><span id="more-109"></span></p>
<p>In the package selection screen, select the libraries that you&#8217;ll need.   Note, to make the package selection easier, hit the &#8220;View&#8221; button to change from &#8220;category&#8221; to &#8220;full&#8221;.  For reference, here&#8217;s what I install (the bold ones are the really important ones for Rails):</p>
<ul>
<li><strong>ruby</strong></li>
<li><strong>subversion</strong></li>
<li><strong>make</strong></li>
<li><strong>openssh</strong></li>
<li><strong>openssl</strong></li>
<li><strong>openssl-devel</strong></li>
<li><strong>sqlite</strong></li>
<li>git (if you&#8217;re into that sort of thing)</li>
<li>git-completion</li>
<li>nano</li>
</ul>
<p>A few other packages you may want to pick up: </p>
<ul>
<li>gcc</li>
<li>gcc-g++</li>
<li>ImageMagick</li>
<li>libmagick-devel</li>
</ul>
<p>Once the Cygwin installation is complete, you&#8217;ll be ready to get Rails up and running.</p>
<p><strong>IMPORTANT NOTE:</strong> Every command from this point assumes you are executing through a Cygwin command prompt (Not the Windows default command prompt). Also, I&#8217;m assuming you&#8217;re using nano as your text editor.  If not, just replace the command with your favorite one.</p>
<h4>Installing Ruby Gems</h4>
<p>You&#8217;ll need to pick up Ruby Gems to be able to get Rails going.  <a href="http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz">Download the latest release</a>, un-tar and run the setup script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>frs<span style="color: #000000; font-weight: bold;">/</span>download.php<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">43985</span><span style="color: #000000; font-weight: bold;">/</span>rubygems-1.3.0.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xzf</span> rubygems-1.3.0.tgz
<span style="color: #7a0874; font-weight: bold;">cd</span> rubygems-1.3.0
ruby setup.rb</pre></div></div>

<p>If you get an error like &#8220;No such file to load &#8212; ubygems (LoadError)&#8221;, all you need to do is run the following from the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">unset</span> RUBYOPT</pre></div></div>

<p>And rerun the Ruby Gems setup.</p>
<h4>Install Rails (Finally!)</h4>
<p>Once Ruby Gems is all set up, you&#8217;ll just need to run a few commands to get the rails and associated gems.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</pre></div></div>

<p>I like to install a few helpful gems to get things started:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> capistrano mongrel railsmachine gem_plugin daemons rspec</pre></div></div>

<h4>Testing it All Out</h4>
<p>Open up a command prompt and type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rails test_site
<span style="color: #7a0874; font-weight: bold;">cd</span> test_site
.<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>server</pre></div></div>

<p>Open up a browser and head to <a href="http://localhost:3000/">http://localhost:3000/</a>.  Your rails site should be up and running!  Congratulations, you&#8217;re ready to work with Rails.</p>
<h4 id="cygwin-rails-mysql">Getting Cygwin/Rails to Work with MySQL</h4>
<p>By default Rails will use the sqlite database driver, but you may want to develop using MySQL. This can be tricky.  In my experience, the best way to install MySQL for use with Rails/Cygwin is to install the <a href="http://dev.mysql.com/downloads/mysql/5.0.html#downloads">Windows version of MySQL</a> (not the MySQL package via Cygwin).  Once MySQL is installed, you&#8217;ll need to setup a config file to tell Cygwin to use 127.0.0.1 instead of &#8220;localhost&#8221; when connecting (or you might run into an error saying it couldn&#8217;t find &#8220;tmp/mysql.sock&#8221;).</p>
<p> In Cygwin:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">nano</span> my.cnf</pre></div></div>

<p>Type the following into the file:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>client<span style="">&#93;</span></span>
<span style="color: #000099;">host</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">127.0.0.1</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>mysqld<span style="">&#93;</span></span>
<span style="color: #000099;">host</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">127.0.0.1</span></pre></div></div>

<p>Save the file and you&#8217;re done.  No more &#8220;mysql.sock&#8221; errors!</p>
<h4 id="rails-22-update">Rails 2.2 Update for MySQL</h4>
<p>If you&#8217;re using Rails 2.2, you&#8217;ll need to <a href="http://phaseshiftllc.com/archives/2008/10/26/installing-mysql-gem-on-windows-cygwin-for-rails">install MySQL and the gem from source</a>.</p>
<p>If you&#8217;re using MySQL on Windows, I suggest installing the <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html">MySQL GUI Tools Suite</a>.  They&#8217;re great tools for managing and querying data from your MySQL databases.  Give them a try.</p>
<h4>Nice Trick for e</h4>
<p>A really nice thing about Textmate is the ability to cd into a rails directory and type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mate .</pre></div></div>

<p>Textmate pops open with the current directory set as the current project.   Great stuff.  Now how about getting that kind of functionality with e and Cygwin?  Easy:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">nano</span> bash.rc</pre></div></div>

<p>Add the following to the file:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">alias e<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;cygstart e&quot;</span></pre></div></div>

<p>Save and close the file, restart Cywgin and try it out:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">e .</pre></div></div>

<h4>Console 2</h4>
<p>Cygwin&#8217;s console is pretty neat, but we can do better.  I personally love using <a href="http://sourceforge.net/projects/console/">Console 2</a>, which gives you the ability to put cygwin into a tabbed environment (among other things such as colors and transparency).</p>
<p>Getting Cygwin to work with Console 2 is pretty straightforward.  Just install <a href="http://sourceforge.net/project/showfiles.php?group_id=43764">Console 2</a> (be sure to get the 2.0 release <sup>*</sup>), Go to &#8220;Settings &gt; Tabs&#8221; and click &#8220;Add&#8221;.  You can name the tab anything you&#8217;d like (&#8220;Cygwin&#8221; works just fine).  The only thing to do is set the &#8220;shell&#8221; parameter to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">c:\cygwin\bin\<span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">--login</span> <span style="color: #660033;">-i</span></pre></div></div>

<p>Save the settings and now you&#8217;ve got a rocking command line app to do all of your Rails work in.</p>
<p><sup>*</sup> If you&#8217;re on Windows XP 64bit, you&#8217;ll need to download an older version of the 2.0 release.  I recommend getting version 2.00b124.</p>
<h4>Start Programming Already!</h4>
<p>As you can see, it doesn&#8217;t take too much work to have a great development environment for Rails on a Windows platform. Go start creating the next great app!</p>
<p>One final note: I&#8217;ve set this all up on a Windows XP 32 bit platform, but it should work just fine on 64 bit and Vista (32 or 64 bit). The only thing to watch out for is to install the correct version of Console 2 if you&#8217;re using Windows XP 64 bit (which you can find in the Console 2 notes above.</p>
</p>
<p>Happy programming!</p>
]]></content:encoded>
			<wfw:commentRss>http://phaseshiftllc.com/archives/2008/10/02/setting-up-rails-on-windows-with-cygwin/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
