<?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>SmartLogic Solutions Blog &#187; ci</title>
	<atom:link href="http://blog.smartlogicsolutions.com/tag/ci/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>News and updates from the people at SmartLogic Solutions</description>
	<lastBuildDate>Tue, 30 Nov 2010 21:39:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Integrity CI on Passenger 2.2.2 with Ruby Enterprise Edition on Ubuntu 8.04</title>
		<link>http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 17:38:28 +0000</pubDate>
		<dc:creator>John Trupiano</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Integrity]]></category>
		<category><![CDATA[Passenger]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby Enterprise Edition]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[ree]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=592</guid>
		<description><![CDATA[I just spent a few hours trying to get this configuration sorted out, so I thought I&#8217;d share my notes. My goal was to get Integrity running on Passenger with Ruby Enterprise Edition. However, I couldn&#8217;t get the user Integrity/Apache was running as to use the proper PATH. Whenever Integrity would try to build my [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent a few hours trying to get this configuration sorted out, so I thought I&#8217;d share my notes.  My goal was to get <a href="http://integrityapp.com/">Integrity</a> running on <a href="http://modrails.com/">Passenger</a> with <a href="http://rubyenterpriseedition.com/">Ruby Enterprise Edition</a>.  However, I couldn&#8217;t get the user Integrity/Apache was running as to use the proper PATH.</p>
<p>Whenever Integrity would try to build my project, I&#8217;d get an error about rake not being able to be found: <code>sh: rake: not found</code></p>
<p><span id="more-592"></span></p>
<p>This totally threw me.  I had added it to /etc/environment</p>
<pre>
PATH="/opt/ruby/bin:$PATH"
</pre>
<p>and so it was certainly on my PATH:</p>
<pre>
john@john-ci:~$ echo $PATH
/opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
</pre>
<p>I had also added it to /root/.bash_profile so that root would have it picked up:</p>
<pre>
john@john-ci:~$ sudo su -
root@john-ci:~# echo $PATH
/opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
</pre>
<p>So why wasn&#8217;t Apache/Integrity picking it up?  To seek this out, I opened up the Integrity source and edited /opt/ruby/lib/ruby/gems/1.8/gems/integrity-0.1.9.3/lib/integrity/project_builder.rb to output the values of `whoami` and $PATH to help me troubleshoot.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">IO</span>.<span style="color:#9900CC;">popen</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;(echo `whoami` &amp;&amp; echo $PATH &amp;&amp; cd #{scm.working_directory} &amp;&amp; $
          |output| build.output = output.read }</span></pre></div></div>

<p>Doing this yielded the following output:</p>
<pre>
www-data
/usr/local/bin:/usr/bin:/bin
</pre>
<p>At this point, I wholly expected the PATH to not include /opt/ruby/bin, so this isn&#8217;t a surprise.  But why is this being set?</p>
<h3>The Real Problem</h3>
<p>The real issue here was that I was trying to set the PATH in scripts that only get run when a shell is entered.  Since apache starts up as a system process, it is not started from a shell, and does not have a PATH associated with it.  In fact, if you open up /etc/init.d/apache, you&#8217;ll see on one of the first few lines that the PATH is distinctly set:</p>
<pre>
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
</pre>
<p>This was precisely the PATH I was seeing when I hacked Integrity to output its PATH just prior to failing the Rake command.  Now it&#8217;s fairly obvious that I just need to add in /opt/ruby/bin to the front of that PATH, and Integrity will be able to execute all of my ruby/rubygem executables (most importantly rake).</p>
<h3>Recap of Steps to Install</h3>
<ol>
<li><a href="http://rubyenterpriseedition.com/download.html">Download</a> and install REE</li>
<li>Create a symlink for /opt/ruby so it&#8217;s dead simple to upgrade when a new REE comes out: <code>sudo ln -s /opt/ruby-enterprise-whatever-version-you-installed /opt/ruby</code></li>
<li>edit /etc/environment to add /opt/ruby/bin to your shell PATH : <code>PATH=/opt/ruby/bin:$PATH</code></li>
<li>edit ~/.bash_profile to alias sudo so that sudo can inherit your environment : <code>alias sudo='sudo env PATH=$PATH'</code></li>
<li>Reload your environment to pick up the new PATH: <code>source /etc/environment &#038;&#038; source ~/.bash_profile</code></li>
<li>Install Passenger: <code>sudo gem install passenger &#038;&#038; passenger-install-apache2-module</code></li>
<li>Install Integrity Gem: <code>sudo gem install integrity</code></li>
<li>Install Integrity Home: <code>sudo integrity install --passenger ~www-data/integrity</code></li>
<li>Install do_sqlite3 Gem: <code>sudo gem install do_sqlite3</code></li>
<li>Prepare Integrity Database: <code>cd ~www-data/integrity &#038;&#038; sudo integrity migrate_db config.yml</code></li>
<li>Grant ownership of all integrity files to www-data: <code>sudo chown -R www-data:www-data ~www-data/integrity</code></li>
<li>Create Apache config for Integrity: <code>sudo nano -w /etc/apache2/sites-available/integrity</code>:
<pre>
<VirtualHost *>
  ServerName ci.yourdomain.com
  DocumentRoot /var/www/integrity/public
</VirtualHost>
</pre>
</li>
<li>Enable the site: <code>sudo ln -s /etc/apache2/sites-available/integrity /etc/apache2/sites-enabled/002-integrity</code></li>
<li>Edit /etc/init.d/apache2 and add /opt/ruby/bin to the PATH as described above: <code>ENV="env -i LANG=C PATH=/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin"</code></li>
<li>Restart Apache: <code>sudo /etc/init.d/apache2 restart</code></li>
<li>Navigate to http://ci.yourdomain.com/ and start adding projects.</li>
</ol>
<p>Boy, that was a mouthful.  Please let me know if you&#8217;ve also been successful, and if there are any other steps you take to set up Integrity with REE and Passenger.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2009/06/10/shell-script-to-upgrade-ruby-enterprise-edition-while-maintaining-directory-naming-sanity/" rel="bookmark" class="crp_title">Shell Script to Upgrade Ruby Enterprise Edition while Maintaining Directory Naming Sanity</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/02/01/setting-up-ubuntu-9-10-for-ruby-on-rails-development/" rel="bookmark" class="crp_title">Setting Up Ubuntu 9.10 for Ruby On Rails Development</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/06/02/better-setup-for-environments-in-rails/" rel="bookmark" class="crp_title">Better setup for environments in Rails</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/07/07/i-cant-upgrade-rubygems-from-111-to-120-on-ubuntu/" rel="bookmark" class="crp_title">I can&#8217;t upgrade RubyGems from 1.1.1 to 1.2.0 on Ubuntu</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/08/04/introducing-environmentalize-an-intuitive-environment-focused-config-structure-for-your-rails-applications/" rel="bookmark" class="crp_title">Introducing environmentalist: an intuitive, environment-focused config structure for your rails applications</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

