pg_ext load error

Issue #192 duplicate
Former user created an issue

I recently updated to rails 4.1.6 and ruby 2.1.3p242. I also updated all gems on my system. After creating a new app, I keep getting a pg_ext load file error on running the server. I'm on windows 8 x64 with PostgreSQL 9.3. The pg gem was working fine under my previous RoR installation which was rails 3.2 and ruby 1.9.3.

Under the gem's installation directory, I've a 2.0/ file. I tried renaming the folder to 2.1 and ran the server. The result was the same. I assume it's cause Ruby doesn't allow to Require a .so file. Below is the screenshot of the error:


Any help would be really appreciated. Thanks!

Comments (9)

  1. Lars Kanis

    I'm closing the ticket as solved. If it's not yet solved for you, please sign up to bitbucket, in order to receive ticket updates.

  2. Lars Kanis

    @CraneWing there are 3 versions of the pg.gem. A source gem, a binary gem for x86-mingw and another one for x64-mingw. For Windows you could use the source gem together with a local PostgreSQL-installation, but it's usually much easier to use the binary gems. These also should be used by rubygems and bundler as the preferred version, however there are some releases of rubygems, that fail to pick the binary gem. Ensure you use a up-to-date rubygems version: gem update --system and do not mix binary and source gems.

    Could you please post a stack trace and/or log file content, if the above fails?

  3. Lars Kanis

    @CraneWing this probably means, that some dependent DLL could not be found or loaded. needs libpq.dll to work. This is usually done by adjusting the PATH environment variable in lib/pg.rb to the directory of libpq.dll at loading time. There could be some other libpq.dll in the path, that fails to load, or some other library is missing. Windows DLL hell... I usually investigate things like this with the depends-tool of sysinternals. It should not show any missing dlls for, when both libpq.dll and msvcrt-ruby200.dll are in the PATH.

  4. Lars Kanis

    @CraneWing I guess this is the issue. For whatever reason, it loads libpq.dll from c:\PostgreSQL\lib , but this fails, because the gem is linked against the bundled libpq.dll version. The one in the PostgreSQL directory is version 9.1, but the gem is linked against 9.4. So not all symbols can be resolved, and the DLL loader fails. Since it's a 32 bit installation, things like different name mangling could be another reason.

    Try to remove C:\PostgreSQL\lib from your PATH variable, so that the libpq.dll bundled into the pg.gem is loaded. Or try to install the source gem and link it to your PostgreSQL-9.1 installation, like so: gem install --platform ruby -- --with-pg-dir=c:/PostgreSQL .

    Sorry for not being able to reproduce this. I don't have a proper Windows Box at hand.

  5. Lars Kanis

    @CraneWing for the source gem the mkmf.log file (in the gem install directory) should give an indication, why the configure task failed. For the binary gem you probably need to make sure, that the right DLLs are loaded. However in theory both versions should work.

  6. Log in to comment