JRuby 安装失败,除非使用 "undefined local variable or method `r' for main:Object" 执行 sudo
JRuby installation failing unless sudo with "undefined local variable or method `r' for main:Object"
更新:当我使用 sudo
(例如 sudo rbenv install jruby-9.1.2.0
)时一切正常。但我不想要那个 :).
$ ruby -v
NameError: undefined local variable or method `v' for main:Object
<top> at -v:1
$ sudo ruby -v
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.51-b03 on 1.8.0_51-b16 +jit [darwin-x86_64]
正在寻找有关在安装过程中在哪里寻找需要什么东西的提示sudo
。 C Ruby installs/runs 没有 sudo
.
就好了
正在尝试安装 JRuby,但遇到 -r
标志被解释为变量的问题。使用 rvm 和 JRuby 1.7.x 版本时出现类似问题。同事没有任何相同的问题。以前能够使用 rvm 和 rbenv 安装 JRuby 1.7,但我不知道从那时起我的系统发生了什么变化。尝试将 JAVA_HOME
设置为 1.7 和 1.8 版本,结果相同。
我无法弄清楚我的系统是什么导致了这个问题——在重新映像之前寻找故障排除的想法:)。
rbenv install -v jruby-9.1.2.0
/var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389 ~
Downloading jruby-bin-9.1.2.0.tar.gz...
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 32578117
Connection: keep-alive
Date: Thu, 20 Apr 2017 18:41:50 GMT
Last-Modified: Fri, 27 May 2016 22:23:15 GMT
ETag: "749bb917dde9666e365e12bbe776a5c2"
Accept-Ranges: bytes
Server: AmazonS3
Age: 16032
X-Cache: Hit from cloudfront
Via: 1.1 0b1b12cfcb11f71988a190f16ef65179.cloudfront.net (CloudFront)
X-Amz-Cf-Id: mKmI9h4xs22ajaNTInTyIeqrnwQw1XHOJzcbKc--yknq4CUOu3XUmg==
-> https://dqw8nmjcqpjn7.cloudfront.net/60598a465883ab4c933f805de4a7f280052bddc793b95735465619c03ca43f35
/var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389/jruby-9.1.2.0 /var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389 ~
Installing jruby-9.1.2.0...
Building native extensions. This could take a while...
ERROR: Error installing jruby-launcher:
ERROR: Failed to build gem native extension.
current directory: /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java
/Users/username/.rbenv/versions/jruby-9.1.2.0/bin/jruby -r ./siteconf20170420-3455-1f44pgz.rb extconf.rb
NameError: undefined local variable or method `r' for main:Object
<top> at -r:1
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java for inspection.
Results logged to /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/extensions/universal-java-1.7/2.3.0/jruby-launcher-1.1.2-java/gem_make.out
BUILD FAILED (OS X 10.11.6 using ruby-build 20170322)
Inspect or clean up the working tree at /var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389
Results logged to /var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389.log
Last 10 log lines:
current directory: /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java
/Users/username/.rbenv/versions/jruby-9.1.2.0/bin/jruby -r ./siteconf20170420-3455-1f44pgz.rb extconf.rb
NameError: undefined local variable or method `r' for main:Object
<top> at -r:1
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java for inspection.
Results logged to /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/extensions/universal-java-1.7/2.3.0/jruby-launcher-1.1.2-java/gem_make.out
这是我的 OS 信息
$ uname -a
Darwin username-mbp 15.6.0 Darwin Kernel Version 15.6.0: Fri Feb 17 10:21:18 PST 2017; root:xnu-3248.60.11.4.1~1/RELEASE_X86_64 x86_64
jruby-launcher 也有问题,但不确定这是否只是一个症状:
$ gem install jruby-launcher
ERROR: Could not find a valid gem 'jruby-launcher' (>= 0) in any repository
ERROR: Possible alternatives: tmux_launcher, RubyRun_CE, ass_launcher, ec2launcher, jruby-ehcache
更新:出现在JRUBY_OPTS
中使用-S
选项是罪魁祸首。
我取消了用户会话中的所有环境变量设置,并确保 env
与 sudo env
完全匹配,但以下内容除外:
- 邮件
- 登录名
- 用户
- 用户名
- SUDO_COMMAND
- SUDO_USER
- SUDO_UID
- SUDO_GID
然后使用不带 sudo 的用户,我能够毫无问题地安装 JRuby。
现在,即使使用与我遇到问题时完全相同的环境变量,我现在也可以 install/execute JRuby 在闲暇时使用。仍然不知道为什么会这样,或者哪个环境变量有问题。
更新:当我使用 sudo
(例如 sudo rbenv install jruby-9.1.2.0
)时一切正常。但我不想要那个 :).
$ ruby -v
NameError: undefined local variable or method `v' for main:Object
<top> at -v:1
$ sudo ruby -v
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.51-b03 on 1.8.0_51-b16 +jit [darwin-x86_64]
正在寻找有关在安装过程中在哪里寻找需要什么东西的提示sudo
。 C Ruby installs/runs 没有 sudo
.
正在尝试安装 JRuby,但遇到 -r
标志被解释为变量的问题。使用 rvm 和 JRuby 1.7.x 版本时出现类似问题。同事没有任何相同的问题。以前能够使用 rvm 和 rbenv 安装 JRuby 1.7,但我不知道从那时起我的系统发生了什么变化。尝试将 JAVA_HOME
设置为 1.7 和 1.8 版本,结果相同。
我无法弄清楚我的系统是什么导致了这个问题——在重新映像之前寻找故障排除的想法:)。
rbenv install -v jruby-9.1.2.0
/var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389 ~
Downloading jruby-bin-9.1.2.0.tar.gz...
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 32578117
Connection: keep-alive
Date: Thu, 20 Apr 2017 18:41:50 GMT
Last-Modified: Fri, 27 May 2016 22:23:15 GMT
ETag: "749bb917dde9666e365e12bbe776a5c2"
Accept-Ranges: bytes
Server: AmazonS3
Age: 16032
X-Cache: Hit from cloudfront
Via: 1.1 0b1b12cfcb11f71988a190f16ef65179.cloudfront.net (CloudFront)
X-Amz-Cf-Id: mKmI9h4xs22ajaNTInTyIeqrnwQw1XHOJzcbKc--yknq4CUOu3XUmg==
-> https://dqw8nmjcqpjn7.cloudfront.net/60598a465883ab4c933f805de4a7f280052bddc793b95735465619c03ca43f35
/var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389/jruby-9.1.2.0 /var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389 ~
Installing jruby-9.1.2.0...
Building native extensions. This could take a while...
ERROR: Error installing jruby-launcher:
ERROR: Failed to build gem native extension.
current directory: /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java
/Users/username/.rbenv/versions/jruby-9.1.2.0/bin/jruby -r ./siteconf20170420-3455-1f44pgz.rb extconf.rb
NameError: undefined local variable or method `r' for main:Object
<top> at -r:1
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java for inspection.
Results logged to /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/extensions/universal-java-1.7/2.3.0/jruby-launcher-1.1.2-java/gem_make.out
BUILD FAILED (OS X 10.11.6 using ruby-build 20170322)
Inspect or clean up the working tree at /var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389
Results logged to /var/folders/qt/xqr8qztj5tl94l0r3l9t0pm4zbpz12/T/ruby-build.20170420180901.3389.log
Last 10 log lines:
current directory: /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java
/Users/username/.rbenv/versions/jruby-9.1.2.0/bin/jruby -r ./siteconf20170420-3455-1f44pgz.rb extconf.rb
NameError: undefined local variable or method `r' for main:Object
<top> at -r:1
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.2-java for inspection.
Results logged to /Users/username/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/extensions/universal-java-1.7/2.3.0/jruby-launcher-1.1.2-java/gem_make.out
这是我的 OS 信息
$ uname -a
Darwin username-mbp 15.6.0 Darwin Kernel Version 15.6.0: Fri Feb 17 10:21:18 PST 2017; root:xnu-3248.60.11.4.1~1/RELEASE_X86_64 x86_64
jruby-launcher 也有问题,但不确定这是否只是一个症状:
$ gem install jruby-launcher
ERROR: Could not find a valid gem 'jruby-launcher' (>= 0) in any repository
ERROR: Possible alternatives: tmux_launcher, RubyRun_CE, ass_launcher, ec2launcher, jruby-ehcache
更新:出现在JRUBY_OPTS
中使用-S
选项是罪魁祸首。
我取消了用户会话中的所有环境变量设置,并确保 env
与 sudo env
完全匹配,但以下内容除外:
- 邮件
- 登录名
- 用户
- 用户名
- SUDO_COMMAND
- SUDO_USER
- SUDO_UID
- SUDO_GID
然后使用不带 sudo 的用户,我能够毫无问题地安装 JRuby。
现在,即使使用与我遇到问题时完全相同的环境变量,我现在也可以 install/execute JRuby 在闲暇时使用。仍然不知道为什么会这样,或者哪个环境变量有问题。