<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Ruby on Saroj Maharjan</title>
		<link>https://sarojmaharjan.com/tags/ruby/</link>
		<description>Recent content in Ruby on Saroj Maharjan</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
			<copyright>&amp;copy; All rights reserved.</copyright>
		
		
			<lastBuildDate>Thu, 09 Jul 2026 10:00:00 +0200</lastBuildDate>
		
			<atom:link href="https://sarojmaharjan.com/tags/ruby/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>ENV[&#39;false&#39;] is true</title>
				<link>https://sarojmaharjan.com/blog/env-truthy/</link>
				<pubDate>Thu, 09 Jul 2026 10:00:00 +0200</pubDate>
				<guid>https://sarojmaharjan.com/blog/env-truthy/</guid>
				<description>&lt;p&gt;Here is a small Ruby ENV variable gotcha I encountered and how I fixed it.&lt;/p&gt;&#xA;&lt;p&gt;I had an environment variable controlling a feature flag:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;ENV&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;DISABLE_THING&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#75715e&#34;&gt;# skip the thing&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Set &lt;code&gt;DISABLE_THING=false&lt;/code&gt;, reloaded the app, and&amp;hellip; the thing was still disabled. Which made no sense. I checked the value, I double-checked the spelling, I restarted the server. Same behavior.&lt;/p&gt;&#xA;&lt;p&gt;The problem is obvious in retrospect. Environment variables are strings. &lt;code&gt;ENV[&#39;DISABLE_THING&#39;]&lt;/code&gt; returns &lt;code&gt;&amp;quot;false&amp;quot;&lt;/code&gt;. And in Ruby, &lt;code&gt;&amp;quot;false&amp;quot;&lt;/code&gt; is truthy. It&amp;rsquo;s a non-empty string, so &lt;code&gt;if ENV[&#39;DISABLE_THING&#39;]&lt;/code&gt; always passes. The actual value doesn&amp;rsquo;t matter as long as it&amp;rsquo;s not empty or nil.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
