最近在普通用户下用 RVM 安装了最新版本的 Ruby 后,启动 YaST2 管理界面后点击模块,却无法启动模块的管理界面。
从 yslog 中得到如下信息:
2014-01-28 16:24:24 <1> linux-mengz.site(11015) [liby2] genericfrontend.cc(main):575 Launched YaST2 component 'y2base' 'sw_single' 'qt'
2014-01-28 16:24:24 <1> linux-mengz.site(11015) [ui-component] YUIComponentCreator.cc(createInternal):124 Creating UI component for ""
2014-01-28 16:24:24 <1> linux-mengz.site(11015) [liby2] genericfrontend.cc(main):764 YAST_IS_RUNNING is yes
2014-01-28 16:24:25 <3> linux-mengz.site(11015) [Y2Ruby] binary/YRuby.cc(callClient):238 cannot require yast:cannot load such file -- fast_gettext at /usr/lib64/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
2014-01-28 16:24:25 <1> linux-mengz.site(11015) [liby2] genericfrontend.cc(main):778 Finished YaST2 component 'y2base'
2014-01-28 16:24:25 <1> linux-mengz.site(11015) [liby2] genericfrontend.cc(main):783 Exiting with client return value 'false'
看来 YaST2 希望使用的 GEM PATH 是 /usr/lib64/ruby/2.0.0 .
于是查看了一下当前用户下的 gem env:
mengz@linux-mengz: ~
$gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/mengz/.rvm/gems/ruby-2.1.0
- RUBY EXECUTABLE: /home/mengz/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /home/mengz/.rvm/gems/ruby-2.1.0/bin
- SPEC CACHE DIRECTORY: /home/mengz/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/mengz/.rvm/gems/ruby-2.1.0
- /home/mengz/.rvm/gems/ruby-2.1.0@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
而使用在 root 环境下的 gem env:
linux-mengz:~ # gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2013-11-22 patchlevel 353) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib64/ruby/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib64/ruby/gems/2.0.0
- /root/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => true
- :bulk_threshold => 1000
- :benchmark => false
- "install" => "--format-executable --no-user-install"
- "format_executable" => true
- "update" => "--format-executable --no-user-install"
- :sources => "https://rubygems.org"]
由于在普通用下启动 YaST2 管理界面,是使用 kdesu 去启动的 yast2,似乎是继承了当前用户的环境变量,而没有更改到 root 的环境变量,导致 yast2 的 Ruby 路径错误,而打开模块界面失败。
我现在的临时解决方案是,打开 kconsole, su - 到 root 环境,然后 yast2 开启就没有问题了。
$su -
# yast2
我现在不明白的是,YaST 是怎么去寻找 Ruby 文件的?还是 kdesu 存在问题。
是否有其他解决方案来解决这个问题?