Setting up Foreman dev environment... not working

Hi,

TL;DR: I am probably making everything wrong. :confused: Could someone please provide the few commands to get a Foreman dev env working? Thanks.


I’ve tried to setup a Foreman dev environment on RHEL9 (Rocky 9) using the official guide:

However, pretty early “bundle install” should be run… presumably as root? Which is a bad thing? (Not running it as root just does not work…)

So I’ve tried a different approach using the “Install from source” guide:
https://www.theforeman.org/manuals/3.15/index.html#3.4InstallFromSource

It uses “bundle install --path vendor”, allowing for some progress…

However, when trying to start foreman as documented, it fails:

./bin/rails s -e production
Ignoring bcrypt-3.1.20 because its extensions are not built. Try: gem pristine bcrypt --version 3.1.20
Ignoring bigdecimal-3.2.2 because its extensions are not built. Try: gem pristine bigdecimal --version 3.2.2
Ignoring bootsnap-1.18.6 because its extensions are not built. Try: gem pristine bootsnap --version 1.18.6
Ignoring byebug-11.1.3 because its extensions are not built. Try: gem pristine byebug --version 11.1.3
Ignoring cgi-0.5.0 because its extensions are not built. Try: gem pristine cgi --version 0.5.0
Ignoring date-3.4.1 because its extensions are not built. Try: gem pristine date --version 3.4.1
Ignoring debug_inspector-1.2.0 because its extensions are not built. Try: gem pristine debug_inspector --version 1.2.0
Ignoring ffi-1.17.2 because its extensions are not built. Try: gem pristine ffi --version 1.17.2
Ignoring journald-native-1.0.12 because its extensions are not built. Try: gem pristine journald-native --version 1.0.12
Ignoring json-2.13.2 because its extensions are not built. Try: gem pristine json --version 2.13.2
Ignoring msgpack-1.8.0 because its extensions are not built. Try: gem pristine msgpack --version 1.8.0
Ignoring nio4r-2.7.4 because its extensions are not built. Try: gem pristine nio4r --version 2.7.4
Ignoring prism-1.4.0 because its extensions are not built. Try: gem pristine prism --version 1.4.0
Ignoring puma-6.6.0 because its extensions are not built. Try: gem pristine puma --version 6.6.0
Ignoring racc-1.8.1 because its extensions are not built. Try: gem pristine racc --version 1.8.1
Ignoring ruby-libvirt-0.8.4 because its extensions are not built. Try: gem pristine ruby-libvirt --version 0.8.4
Ignoring sassc-2.4.0 because its extensions are not built. Try: gem pristine sassc --version 2.4.0
Ignoring websocket-driver-0.8.0 because its extensions are not built. Try: gem pristine websocket-driver --version 0.8.0
WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
      racc (~> 1.4)
      Available/installed versions of this gem:
      - 1.8.1
      - 1.5.2
      net-smtp (>= 0)
      Available/installed versions of this gem:
      - 0.5.1
      - 0.2.1
      net-imap (>= 0)
      Available/installed versions of this gem:
      - 0.4.22
      - 0.1.1
      net-pop (>= 0)
      Available/installed versions of this gem:
      - 0.1.2
      - 0.1.1
      logger (>= 0)
      Available/installed versions of this gem:
      - 1.7.0
      - 1.4.3
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.
/home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/autoloaders.rb:20:in `require': cannot load such file -- zeitwerk (LoadError)
	from /home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/autoloaders.rb:20:in `initialize'
	from /home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/application.rb:121:in `new'
	from /home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/application.rb:121:in `initialize'
	from /home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/railtie.rb:184:in `new'
	from /home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/railtie.rb:184:in `instance'
	from /home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/application.rb:78:in `instance'
	from /home/user/foreman/vendor/ruby/3.0.0/gems/railties-7.0.8.7/lib/rails/railtie.rb:146:in `config'
	from /home/user/foreman/config/application.rb:83:in `<class:Application>'
...

OK, I can workaround this by starting Foreman like this:

RAILS_ENV=production bundle exec foreman start

Now that Foreman is up and running I start webpack like this:

RAILS_ENV=production bundle exec foreman start webpack

But Foreman is still not working, because webpack resources cannot be loaded:

2025-07-31T18:17:54 [I|app|264f99ef] Started GET "/users/login" for IP at 2025-07-31 18:17:54 +0200
2025-07-31T18:17:55 [I|app|264f99ef] Processing by UsersController#login as HTML
2025-07-31T18:17:55 [I|app|264f99ef]   Rendered users/login.html.erb within layouts/login (Duration: 3.1ms | Allocations: 771)
2025-07-31T18:17:55 [I|app|264f99ef]   Rendered layouts/base.html.erb (Duration: 7.5ms | Allocations: 3204)
2025-07-31T18:17:55 [I|app|264f99ef]   Rendered layout layouts/login.html.erb (Duration: 12.7ms | Allocations: 4451)
2025-07-31T18:17:55 [I|app|264f99ef] Completed 200 OK in 57ms (Views: 21.0ms | ActiveRecord: 1.1ms | Allocations: 26311)
2025-07-31T18:17:55 [I|app|37b81a55] Started GET "/webpack/vendorStyles.css" for IP at 2025-07-31 18:17:55 +0200
2025-07-31T18:17:55 [F|app|37b81a55]   
 | ActionController::RoutingError (No route matches [GET] "/webpack/vendorStyles.css"):
 |   
 | lib/foreman/middleware/logging_context_request.rb:11:in `call'
2025-07-31T18:17:55 [I|app|6210e493] Started GET "/javascripts/locale/en/app.js" for IP at 2025-07-31 18:17:55 +0200
2025-07-31T18:17:55 [F|app|6210e493]   
 | ActionController::RoutingError (No route matches [GET] "/javascripts/locale/en/app.js"):
 |   
 | lib/foreman/middleware/logging_context_request.rb:11:in `call'
2025-07-31T18:17:55 [F|app|8f70c930]   
 | ActionController::RoutingError (No route matches [GET] "/assets/late_load-d3b26123d019e3576d91e83ef6eac3c76018e932d2931179171445998bc4c30a.js"):
...

Any help would be greatly appreciated!

Thanks
Frank

Not sure about the ruby issues, but foreman start starts webpack and rails.
If you want to run them separately you can do that by running foreman start webpack and foreman start rails, or if youre not doing UI code changes you can just run rake webpack:compile once.
The initial run for webpack compile can take a few minutes, so make sure you wait for it to be done (successfully)

Hm, I had to use RAILS_ENV=production to start Foreman, because the development env wasn’t working. However, the production env does not serve webpack assets (learned from reading config/environments/production.rb).

Turns out I just had to add the irb gem to Gemfile to get the development env working. This is not mentioned anywhere (but more or less obvious from the error message you get).

Now Foreman dev seems to work properly. :relieved:

git clone https://github.com/theforeman/foreman.git -b develop
cd foreman
cp config/settings.yaml.example config/settings.yaml
cp config/database.yml.example config/database.yml

vi Gemfile
gem 'irb'

bundle install --path vendor
npm install

BIND=0.0.0.0 bundle exec foreman start
1 Like