New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundler plugins #3319
Comments
cc @indirect @segiddins @colby-swandale |
cc @asutoshpalai who implemented plugins |
@jules2689 thanks! this is super helpful. Would you be interested in writing up an RFC-format document with what you think the next version of plugins should look like? If not, no worries, and we'll try to work on improving the plugin system as we have time. |
Could a plugin be installed only for a specific group? E.g. group :development do
plugin 'my_plugin'
end UPD: if I place a plugin under the development group and run
Bundler version 1.17.3. |
I've been looking this, and it seems several of the issues mentioned here have been fixed:
These things are still broken:
I'd also like to see a new hook for before/after gemfile evaluation. It seems like a lot of plugins recommend doing |
#6957 now fixes this as well |
#6957 also now gracefully handles if a plugin is referencing a gem outside the .bundle directory, and that gem gets removed. It gives a nice error message |
Bundler Plugin System
The Bundler Plugin system allows a developer to integrate into certain points in Bundler's runtime. These include, at the time of writing,
before-install
,before-install-all
,after-install
, andafter-install-all
. There is also an option to add your ownbundle
commands likebundle viz
.Each of these points allows a plugin to interact with a
Bundler::ParallelInstaller::SpecInstallation
in the singularinstall
options, and arrays ofBundler::Dependency
objects in the-all
options.These provide users with the opportunities to modify the behaviour of
bundle install
to their heart's content.I've seen two use cases in practice:
bundler
plugin that makes gem installation errors more actionable, educative, and all around easier to understandThe former was created by myself and is intended for a large audience (everyone), while the latter was created by Rafael Franca and Edouard Chin - of the Shopify Rails team - and is intended for an organization or project needing to run two versions of a gem at once.
Distribution
The 2 aforementioned plugins presents two different distribution systems. The first errors handling plugin is intended to be installed using
bundler plugin install
while the latter is intended to be listed in theGemfile
using theplugin "blah"
stanza. Both methods have issues that I'll enumerate in this issue.bundler plugin install
The issue here is that it assumes users know to run
bundle plugin install
. This is not muscle memory, particularly since there exists practically no plugin gems available for use.Gemfile's plugin stanza
Once a Gemfile lists
plugin
in the stanza, it now has to evaluate every single time.bundle install
causes the plugin to be install every single time. Likely because it is not added to the.bundle/plugin/index
file.A Common Problem
What plugins exist? In what ways can I extend Bundler? No one can answer these questions. It is up to the plugin developer to market their plugin gem, to little benefit. Many people have never heard of Plugins.
This is even listed here: https://github.com/bundler/bundler/issues/4682
Issues with the plugin index
./.bundle/plugins/index
or~/.bundle/plugin/index
- it's not obvious what is where thoughindex
, to which Bundler seems to have issuesDeveloping/Managing Plugins
bundle plugin install
command, but once installed in another way, it ends up in the index forever and just works (TM)bundle plugin list
command bundler#5467) despite alist
command being added (Add plugin list command bundler#6120), it does not work.Summary
There are 3 main categories to focus on:
These 3 categories cause plugins to be more difficult to develop than needed (installing local plugins), difficult to use (technical issues and management), and difficult to find (distribution). This section aims to provide a list of requirements to start to remedy these issues.
Technical Issues
plugin
index, that is apparent and evident. Tell the user when a plugin is being installed that a plugin is "Installing globally" or "Installing locally"plugin
stanza goes to.bundle/plugins/index
bundle plugin install
goes to~/.bundle/plugins/index
unless--local
flag or something is setplugin
stanza does not cause abundle install
to always evaluate and does not prevent abundle check
from succeedingDistribution
plugins
. This can be determined by looking for a validplugin.rb
file in the base of the gem.I don't expect wide adoption of plugins. It is likely to be a fragmented system, so we should be looking to see how a plugin affects the ecosystem and adopt the ones intended for all users into core where it makes sense.
Management of plugins
bundle plugin uninstall
commandbundle plugin list
commandindex
filebundle plugin install
(this should be local only, I'd think?)The text was updated successfully, but these errors were encountered: