Here is the error details we resolved.
PostgreSQL libpq.5.dylib LoadError
/Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require': dlopen(/Users/doss/.rvm/gems/ruby-3.0.0/gems/pg-1.3.3/lib/pg_ext.bundle, 0x0009): Library not loaded: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (LoadError)
Referenced from: '/Users/doss/.rvm/gems/ruby-3.0.0/gems/pg-1.3.3/lib/pg_ext.bundle'
Reason: tried: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file), '/opt/homebrew/Cellar/postgresql@14/14.5_3/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file) - /Users/doss/.rvm/gems/ruby-3.0.0/gems/pg-1.3.3/lib/pg_ext.bundle
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/pg-1.3.3/lib/pg.rb:49:in `block in <module:PG>'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/pg-1.3.3/lib/pg.rb:37:in `block in <module:PG>'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/pg-1.3.3/lib/pg.rb:42:in `<module:PG>'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/pg-1.3.3/lib/pg.rb:6:in `<main>'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/doss/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:66:in `block (2 levels) in require'
from /Users/doss/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `each'
from /Users/doss/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `block in require'
from /Users/doss/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:50:in `each'
from /Users/doss/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:50:in `require'
from /Users/doss/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler.rb:174:in `require'
from /Users/doss/Projects/DocPlus2/api/config/application.rb:7:in `<main>'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:137:in `block in perform'
from <internal:kernel>:90:in `tap'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:134:in `perform'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/railties-7.0.2.2/lib/rails/command/base.rb:87:in `perform'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/railties-7.0.2.2/lib/rails/command.rb:48:in `invoke'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/railties-7.0.2.2/lib/rails/commands.rb:18:in `<main>'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/doss/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from bin/rails:4:in `<main>'
The above issue when starting the rails application,
Solution:
If you are recently upgraded the PostgreSql 14.5, that affected gem installed in the application.
To resolve the issue you have to uninstall the Gem ‘pg’ and reinstall it again.
Command to execute:
#To uninstall postgres gem
gem uninstall pg
#To install postgres gem
gem install pg
or
Mention the gem version in the Gemfile and run the bundler using below command.
Modify Gem file
gem 'pg', '1.2.3'
And run this command via terminal
bundle
Now the issue must be resolved.