3

When I try to run a simple code like

# A Postgres connection:
DataMapper.setup(:default, 'postgres://localhost/the_database_name')

on an win7 x86-64 machine, I get the following error :

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>'

I have every gem dependency installed and a binary version of postgreSQL (the one-click installer found on their site) I suspect the x86-64 architecture to be the cause of the error, because same install on x86 machine works great.

Some ideas ? thanks

PS: That's a question following this one (not really answered), but since the error it's another one I've asked a new question.

Community
  • 1
  • 1
kitensei
  • 2,510
  • 2
  • 42
  • 68

2 Answers2

1

I am a linux guy and have not done any programming in Windows in fourteen years. However:

The error message says it is not a valid Win32 application. And, it works on a 32 bit install, right?

Try installing the 32 bit version of Postgres on the 64 bit machine. It will still run on the 64 bit machine. Otherwise, there may be an option of 64 bit windows libraries.

RedMage
  • 1,126
  • 1
  • 9
  • 21
0

Kind of late to the party, but in case anyone ends up here after a google search, I've found that this works:

Copy these files from the Postgres installation dir to ..\Ruby\bin:

  • lib\libpq.dll
  • bin\libeay32.dll
  • bin\libintl-8.dll
  • bin\libiconv-2.dll
  • bin\krb5_32.dll
  • bin\comerr32.dll
  • bin\k5sprt32.dll
  • bin\gssapi32.dll

Some may already exist, so you don't need to overwrite.

Credit goes to Luis Lavena: https://groups.google.com/forum/#!topic/datamapper/3fz5MeB-frM

avi
  • 16
  • After toying around with this all morning, I found copying all ov the above files **EXCEPT libeay32.dll** made DataMapper work with PostgreSQL 9.3.4 on win7x86-64 (including libeay32 gave an error 127- the specified procedure could not be found) – corg Dec 18 '13 at 21:29