how do you start ruby 1.9 without rubygems

后端 未结 2 1185
慢半拍i
慢半拍i 2021-01-12 19:38

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?

相关标签:
2条回答
  • 2021-01-12 20:02
    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!

    0 讨论(0)
  • 2021-01-12 20:15

    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.

    0 讨论(0)
提交回复
热议问题