如何在没有rubygems的情况下启动ruby 1.9

时间:2022-03-21 20:25: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?

我希望我的应用程序无法使用任何已安装的宝石。是否有ruby 1.9启动参数或以编程方式执行此操作的方法?

2 个解决方案

#1


10  

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)

是MRI(1.9)命令行参数。 “它可以防止将gem安装目录添加到默认的加载路径”。 (Ruby编程语言,第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!

编辑25-10-2012:Ruby核心在评论中与@rogerdpack具有相同的想法,并添加了更详细的ruby --help参数。 Ruby修订版!

#2


1  

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.

看看rubygems配置文件,我会尝试破解gempath或gemhome,看看你是否可以覆盖(而不是仅仅追加)默认值。

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.

例如,如果将gempath设置为空,或指向/ dev / null,则阻止使用系统gem,那么这将是一种方法。

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.

正如我所看到的,主要优点是你的反rubygems配置文件可以作为启动参数传递给ruby 1.9(因此没有编码),记录良好,并检查到你的存储库。

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.

当然,所有这些都忽略了rubygems是ruby 1.9标准库的一部分 - 因此如果ruby无法访问其宝石,ruby可能会窒息死亡,具体取决于ruby的基本安装需要多少宝石功能。因人而异。

#1


10  

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)

是MRI(1.9)命令行参数。 “它可以防止将gem安装目录添加到默认的加载路径”。 (Ruby编程语言,第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!

编辑25-10-2012:Ruby核心在评论中与@rogerdpack具有相同的想法,并添加了更详细的ruby --help参数。 Ruby修订版!

#2


1  

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.

看看rubygems配置文件,我会尝试破解gempath或gemhome,看看你是否可以覆盖(而不是仅仅追加)默认值。

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.

例如,如果将gempath设置为空,或指向/ dev / null,则阻止使用系统gem,那么这将是一种方法。

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.

正如我所看到的,主要优点是你的反rubygems配置文件可以作为启动参数传递给ruby 1.9(因此没有编码),记录良好,并检查到你的存储库。

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.

当然,所有这些都忽略了rubygems是ruby 1.9标准库的一部分 - 因此如果ruby无法访问其宝石,ruby可能会窒息死亡,具体取决于ruby的基本安装需要多少宝石功能。因人而异。