ActionController::RoutingError after installing Foreman from source

Problem:
I try to install Foreman from source as described here: Foreman :: Manual. All installation steps work fine until I start the server using command bundle exec bin/rails server and try to access the login page at http://localhost:3000/users/login. The page is blank and the log shows error messages like this:

022-12-02T19:07:41 [I|app|75a12f23] Completed 200 OK in 18ms (Views: 14.5ms | ActiveRecord: 0.4ms | Allocations: 5046)
2022-12-02T19:07:41 [I|app|33de6b79] Started GET "/webpack/foreman-vendor.bundle-v10.1.7-production-57ed7676cc22ce47f0a6.css" for 79.245.96.104 at 2022-12-02 19:07:41 +0000
2022-12-02T19:07:41 [I|app|33816192] Started GET "/webpack/bundle-b96aeee17c6d454bad59.css" for 79.245.96.104 at 2022-12-02 19:07:41 +0000
2022-12-02T19:07:41 [F|app|33de6b79]   
 33de6b79 | ActionController::RoutingError (No route matches [GET] "/webpack/foreman-vendor.bundle-v10.1.7-production-57ed7676cc22ce47f0a6.css"):
 33de6b79 |   
 33de6b79 | lib/foreman/middleware/logging_context_request.rb:11:in `call'
2022-12-02T19:07:41 [I|app|4723353b] Started GET "/webpack/bundle-b96aeee17c6d454bad59.js" for 79.245.96.104 at 2022-12-02 19:07:41 +0000
2022-12-02T19:07:41 [F|app|4723353b]   
 4723353b | ActionController::RoutingError (No route matches [GET] "/webpack/bundle-b96aeee17c6d454bad59.js"):
 4723353b |   
 4723353b | lib/foreman/middleware/logging_context_request.rb:11:in `call'
2022-12-02T19:07:41 [I|app|9a9b971b] Started GET "/javascripts/locale/en_GB/app.js" for 79.245.96.104 at 2022-12-02 19:07:41 +0000
2022-12-02T19:07:41 [I|app|4105cc0d] Started GET "/webpack/foreman-vendor.bundle-v10.1.7-production-57ed7676cc22ce47f0a6.js" for 79.245.96.104 at 2022-12-02 19:07:41 +0000
2022-12-02T19:07:41 [F|app|9a9b971b]   
 9a9b971b | ActionController::RoutingError (No route matches [GET] "/javascripts/locale/en_GB/app.js"):
 9a9b971b |   
 9a9b971b | lib/foreman/middleware/logging_context_request.rb:11:in `call'

[ā€¦]

The files the web server is trying to get are available in folder public/webpack but the web server seems not to be able to find them.

I see the exact same behaviour when building a Docker image with the Dockerfile provided in ForemanĀ“s github repository and running a Foreman container.

Expected outcome:
User login page appears properly

Foreman and Proxy versions:
Branches ā€œdevelopmentā€ as well als ā€œ3.5-stableā€

Foreman and Proxy plugin versions:

Distribution and version:
Amazon Linux / macOS

Other relevant data:

Hi all,

the problem came from a change to the public_file_server.enabled setting in config/environments/production.rb due to Bug #33956: serve assets directly via Apache, not via Puma/Rails - Installer - Foreman

config.public_file_server.enabled = false

As far as I can see this breaks the ā€œInstall from Sourceā€ documentation (since it tells the user to start the server in production mode) as well as the Docker images provided at https://quay.io/repository/foreman/foreman. In the Dockerfile the environment variable RAILS_SERVE_STATIC_FILES=true is set but this does not work (the environment variable seems to be deprecated in newer Rails versions).

When I set

config.public_file_server.enabled = true

in config/environments/production.rb I can start Foreman in production mode after installing from source successfully. Also rebuilding the Docker image after changing the setting fixes the issue when running Foreman in the Docker container.

Best regards

Jannis

@ekohl and I have been working on this in Fixes #35593 - Use CentOS 8 Stream for container by ekohl Ā· Pull Request #9450 Ā· theforeman/foreman Ā· GitHub but somehow never got to merging it.

Your analysis is absolutely correct!

1 Like

I am having the same problem on Ubuntu 20.04 deb packages with 3.5.2 and 3.6.1. Enabling the public_file_server in production.rb did fix the problem but with a little more research it seems this was fixed in the puppet-foreman module which I hadnā€™t upgraded.

Hopefully this will be of use to someone else