Having a hard time installing `eth` gem in a plugin in production

Here’s what I did. I logged in to the server and entered the docker container.

  • create a folder called gems

  • create a subdirectory 2.7.5 (ruby version used by production discourse on tests-passed)

  • cd back to gems folder

  • Run commands in this fashion

    RUBY_VERSION=2.7.5
    gem install pkg-config -v 1.4.7 -i $RUBY_VERSION --no-document --ignore- 
    dependencies --no-user-install
    gem install mkmfmf -v 0.4 -i $RUBY_VERSION --no-document --ignore-dependencies 
    --no-user-install
    ...
    

    Note: these are the exact same commands discourse runs(tries to run, but fails) to install the gems.

  • Now zip this folder.

  • Exit the docker container and copy the zip outside the docker container using docker cp command.

  • Connect to your server via filezilla or vscode and download the zip.

  • extract it to the root folder of your plugin. So your plugin folder would now have the gems directory.

  • Now push the gems folder with the plugin to github.

Now when you do a rebuild on discourse with this plugin, discourse will use the dependencies you supplied it and won’t try to install them. This is a temporary workaround and would need to be re-done once discourse bumps the ruby version.

But here’s the big question, why do the same commands that work when running from the terminal fail when discourse tries to run it. It would be really worth looking into and I hope there’s a simple fix.

3 Likes