how do you start ruby 1.9 without rubygems

牧云@^-^@ 提交于 2019-12-30 09:19:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!