Build failing for Rails application

infomatrixinc
PRO

3 months ago

I am deploying a rails app with 3.3.8 Ruby and 7.2 rails. While deploying the build fails with the following error --

An error occurred while installing psych (5.2.6), and Bundler cannot continue.

In Gemfile:

importmap-rails was resolved to 2.1.0, which depends on

railties was resolved to 7.2.2.1, which depends on

irb was resolved to 1.15.2, which depends on

rdoc was resolved to 6.14.0, which depends on

psych

Googling this issue suggests that a library is missing libyaml.

Any ideas how i can resolve this?

Solved$10 Bounty

1 Replies

3 months ago

Hi there

you need to add `libyaml-dev` to your Dockerfile in the build phase

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems and node modules
ARG BUILD_PACKAGES="git build-essential libpq-dev wget curl gzip libyaml-dev"
ENV BUILD_PACKAGES ${BUILD_PACKAGES}

RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y ${BUILD_PACKAGES} \
    && rm -rf /var/lib/apt/lists /var/cache/apt/archives

if you don't have a Dockerfile, you create a new one by adding this gem to your Gemfile

gem "dockerfile-rails", ">= 1.7", group: :development

then

and to generate a Dockerfile along with relevant files

rails g dockerfile

this will read your app structure and create a Dockerfile for all your dependencies, you might need to discard some of the changes or delete some of the files depending on your setup.

commit push and it should all work now!

let me know how it goes and if you found this answer to be helpful feel free to mark is as accepted!

thanks

alex


Status changed to Solved chandrika about 2 months ago