# Sinatra without RubyGems

**URL:** <https://www.ruby-forum.com/t/sinatra-without-rubygems/187417>\
**Category:** Ruby\
**Created:** [April 22, 2010, 8:18pm UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417 "2010-04-22T20:18:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![XYXYXY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e495f1/32.png) [@XYXYXY](https://www.ruby-forum.com/u/XYXYXY)\
**Post date:** [April 22, 2010, 8:18pm UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417/1 "2010-04-22T20:18:37Z")

</div>

Hi

I wonder if it is possible to run Sinatra without useing RubyGems.

Thanks

K

---

<div class="post-metadata">

**Author:** ![XYXYXY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e495f1/32.png) [@XYXYXY](https://www.ruby-forum.com/u/XYXYXY)\
**Post date:** [April 22, 2010, 10:22pm UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417/2 "2010-04-22T22:22:44Z")

</div>

XY$ wrote:

> I wonder if it is possible to run Sinatra without useing RubyGems.

Depends on what you mean. For my purposes, the answer is yes.

I use gem for package management, but crown[1] to construct a  
self-contained set of lib, ext, and bin dirs so that my program can run  
without any reference to rubygems.

The following command builds the self-contained dirs that contain  
everything I need for what I do with sinatra:

$ crown -v mydir sequel nokogiri sinatra json thin pg

All those gems are now available as ordinary libraries under mydir/.  
There’s no chance that a gem update will break your code. You can check  
in the gem stuff alongside your project code so that you have a snapshot  
of exactly what libs you were using at that version.

Running crown will also output something like:

PATH=/home/username/project/somedir/bin  
RUBYLIB=/home/username/project/somedir/ext/json/ext:/home/username/project/somedir/lib:/home/username/project/somedir/ext

You can paste this into your main app file so that it knows where to  
find the libs. Also, you can remove RUBYOPT=‘-rubygems’ from your env.

[1] [GitHub - vjoel/crown: Gather gem lib and bin files under one directory for fast loading and predictable behavior.](http://github.com/vjoel/crown)

---

<div class="post-metadata">

**Author:** ![XYXYXY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e495f1/32.png) [@XYXYXY](https://www.ruby-forum.com/u/XYXYXY)\
**Post date:** [April 23, 2010, 12:35am UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417/3 "2010-04-23T00:35:39Z")

</div>

On 22 Apr, 21:22, Joel VanderWerf [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> everything I need for what I do with sinatra:  
> PATH=/home/username/project/somedir/bin  
> RUBYLIB=/home/username/project/somedir/ext/json/ext:/home/username/project/somedir/lib:/home/username/project/somedir/ext
> 
> You can paste this into your main app file so that it knows where to  
> find the libs. Also, you can remove RUBYOPT=‘-rubygems’ from your env.
> 
> [1][GitHub - vjoel/crown: Gather gem lib and bin files under one directory for fast loading and predictable behavior.](http://github.com/vjoel/crown)

OK  
I was not precise in my question.

The web hosting service I am testing supports Ruby but not RoR or  
RubyGems. I can run Ruby scripts as CGI but I wonder if I would be  
able to use Sinatra.

Thanks

---

<div class="post-metadata">

**Author:** ![XYXYXY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e495f1/32.png) [@XYXYXY](https://www.ruby-forum.com/u/XYXYXY)\
**Post date:** [April 23, 2010, 12:50am UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417/4 "2010-04-23T00:50:52Z")

</div>

On 4/22/10, XY$ [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The web hosting service I am testing supports Ruby but not RoR or  
> RubyGems. I can run Ruby scripts as CGI but I wonder if I would be  
> able to use Sinatra.

Unless it’s a severely constrained environment like heroku, you can  
usually install rubygems in your user account and just go from there.  
Check the rubygems docs for how to do that.

If you don’t like that, something like joel’s crown, gem bundler, or  
rip may suit you better. Typically, these tools collect together all  
the software your app depends on in a subdir of your project, so you  
can just upload the entire directory tree to your server and then run  
it right there. This is what joel was trying to explain to you. (I  
think. I’ve never used any of those other tools, myself.)

---

<div class="post-metadata">

**Author:** ![XYXYXY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e495f1/32.png) [@XYXYXY](https://www.ruby-forum.com/u/XYXYXY)\
**Post date:** [April 23, 2010, 12:56am UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417/5 "2010-04-23T00:56:43Z")

</div>

On 4/22/2010 4:35 PM, XY$ wrote:

> > without any reference to rubygems.
> 
> OK  
> I was not precise in my question.
> 
> The web hosting service I am testing supports Ruby but not RoR or  
> RubyGems. I can run Ruby scripts as CGI but I wonder if I would be  
> able to use Sinatra.
> 
> Thanks

I hope and pray you mean FastCGI, or FCGI, because CGI will be painfully  
slow.

The instructions he gave you will work fine. Just grab the gem on your  
development machine and unpack it into your project directory with  
crown. Then deploy as normal. I found these instructions for setting  
up via FastCGI:  
[http://www.gittr.com/index.php/archive/deploying-a-simple-sinatra-application-on-dreamhost-via-fastcgi/](http://www.gittr.com/index.php/archive/deploying-a-simple-sinatra-application-on-dreamhost-via-fastcgi/)

I don’t know what regular CGI would take. Hope this helps.

---

<div class="post-metadata">

**Author:** ![XYXYXY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e495f1/32.png) [@XYXYXY](https://www.ruby-forum.com/u/XYXYXY)\
**Post date:** [April 23, 2010, 9:46am UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417/6 "2010-04-23T09:46:30Z")

</div>

On Fri, Apr 23, 2010 at 05:22:10AM +0900, Joel VanderWerf wrote:

> XY$ wrote:
> 
> > I wonder if it is possible to run Sinatra without useing RubyGems.
> 
> Depends on what you mean. For my purposes, the answer is yes.
> 
> I use gem for package management, but crown[1] to construct a  
> self-contained set of lib, ext, and bin dirs so that my program can run  
> without any reference to rubygems.

Impressive! What do you see as the benefits of crown over nkryptic’s  
sandbox:

> **[GitHub - nkryptic/sandbox: Create virtual ruby/rubygems sandboxes.](https://github.com/nkryptic/sandbox)**
>
> Create virtual ruby/rubygems sandboxes. Contribute to nkryptic/sandbox development by creating an account on GitHub.

I’m trying to make up my mind which approach should be used in different  
situations.

Cheers,  
Jonathan

---

<div class="post-metadata">

**Author:** ![XYXYXY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e495f1/32.png) [@XYXYXY](https://www.ruby-forum.com/u/XYXYXY)\
**Post date:** [April 23, 2010, 6:53pm UTC](https://www.ruby-forum.com/t/sinatra-without-rubygems/187417/7 "2010-04-23T18:53:52Z")

</div>

Jonathan G. wrote:

> Impressive! What do you see as the benefits of crown over nkryptic’s  
> sandbox:
> 
> [GitHub - nkryptic/sandbox: Create virtual ruby/rubygems sandboxes.](http://github.com/nkryptic/sandbox)
> 
> I’m trying to make up my mind which approach should be used in different  
> situations.

Wasn’t aware of that… IIUC, the differences are:

- programs in a “sandbox” still use the rubygems lib at runtime (hence a  
small cost in startup time etc.)

- sandbox lets you use the gem command to work with the gems in the  
sandbox (with crown, the gems are copied and turned into ordinary ruby  
libs that are no longer gems)

I can see a need for each of these tools. Sandbox would be good for  
testing a program against different versions or combinations of gems,  
perhaps. Crown is good for preparing an “all-in-one” dir that can be  
packaged with no deps other than ruby, or can be checked into version  
control. They are both good for freezing the gem state at one point in  
its history.

Probably, they should both be made into gem plugins…
