Home Articles

安装后即使无法加载pg gem

Asked
Viewed 1476 times
1

对不起,如果问题是基本的,并且已经提出了相关的表格 . 我的系统管理员不在国外,所以我一直试图解决这个问题 . 并且没有一个类似的问题具有确切的情况(相信我,我看起来并且已经撞墙一段时间了) .

请参阅下面的我的红宝石/宝石,均为1.9.3 . 然后运行它以某种方式显示1.9.1,不知道为什么 . 无论如何,我已经尝试安装pg,缺少的宝石 . 看起来它已安装,但重新运行会给出相同的错误消息 .

请问我认为您认为相关的任何其他信息 .

rails@alpite:~/solr_indexer$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p551/bin/ruby

rails@alpite:~/solr_indexer$ which gem
/usr/local/rvm/rubies/ruby-1.9.3-p551/bin/gem

rails@alpite:~/solr_indexer$ ruby indexer.rb
/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- pg (LoadError)
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/rails/solr_indexer/cfg.rb:2:in `'
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from indexer.rb:1:in `'
rails@alpite:~/solr_indexer$ gem install pg
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/local/rvm/gems/ruby-1.9.3-p551 directory.

rails@alpite:~/solr_indexer$ sudo gem install pg
[sudo] password for rails: 
Sorry, try again.
[sudo] password for rails: 
Building native extensions.  This could take a while...
Successfully installed pg-0.17.1
1 gem installed
Installing ri documentation for pg-0.17.1...
Installing RDoc documentation for pg-0.17.1...

rails@alpite:~/solr_indexer$ ruby indexer.rb
/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- pg (LoadError)
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/rails/solr_indexer/cfg.rb:2:in `'
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from indexer.rb:1:in `'

1 Answer

  • 0

    您're using a multi-user RVM installation to manage multiple Rubies. When using that, don' t使用 sudo 来安装宝石 . RVM installation page说:

    注意:多用户安装说明必须以sudo命令为前缀 . 但是,一旦安装完成,并且遵循了将用户添加到rvm组的说明,则不再需要使用sudo或rvmsudo . sudo命令只是暂时提升权限,以便安装程序可以完成其工作 . 如果在安装完成后需要使用sudo或rvmsudo,则未正确遵循安装说明的某些部分 . 这通常是因为人们以root身份执行安装,而不是从非特权用户帐户执行安装指令 .

    我建议阅读整个页面,因为它有关于在您的环境中使用RVM的重要信息 .

    Sudo”页面也很好读 .

Related