Existing Rails app errors out on fly-deploy

Hi, I am also facing similar issue. I am following the tutorial here Getting Started · Fly Docs using the fly Webcli.

I got the following error when i run “fly launch”

An error occurred while installing pg (1.4.6), and Bundler cannot continue.

followed by other outputs which signify that the launch was completed

However when i ran “fly deploy” I ran into this error

=> ERROR [build 3/7] RUN bundle install &&     bundle exec bootsnap precompile --gemfile                  0.6s
------
 > [build 3/7] RUN bundle install &&     bundle exec bootsnap precompile --gemfile:
#13 0.575 You are trying to install in deployment mode after changing
#13 0.575 your Gemfile. Run `bundle install` elsewhere and add the
#13 0.575 updated Gemfile.lock to version control.
#13 0.575 
#13 0.575 The dependencies in your gemfile changed
#13 0.575 
#13 0.575 You have added to the Gemfile:
#13 0.575 * redis (~> 5.0)
#13 0.575 
#13 0.575 You have deleted from the Gemfile:
#13 0.575 * redis
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c bundle install &&     bundle exec bootsnap precompile --gemfile]: exit code: 16

So i ran “bundle install && bundle exec bootsnap precompile --gemfile” and got this error

Installing pg 1.4.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension

Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so:
  sudo apt install libpq-dev
  sudo yum install postgresql-devel
  sudo zypper in postgresql-devel
  sudo pacman -S postgresql-libs

I then ran " apt install libpq-dev" to get the dependencies installed and after that I was able to successfully deploy the App.

However, when i run “fly open” I see following error

Error failed opening http://withered-firefly-1140.fly.dev: exec: “xdg-open”: executable file not found in $PATH

I have no idea what “xdg-open”. I tried “which xdg-open” but it returns empty. so I am kinda stuck here.
I found this 3 files in /usr/bin but I don’t really know where to go from here.

xdg-dbus-proxy
xdg-user-dir
xdg-user-dirs-update

Kindly advise
Ps: this is my first experience with rails and fly

Two problems here. The following should fix your Dockerfile:

bin/rails generate dockerfile --postgresql

It will prompt you to overwrite the Dockerfile you have. Feel free to look at the diffs before you accept the changes.

Now as to the fly open, it appears that you are running on a Debian based operating system, perhaps on WSL2. If you are running Linux directly, try:

apt-get install xdg-utils

If you are running WSL2, try:

sudo ln -s /usr/local/bin/xdg-open /usr/bin/wslview