DEV Community

Mezbah Alam
Mezbah Alam

Posted on

How to Fix the "dyld: lazy symbol binding failed" Error When Using PostgreSQL and Ruby on macOS

If you're working with Ruby and PostgreSQL on macOS, you may run into issues installing the PG gem. This is due to the fact that the gem relies on the PostgreSQL library, which can be difficult to link with on macOS.

One common issue that you may encounter is a "lazy symbol binding failed" error message. This indicates that the gem is unable to locate the libpq library, which is required for the gem to function properly.

dyld: lazy symbol binding failed: Symbol not found: _PQresultMemorySize
  Referenced from: /path/to/gems/pg-1.x.x/lib/pg_ext.bundle
  Expected in: /usr/lib/libpq.5.dylib
Enter fullscreen mode Exit fullscreen mode

Solution

To fix this issue, you can run the following command:

gem pristine pg
Enter fullscreen mode Exit fullscreen mode

This command will rebuild the PG gem and link it with the libpq library on your system. Once this is done, you should be able to use the PG gem without any issues.

Conclusion

Working with PostgreSQL on macOS can be tricky, but with the right tools and knowledge, you can overcome any issues that you may encounter. By following the steps outlined in this guide, you should be able to resolve any PG gem installation issues that you may encounter.

Oldest comments (0)