southbridgeio / redmine_2fa

Two-factor (sms/telegram) authentication for Redmine
https://southbridge.io
MIT License
42 stars 17 forks source link

No such file to load in Production #51 #52

Closed akhilesharora closed 6 years ago

akhilesharora commented 6 years ago

It breaks in production whereas in development it works fine. Telegram common plugin is already installed.

sudo rails s -b 0.0.0.0 -e production
=> Booting WEBrick
=> Rails 4.2.8 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require': No such file to load -- telegram_handler_worker (LoadError)
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:360:in `require_or_load'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:317:in `depend_on'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:233:in `require_dependency'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:471:in `each'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:471:in `block in eager_load!'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:469:in `each'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:469:in `eager_load!'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:346:in `eager_load!'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/application/finisher.rb:56:in `each'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `instance_exec'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `run'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
    from /usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
    from /usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
    from /usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
    from /usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:54:in `run_initializers'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/application.rb:352:in `initialize!'
    from /home/akhilesh/Documents/code/redmine_test/config/environment.rb:14:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
    from /home/akhilesh/Documents/code/redmine_test/config.ru:3:in `block in <main>'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/builder.rb:55:in `instance_eval'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/builder.rb:55:in `initialize'
    from /home/akhilesh/Documents/code/redmine_test/config.ru:in `new'
    from /home/akhilesh/Documents/code/redmine_test/config.ru:in `<main>'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/builder.rb:49:in `eval'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/builder.rb:49:in `new_from_string'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/builder.rb:40:in `parse_file'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/server.rb:300:in `build_app_and_options_from_config'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/server.rb:209:in `app'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/server.rb:61:in `app'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/server.rb:337:in `wrapped_app'
    from /var/lib/gems/2.3.0/gems/rack-1.6.9/lib/rack/server.rb:273:in `start'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/server.rb:80:in `start'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:80:in `block in server'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /var/lib/gems/2.3.0/gems/railties-4.2.8/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
olemskoi commented 6 years ago

Sorry, I don’t understand what do you want from us.

akhilesharora commented 6 years ago

I want to solve the problem.

olemskoi commented 6 years ago

la -laF redmine/plugins

Did you run migrations?

akhilesharora commented 6 years ago

Yeah I did run migrations.

So in config/environments/development.rb config.eager_load = false whereas in production config.eager_load = true

total 44
drwxrwxr-x  8 akhilesh akhilesh 4096 mrt 14 15:21 ./
drwxrwxr-x 20 akhilesh akhilesh 4096 mrt 14 15:19 ../
-rw-rw-r--  1 akhilesh akhilesh   31 mrt 13 21:12 README
drwxrwxr-x  8 akhilesh akhilesh 4096 mrt 13 21:13 redmine_2fa/
drwxrwxr-x  7 akhilesh akhilesh 4096 mrt 14 13:09 redmine_telegram_common/
olemskoi commented 6 years ago

Does it work without our plugins?

akhilesharora commented 6 years ago

Yeah..Once I make config.eager_load = false in config/environments/production.rb then it runs fine. But that is just a quick hack since in prod eager_load should be true.

olemskoi commented 6 years ago

So now it works? Is your problem in our plugins?

akhilesharora commented 6 years ago

Yeah. The application fails in production because its unable to load the Telegram_bot somewhere since the eager_load => true in production. Whereas in development eager_load => false, so it does not break. But at the end of the day I want to use the plugin in production but I am unable to do that.

Eager load code on boot. This eager loads most of Rails and your application in memory, allowing both threaded web servers and those relying on copy on write to perform better.

vladislav-yashin commented 6 years ago

Which versions of redmine_2fa and redmine_telegram_common do you have?

akhilesharora commented 6 years ago

name 'Redmine 2FA' => version '1.4.0' name 'Redmine Telegram Common plugin' => version '0.3.0'

vladislav-yashin commented 6 years ago

Okay, versions are consistent. I'm not sure that it will help you, but I suggest to try using Puma or something else instead of Webrick in production environment since webrick is not suited for production. Actually we use Puma on our production server (with eager_load option set to true), and it works.

akhilesharora commented 6 years ago

I am using Passenger in my production environment. With webrick I was just testing why it was failing.

vladislav-yashin commented 6 years ago

Please, try to remove this line:

Rails.application.config.eager_load_paths += Dir.glob("#{Rails.application.config.root}/plugins/redmine_telegram_common/{lib,app/workers,app/models,app/controllers}")

in redmine_telegram_common/init.rb and let us know if it helped you.

akhilesharora commented 6 years ago

It did help. As of now it does not throw any errors. Thanks @funk-yourself

vladislav-yashin commented 6 years ago

@akhilesharora glad that it helped you, but it's still a workaround, not a proper fix. It would be great if you can send me your redmine folder since I can't reproduce this bug myself. My E-mail is v.yashin.work@gmail.com

olemskoi commented 6 years ago

Please open issue if you still want to fix problem.