`LoadError: cannot load such file` on plugin external gem

Hi.

I’m trying to develop this plugin and am having issues with external dependencies.

My dependency is specified in plugin.rb with gem 'omniauth-telegram', '0.2.1' which is the
recommended way to require dependencies I believe? I’m bringing it into the docker container with this:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/mjsir911/discourse-telegram-auth.git

Results in this error:

I, [2022-09-21T07:17:21.579540 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'LOAD_PLUGINS=0 bundle exec rake plugin:pull_compatible_all'
I, [2022-09-21T07:17:22.713904 #1]  INFO -- : discourse-telegram-auth is already at latest compatible version
docker_manager is already at latest compatible version

I, [2022-09-21T07:17:22.714304 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
LoadError: cannot load such file -- omniauth-telegram
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/var/www/discourse/lib/plugin_gem.rb:30:in `load'
/var/www/discourse/lib/plugin/instance.rb:776:in `gem'
/var/www/discourse/plugins/discourse-telegram-auth/plugin.rb:9:in `activate!'
/var/www/discourse/lib/plugin/instance.rb:670:in `instance_eval'
/var/www/discourse/lib/plugin/instance.rb:670:in `activate!'
/var/www/discourse/lib/discourse.rb:314:in `block in activate_plugins!'
/var/www/discourse/lib/discourse.rb:311:in `each'
/var/www/discourse/lib/discourse.rb:311:in `activate_plugins!'
/var/www/discourse/config/application.rb:228:in `block in <class:Application>'
/var/www/discourse/lib/plugin.rb:6:in `initialization_guard'
/var/www/discourse/config/application.rb:227:in `<class:Application>'
/var/www/discourse/config/application.rb:81:in `<module:Discourse>'
/var/www/discourse/config/application.rb:80:in `<top (required)>'
/var/www/discourse/Rakefile:7:in `require'
/var/www/discourse/Rakefile:7:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
(See full trace by running task with --trace)
I, [2022-09-21T07:17:23.851899 #1]  INFO -- : gem install omniauth-telegram -v 0.2.1 -i /var/www/discourse/plugins/discourse-telegram-auth/gems/2.7.6 --no-document --ignore-dependencies --no-user-install
Successfully installed omniauth-telegram-0.2.1
1 gem installed

I, [2022-09-21T07:17:23.852119 #1]  INFO -- : Terminating async processes
I, [2022-09-21T07:17:23.852174 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 57
I, [2022-09-21T07:17:23.852234 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 118
118:signal-handler (1663744643) Received SIGTERM scheduling shutdown...
2022-09-21 07:17:23.852 UTC [57] LOG:  received fast shutdown request
2022-09-21 07:17:23.855 UTC [57] LOG:  aborting any active transactions
2022-09-21 07:17:23.860 UTC [57] LOG:  background worker "logical replication launcher" (PID 66) exited with exit code 1
2022-09-21 07:17:23.860 UTC [61] LOG:  shutting down
2022-09-21 07:17:23.878 UTC [57] LOG:  database system is shut down
118:M 21 Sep 2022 07:17:23.936 # User requested shutdown...
118:M 21 Sep 2022 07:17:23.936 * Saving the final RDB snapshot before exiting.
118:M 21 Sep 2022 07:17:23.937 * DB saved on disk
118:M 21 Sep 2022 07:17:23.937 # Redis is now ready to exit, bye bye...


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1212 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

Related posts where the fixes don’t apply to me:

1 Like

I’ve attempted a few things and made a PR to your plugin and the fix seems to be working.

2 Likes