I’m currently writing a plugin that depends on a certain gem. Is there a way to specify gem dependencies for plugins? Essentially, I need the gem to be included in the discourse’s Gemfile so that it’s accessible from the plugin.
Yes, see this plugin for example:
This answers a basic case, but what about more complex cases? The current
gem method seems a little bit inadequate. For an actual example, I’m looking to have a plugin depend on a gem that 1) isn’t on RubyGems and is only located in a git repo and 2) depends on other gems.
Now there are easy ways to do this such as add it to the main Discourse
Gemfile, but of course that’s not very good plugin encapsulation. Any recommended better solutions?
You must be explicit about your dependencies in your plugins, including all sub dependencies. You can specify a custom gem source if needed.
There has been talk about aux Gemfiles but it still is not slotted to the bundler team.
If you start butchering our Gemfile.lock you are going to be in merge hell.
Transforming simple ruby files into a ruby gem
Hmm, wish there was a cleaner way to do things, but what you describe seems reasonable enough given the options.
I suppose an argument could be made that plugins should be in the form of actual gems and require their dependencies that way, but then that brings up the same issues with Gemfile.lock. And nobody wants to end up in merge hell… shudder