Skip to content

rails server fails using Dockerfile generated by rails new, bun and execjs #134

@SpringMT

Description

@SpringMT

I use boostrap gem with Rails 7.1 and bun .
bootstrap uses execjs gem.

When I run rails s with the Dockerfile generated by rails new, the rails app fails with the following error.

/usr/local/bundle/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs/runtimes.rb:68:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

This error occurs because bun binary does not exist.
This error can be fixed by modifying the Dockerfile as shown below.

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails
+ COPY --from=build /usr/local/bun /usr/local/bun
+ ENV PATH=/usr/local/bun/bin:$PATH

This Dockerfile is generated by Rails.
https://github.com/rails/rails/blob/2d271a4b901e7a7dae8ba4e5e83edfebdee278e8/railties/lib/rails/generators/rails/app/templates/Dockerfile.tt#L88-L91

Is the modification that resolves this error acceptable to submit in the Rails?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions