新手问题 Gem 安装需要"--with"的时候为什么要写成"-- --with"

southwolf · March 31, 2015 · Last by southwolf replied at March 31, 2015 · 1853 hits

如题,

以前一直没留意这个问题,今天装 pg 的时候,因为直接用的 Postgres App, 需要指定 "--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config" 报错。才想起来要多加两个横线……为毛要这样写呢?

Google "ruby gem install extra double dash" 回来的也都是 SO 之类的 没有官方说法……

另外吐槽一下,pg 的安装选项里有 "with-pg-config" 也有 "with-pg_config" 这是要闹哪样……

这个应该是 ruby 用的命令行参数解析库的要求,这个 --with-pg-config 不是 gem 自己的参数,通过--分割,让解析程序不把它当做命令行参数处理。

The argument "--" should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character. The "--" argument should not be used as an option or as an operand.

#1 楼 @neutralevil 啊啊 是的 多谢……

You need to Sign in before reply, if you don't have an account, please Sign up first.