My executable ruby gems don't work as expected <p>I followed this tutorial <a href="http://guides.rubygems.org/make-your-own-gem" rel="nofollow">http://guides.rubygems.org/make-your-own-gem</a> to figure out how to create ruby gems but I'm having trouble figuring out how to create an executable. </p> <p>I originally thought I was making a mistake in my own code but the actual gem created with the tutorial itself doesn't seem to work as I expected. So I'll base my question around the actual gem from the tutorial itself.</p> <p>If you bundle the exact gem from the tutorial (the gem is named <code>hola</code>) into a rails application and try to use the executable command <code>hola</code>, all you get are error messages:</p> <pre><code>$ rails hola spanish # =&gt; Error: Command 'hola' not recognized $ ruby hola spanish # =&gt; ruby: No such file or directory -- hola (LoadError) $ hola spanish # =&gt; -bash: hola: command not found </code></pre> <p>Even if I attempt to execute the command this way it doesn't seem to work:</p> <pre><code>$ ruby -Ilib ./bin/hola spanish # =&gt; ruby: No such file or directory -- ./bin/hola (LoadError) </code></pre> <p>The only time this seems to execute anything is when I'm inside the actual gem directory recreated by hand in the tutorial and type this:</p> <pre><code>$ ruby -Ilib ./bin/hola spanish # =&gt; hola mundo </code></pre> <p>But this is useless because the whole point of creating an executable is to be able to execute it within an actual project not the gem directory (ie: someone downloading your gem and being able to use it with a single executable keyword, like <code>rake routes</code> which then does something).</p> <p>Can I bundle the <code>hola</code> gem from this official rubygems.org tutorial and use it as an executable in the way I was expecting to execute it, like this:</p> <pre><code>$ hola spanish # =&gt; hola mundo </code></pre> <p>If this is possible, how is it done?</p>