Foreman 3.3: Foreman does not start with Gem LoadError

Problem: During foreman start, it is trying to load a file and failling:

Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/application.rb:363:in `initialize!'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/railtie.rb:190:in `public_send'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/railtie.rb:190:in `method_missing'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /usr/share/foreman/config/environment.rb:5:in `<top (required)>'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/dependencies.rb:324:in `block in require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/dependencies.rb:291:in `load_dependency'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/dependencies.rb:324:in `require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from config.ru:5:in `block in <main>'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/server.rb:312:in `block in start'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/server.rb:379:in `handle_profiling'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/rack-2.2.3/lib/rack/server.rb:311:in `start'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/commands/server/server_command.rb:39:in `start'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/commands/server/server_command.rb:147:in `block in perform'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/commands/server/server_command.rb:138:in `tap'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/commands/server/server_command.rb:138:in `perform'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/command/base.rb:69:in `perform'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/command.rb:46:in `invoke'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.4.7/lib/rails/commands.rb:18:in `<top (required)>'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `rescue in require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:147:in `require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /usr/share/foreman/bin/rails:9:in `<main>'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: /opt/rh/rh-**ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- rails/commands (LoadError)**
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
Feb 06 16:27:00 bdapmgmtprd01.mgmt foreman[5605]: from /usr/share/foreman/bin/rails:9:in `<main>'
Feb 06 16:27:00 bdapmgmtprd01.mgmt systemd[1]: foreman.service: main process exited, code=exited, status=1/FAILURE
Feb 06 16:27:00 bdapmgmtprd01.mgmt systemd[1]: Failed to start Foreman.

Expected outcome: Foreman starts

Foreman and Proxy versions: Foreman 3.3 and proxy 3.3

** OS:** RHEL 7.9

Other relevant data:
** Gems installed **

[root@bdapmgmtprd01 share]# scl enable tfm – gem list --all

*** LOCAL GEMS ***

actioncable (6.0.4.7)
actionmailbox (6.0.4.7)
actionmailer (6.0.4.7)
actionpack (6.0.4.7)
actiontext (6.0.4.7)
actionview (6.0.4.7)
activejob (6.0.4.7)
activemodel (6.0.4.7)
activerecord (6.0.4.7)
activerecord-import (1.1.0)
activerecord-session_store (2.0.0)
activestorage (6.0.4.7)
activesupport (6.0.4.7)
addressable (2.8.0)
algebrick (0.7.3)
amazing_print (1.1.0)
ancestry (3.0.7)
anemone (0.7.2)
angular-rails-templates (1.1.0)
ansi (1.5.0)
apipie-bindings (0.5.0)
apipie-dsl (2.4.0)
apipie-params (0.0.5)
apipie-rails (0.5.17)
audited (4.9.0)
awesome_print (1.8.0)
bcrypt (3.1.12)
bigdecimal (2.0.0)
builder (3.2.4)
bundler (2.2.24)
bundler_ext (0.4.1)
clamp (1.1.2)
coffee-rails (5.0.0)
coffee-script (2.4.1)
coffee-script-source (1.12.2)
colorize (0.8.1)
concurrent-ruby (1.1.6)
concurrent-ruby-edge (0.6.0)
connection_pool (2.2.2)
crass (1.0.6)
css_parser (1.4.7)
daemons (1.2.3)
deacon (1.0.0)
deep_cloneable (3.0.0)
deface (1.5.3)
did_you_mean (1.4.0)
domain_name (0.5.20160310)
dynflow (1.6.4)
erubi (1.9.0)
excon (0.76.0)
execjs (2.7.0)
facter (4.0.51)
faraday (0.17.3)
fast_gettext (1.4.1)
ffi (1.12.2)
fog-aws (3.6.5)
fog-core (2.1.0)
fog-json (1.2.0)
fog-libvirt (0.9.0)
fog-ovirt (2.0.1)
fog-xml (0.1.2)
foreman-tasks (6.0.2)
foreman_openscap (5.2.2)
foreman_puppet (4.0.1)
foreman_remote_execution (7.1.0)
foreman_virt_who_configure (0.5.8)
formatador (0.2.1)
friendly_id (5.3.0)
fx (0.5.0)
get_process_mem (0.2.7)
gettext_i18n_rails (1.8.0)
gitlab-sidekiq-fetcher (0.6.0)
globalid (0.4.2)
graphql (1.8.14)
graphql-batch (0.3.10)
gssapi (1.2.0)
hammer_cli (3.3.0)
hammer_cli_foreman (3.3.0)
hammer_cli_foreman_openscap (0.1.13)
hammer_cli_foreman_puppet (0.0.6)
hammer_cli_foreman_remote_execution (0.2.2)
hammer_cli_foreman_tasks (0.0.17)
hammer_cli_foreman_virt_who_configure (0.0.9)
hammer_cli_katello (1.5.2)
hashie (3.6.0)
highline (2.0.3)
hocon (1.3.1)
http-cookie (1.0.2)
i18n (1.8.2)
io-console (0.5.6)
ipaddress (0.8.3)
irb (1.2.6)
json (2.3.0)
jwt (2.2.2)
kafo (6.4.0)
kafo_parsers (1.2.1)
kafo_wizards (0.0.2)
katello (4.5.0)
ldap_fluff (0.6.0)
little-plugger (1.1.4)
locale (2.0.9)
logging (2.3.1, 2.3.0)
loofah (2.4.0)
mail (2.7.1)
marcel (1.0.1)
method_source (0.9.2)
mime-types (3.3.1)
mime-types-data (3.2018.0812)
mini_mime (1.0.2)
mini_portile2 (2.5.1)
minitest (5.17.0, 5.13.0)
msgpack (1.3.3)
multi_json (1.15.0, 1.14.1)
multipart-post (2.0.0)
mustermann (1.1.1)
net-ldap (0.17.0)
net-ping (2.0.1)
net-scp (1.2.1)
net-ssh (7.0.1, 4.2.0)
net_http_unix (0.2.2)
netrc (0.11.0)
nio4r (2.5.4)
nokogiri (1.11.3)
oauth (0.5.4)
openscap (0.4.9)
openscap_parser (1.0.2)
openssl (2.1.3)
ovirt-engine-sdk (4.4.0)
parallel (1.19.1)
parse-cron (0.1.4)
pg (1.1.4)
polyglot (0.3.5)
powerbar (2.0.1)
promise.rb (0.7.4)
psych (3.1.0)
public_suffix (3.0.3)
pulp_ansible_client (0.13.1)
pulp_certguard_client (1.5.0)
pulp_container_client (2.10.3)
pulp_deb_client (2.18.0)
pulp_file_client (1.10.0)
pulp_ostree_client (2.0.0a1)
pulp_python_client (3.6.0)
pulp_rpm_client (3.17.4)
pulpcore_client (3.18.5)
puma (5.6.2)
puma-status (1.3)
puppetdb_foreman (5.0.0)
qpid_messaging (1.38.0)
qpid_proton (0.37.0)
rabl (0.14.3)
racc (1.5.2, 1.4.16)
rack (2.2.3)
rack-cors (1.0.2)
rack-jsonp (1.3.1)
rack-protection (2.1.0)
rack-test (1.1.0)
rails (6.0.4.7)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.3.0)
rails-i18n (6.0.0)
railties (6.0.4.7)
rainbow (2.2.2)
rake (13.0.6, 13.0.1)
rake-compiler (1.0.7)
rb-inotify (0.9.7)
rdoc (6.2.1.1)
redfish_client (0.5.2)
redis (4.5.1)
responders (3.0.0)
rest-client (2.0.2)
rkerberos (0.1.5)
roadie (3.4.0)
roadie-rails (2.1.1)
robotex (1.0.0)
rsec (0.4.3)
ruby-libvirt (0.7.1)
ruby2_keywords (0.0.4)
ruby2ruby (2.4.2)
ruby_parser (3.10.1)
rubyipmi (0.11.0)
runcible (2.13.1)
safemode (1.3.6)
scoped_search (4.1.10)
sd_notify (0.1.0)
secure_headers (6.3.0)
sequel (5.53.0)
server_sent_events (0.1.2)
sexp_processor (4.10.0)
sidekiq (5.2.10)
sinatra (2.1.0)
smart_proxy_openscap (0.9.1)
smart_proxy_pulp (3.2.0)
sprockets (4.0.2)
sprockets-rails (3.2.1)
sshkey (1.9.0)
statsd-instrument (2.1.4)
stomp (1.4.9)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.8)
tzinfo (1.2.6)
unf (0.1.3)
unf_ext (0.0.7.2)
unicode (0.4.4.4)
unicode-display_width (2.4.2, 1.7.0)
validates_lengths_from_database (0.5.0)
webpack-rails (0.9.8)
websocket-driver (0.7.1)
websocket-extensions (0.1.5)
will_paginate (3.1.7)
xmlrpc (0.3.0)
zeitwerk (2.2.2)

How did you install Foreman? And why don’t you install newer version, 3.5 is available already. Do you need to stay on RHEL 7.9? I’ve seen something similar happen when the installation was mixed with git-like setup. Check there’s no .git in ~foreman and your gems path.

HI Marek,

We have installed using “foreman-installer”.
Unfortunetly, we stay for now in RHEL 7.9 for a while, we are still planning for the move to RHEL 8. That means we cannot move from Foreman 3.3.

I could not find any “.git” in the foreman directories or gems.

We have also executed “bundle install” and “foreman-installer” once again, it did install a bunch of other gems but still we see the same issue.