尝试销毁控制器时收到pg错误 [英] I get a pg error when trying to destroy a controller

查看:71
本文介绍了尝试销毁控制器时收到pg错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上工作,具有3.2.12(刚升级)和ruby 2.0.0p0。当我尝试删除控制器时,出现此错误:

I work on windows, have rails 3.2.12(just upgraded) and ruby 2.0.0p0. when i try to delete a controller i get this error:

F:\my apps\meshworks-redo> rails d controller Plans
C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/pg.rb:10:in `require': cannot load such file -- 2.0/pg_ext (LoadError)
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/pg.rb:10:in `rescue in <top (required)>'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/pg.rb:3:in `<top (required)>'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:72:in `require'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:70:in `each'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:70:in `block in require'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:59:in `each'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:59:in `require'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler.rb:132:in `require'
        from F:/my apps/meshworks-redo/config/application.rb:7:in `<top (required)>'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:24:in `require'
        from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:24:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

我尝试重新安装pg gem,但是没有运气

I tried re installing the pg gem, no luck.

推荐答案

在Windows 7和Postgres上使用Ruby 2.0时,我的一个朋友遇到了同样的问题。它不仅在尝试销毁控制器时发生,而且在每个数据库操作(包括rake db:create)中也会发生。问题是ruby 2.0不包含pg_ext.so文件。它包含在1.9中,但仅将其复制到2.0似乎无效。但是,我找到了另一种获取正确的pg_ext.so的方法。不确定为什么这样做,但对他有用。这是您需要做的:

A friend of mine got the same problem when using Ruby 2.0 on Windows 7 with Postgres. It occurs not only when trying to destroy a controller, but for every database action (including rake db:create). The problem is that the pg_ext.so file is not included for ruby 2.0. It is included for 1.9, but simply copying this to the 2.0 does not seem work. However, I found another method to obtain the correct pg_ext.so. Not exactly sure why this works, but it works for him. Here is what you need to do:


  1. 转到应存放2.0 / pg_ext.so(找不到文件)的文件夹。位于。在您的情况下C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/。

  2. 在此处创建一个名为 2.0的文件夹(不带引号)。

  3. 在此文件夹中,您将需要正确的pg_ext.so文件。您可以通过以下方式获得它:

  4. 手动安装pg gem(控制台中为 gem install pg)。这将安装非x86-mingw32版本的gem。它不能解决问题,但是可以创建正确的pg_ext.so。我认为这是因为它会为您的系统编译pg gem,因此对于ruby 2.0也是如此。然后可以将此pg_ext.so文件与pg x86-mingw32版本一起使用。您将需要DevKit才能编译和安装pg( http://rubyinstaller.org/add-ons/ devkit / )。

  5. 转到pg-0.14.1 gem文件夹中pg_ext.so的位置。在您的情况下,这将是C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1/lib。

  6. 在步骤2中将文件pg_ext.so从此文件夹复制到新的pg-0.14.1-x86-mingw32 / lib / 2.0 /文件夹中。

  7. 现在重试您的命令并检查是否一切正常。如果没有,请删除您的Gemfile.lock并重新运行捆绑包安装。

  8. 其他mingw32宝石也可能与此宝石发生相同的问题。例如,我对bcrypt-rails gem有同样的问题。遵循与上述相同的步骤解决了该问题。我现在可以在Windows 7上成功运行Ruby 2.0。

  1. Go to the folder where 2.0/pg_ext.so (the file that could not be found) should be located. In your case C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/.
  2. Create a folder called '2.0' (without the quotes) here.
  3. In this folder you will need the correct pg_ext.so file. You can obtain this in the following way:
  4. Manually install the pg gem ("gem install pg" in console). This installs the non x86-mingw32 version of the gem. It does not fix the problem, but it does create the correct pg_ext.so. I think this is because it compiles the pg gem for your system, so for ruby 2.0. You can then use this pg_ext.so file with the pg x86-mingw32 version. You will need DevKit in order to compile and install pg (http://rubyinstaller.org/add-ons/devkit/).
  5. Go to the location of pg_ext.so in the pg-0.14.1 gem folder. In your case this would be C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1/lib.
  6. Copy the file pg_ext.so from this folder to the newly pg-0.14.1-x86-mingw32/lib/2.0/ folder in step 2.
  7. Now retry your commands and check if everything works. If it does not, delete your Gemfile.lock and re-run bundle install.
  8. The same problem with this gem might occur with other mingw32 gems as well. IFor example, I had the same problem with the bcrypt-rails gem. Following the same steps as described above fixed the problem. I am now successfully running Ruby 2.0 on Windows 7.

Ps。如果您在Windows 7 64位上运行pg gem时遇到任何其他问题,请尝试安装32位x86版本的Ruby(RubyInstaller)和postgresql。此外,请确保在路径中包括Ruby文件夹(使用RubyInstaller安装ruby 2.0时可以选择)以及Postgresql lib和bin文件夹。

Ps. If you have any other problems running the pg gem on Windows 7 64 bit, then try to install the 32 bit x86 version of Ruby (the RubyInstaller) and postgresql. Furthermore, make sure you include the Ruby folders in your path (this is an option while installing ruby 2.0 using the RubyInstaller) as well as the Postgresql lib and bin folders.

祝你好运!

这篇关于尝试销毁控制器时收到pg错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆