当我尝试运行像
这样的简单代码时# A Postgres connection:
DataMapper.setup(:default, 'postgres://localhost/the_database_name')
在win7 x86-64机器上,我收到以下错误:
D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 193: %1 n?est pas une application Win32 valide. - D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/do_postgres-0.10.8-x86-mingw32/lib/do_postgres/1.9/do_postgres.so (LoadError)
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/do_postgres-0.10.8-x86-mingw32/lib/do_postgres.rb:30:in `rescue in <top (required)>'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/do_postgres-0.10.8-x86-mingw32/lib/do_postgres.rb:25:in `<top (required)>'
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/dm-postgres-adapter-1.2.0/lib/dm-postgres-adapter/adapter.rb:1:in `<top (required)>'
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/dm-postgres-adapter-1.2.0/lib/dm-postgres-adapter.rb:1:in `<top (required)>'
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from D:/dev/Ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:163:in `load_adapter'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:133:in `adapter_class'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:13:in `new'
from D:/dev/Ruby/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core.rb:228:in `setup'
from D:/dev/workspace/ruby/training/bin/pg/main.rb:8:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
我安装了每个gem依赖项和postgreSQL的二进制版本(在他们的站点上找到一键安装程序) 我怀疑x86-64架构是导致错误的原因,因为x86机器上的相同安装效果很好。
一些想法?感谢
PS:这是this one之后的一个问题(没有真正回答),但是由于错误是另一个问题,我提出了一个新问题。
答案 0 :(得分:1)
我是一名Linux用户,并且在十四年没有在Windows中进行任何编程。但是:
错误消息显示它不是有效的Win32应用程序。而且,它适用于32位安装,对吧?
尝试在64位计算机上安装32位版本的Postgres。它仍然可以在64位机器上运行。否则,可能存在64位Windows库的选项。
答案 1 :(得分:0)
有点迟到了,但如果有人在谷歌搜索后结束了这里,我发现这有效:
将这些文件从Postgres安装目录复制到.. \ Ruby \ bin:
有些可能已经存在,因此您无需覆盖。
归功于Luis Lavena:https://groups.google.com/forum/#!topic/datamapper/3fz5MeB-frM