psql "invalid client_encoding" error on OS X, PostgreSQL 9.4.5
client_encoding is a libpq connection option that was added circa 2011 and will not be recognized by older versions.

The error:


  psql: invalid connection option "client_encoding"


comes from dynamically linking a newer psql with an older libpq, for instance the one that ships with the system.

On Mac OS X, this can be worked around by setting DYLD_LIBRARY_PATH (the equivalent of linux's LD_LIBRARY_PATH) to the path of the newer PostgreSQL installation.

Per comments and update, it's confirmed to work when setting this variable globally in /etc/profile