Rails 6 app build fails when run from GitHub codespace: LoadError: libffi.so.7: cannot open shared object file

I’m attempting to deploy a Rails app to fly.io but am experiencing some unexpected behavior that I’m hoping to get help with.

For context, I teach a class where students learn how to write Ruby on Rails apps. We’re looking to have students work entirely with GitHub Codespaces.

The issue I’m having is that after running fly launch, fly deploy with always fail when bundling the assets

=> CACHED [build 5/6] RUN bundle exec bootsnap precompile app/ lib/ 0.0s
=> ERROR [build 6/6] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile 2.6s
------
> [build 6/6] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile:
#16 2.553 rails aborted!
#16 2.553 LoadError: libffi.so.7: cannot open shared object file: No such file or directory - /rails/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/lib/ffi_c.so

I’ve tried adding install instructions for libffi7 in the Dockerfile a few different ways. I’ve tried using the full Ruby 2.7.3 base image instead of the slim image but the error persists.

What I mainly don’t understand is that I can deploy app from my local WSL ubuntu environment without issue, but it fails when deployed from a codespace.

I thought that it shouldn’t matter what environment I deploy from if the image is being built remotely?

Could someone help me understand how I can make this project deploy successfully from a codespace?

Here is the repository I’ve been working from.

I don’t have the answer, but a few things to explore…

As a rule of thumb, that’s true. But it is only a rule of thumb.

What is actually going on is that all of the files in your current working directory, minus the ones listed in .dockerignore, are uploaded, and then your application is built (gems are installed, assets are precompiled, etc) from there.

Now lets look at the message:

Your github repository has an empty vendor/bundle directory.

Your .dockerignore file doesn’t mention vendor.

Is it possible that you have this gem installed and vendored on wsl2, but not on codespaces?

Thanks for the reply! My vendor/bundle directory is empty in my local environment as well. I can do a fresh clone of the repo in my local environment and run fly deploy and it succeeds.

AH I see what happened. In the codespace, gems were installed into vendor/bundle, but this did not happen locally. I guess since those gems are copied to the image it has some bad effect when assets compile. Removing gems from vendor/bundle solved the issue. I thought I tried this before, apparently not! Thanks for your help!