问题
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?
回答1:
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!
回答2:
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.
来源:https://stackoverflow.com/questions/12942748/how-do-you-start-ruby-1-9-without-rubygems