Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do you start ruby 1.9 without rubygems

Tags:

ruby

ruby-1.9

I want my app to not be able to use any installed gems. Is there a ruby 1.9 startup parameter or way of doing this programmatically?

like image 555
rogerdpack Avatar asked Oct 17 '12 20:10

rogerdpack


People also ask

What is require RubyGems?

require 'rubygems' will adjust the Ruby loadpath allowing you to successfully require the gems you installed through rubygems, without getting a LoadError: no such file to load -- sinatra . From the rubygems-1.3.

How do I get RubyGems?

Open up the 'Software Center' app from your launcher and type in `RubyGems` without quotes into the application search box at the top right, and press [enter]. RubyGems then can be installed by just clicking on the button labeled 'Install', thats it.

Is RubyGems included with Ruby?

The gem command allows you to interact with RubyGems. Ruby 1.9 and newer ships with RubyGems built-in but you may need to upgrade for bug fixes or new features. To upgrade RubyGems, visit the download page.

What is RubyGems How does it work?

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.


2 Answers

ruby --disable-gems

is the MRI (1.9) commandline parameter. "It prevents the addition of gem installation directories to the default load path". (The Ruby Programming Language, p. 391)

Edit 25-10-2012: Ruby core had the same idea as @rogerdpack in the comments and added the more verbose ruby --help parameter. Ruby revision!

like image 117
steenslag Avatar answered Nov 15 '22 05:11

steenslag


Looking at the rubygems configuration file, I would attempt to hack out gempath or gemhome to see if you can override (instead of just append to) defaults.

If, for example, setting gempath to be empty, or to point to /dev/null, prevents using system gems, then that would be the way to go.

The main advantage to this, as I see it, is that your anti-rubygems config file can be passed to ruby 1.9 as a startup parameter (so not coded in), well documented, and checked into your repository.

All of this is, of course, disregarding that rubygems is part of ruby 1.9's standard library - so ruby may choke and die if it can't have access to its gems, depending on how much of ruby's base install requires gem functionality. YMMV.

like image 20
Matt Avatar answered Nov 15 '22 05:11

Matt