-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
bundle install does not run the gems hooks #3239
Comments
Hi @anks333! Please provide steps so we can reproduce this issue in our environment. Thanks! |
|
this is my gem file when I run |
if I do in the context of node.js, modules have |
I think this is actually a rubygems issue. Post install hooks only fire for gems that are already installed when ruby boots and requires rubygems:
|
if so, then if I run |
Yep, if |
From my understanding, it appears that the Rusky gem is using rubygems plugins in a way that is not intended 🤔 here is what makes me think that. Plugins are "Extensions that use the RubyGems plugin API" and so are ways that you can extend and modify the behavior of Rubygems in general and not just for one specific gem. One way that you can share these plugins would be to gemify it and share it with others. Once the gem is installed, rubygems would find the plugin (and any hooks, commands, etc. it adds) during future installs. Rusky attempts to use the plugin API to add it's own post install behavior https://github.com/ohbarye/rusky/blob/3edc4ddae4172a5bf5407226d2fe1f71434d64d7/lib/rubygems_plugin.rb#L6-L8 but from what I understand, this would not have the expected behavior. As we were seeing in the example above, installing the gem the first time will add this plugin behavior for subsequent installs, but on the initial install would not run (because during that install, the plugin was not installed or active yet). If this understanding is correct, then the rubygems plugin API is working as expected and the observed issue is due to the way the Rusky gem is attempting to use it to run it's own post install behavior in a way the plugin API is not intended to be used. Does this understanding seem correct to others that might have more context on the rubygems plugin API? |
You're right @rreinhardt9. |
I understand that the Take So, instead of:
we would get
By the way, we should review the https://guides.rubygems.org/plugins/ guide, since rubygems no longer uses |
I think you can create "extension" to run custom script during gem install. Rakefile extension would be enough here. |
Yes, you can. In my opinion though, that's unrelated to whether we should consider this as an issue or not. I was personally surprised by this behaviour when I first found it, and only made sense after seeing the implementation. I believe we should either make this case work as I suggested, or improve our documentation about it. |
This is super fascinating to me really; I'm just learning about this cool plugin system from this issue 🎉
I wonder if it could start to be a bit of a rabbit hole to try and make sure that when a plugin is installed from a gem it immediately takes effect. For example: post_installIn this case, let's say running bundler is going to install 4 gems and our plugin is in the 3rd. Would gems 1 and 2 not get the post_install behavior but gems 3 and 4 would because the plugin would be required after it's installed as the 3rd gem? pre_installIn this case, let's again say running bundler is going to install 4 gems and our plugin is the 3rd. Would gems 1, 2, and 3 not get the pre_install behavior, but gem 4 would because it would now be present after gem 3 is installed and required? For the Rusky gem, I believe that since it's installed itself as a "plugin" that post_install hook is going to run for every gem that is installed, not just the Rusky gem, on subsequent bundle runs 🤔 Which doesn't appear to have been the intended behaviour (they just wanted some post install setup to happen when that single gem was installed it appeared). I'm kind of thinking that like you said, better clarity through documentation might be a good place to start here. I'd love to help out with that if I can! Would a good start be to open some issues for clarifying plugin documentation on the https://github.com/rubygems/guides repo and linking back to this issue? |
Thanks for the input @rreinhardt9, I'll be offline for a few days but I'm marking this thread as unread and will get back to your post when I come back online next Wednesday. |
There's some interaction between bundler and rubygems here that I want to review at some point, but from the current state of the code I think the idea is that
I think in this case I'd expect no new pre-install hooks to be run at all. Essentially consider the whole bundle as a unit and only run
Yes, it seems like misusing
Sure. Whatever the expected behaviour is, documenting the current way things work would be a nice improvement anyways. |
Is this discussion question possibly related? Sounds like it might be. TL;DR- RBENV is no longer able to rehash its shims after |
I am using rusky gem in my project for git hooks. and rusky has post-install script to create the git hooks.
but when I do
bundle install
then hooks are not getting createdbut when I do
gem install rusky
it runs the postscript and creates the git-hooks.so, for now, I am running
rusky install
explicitly, which is a little annoying.do let me know how to invoke postscript of gems or any script after
bundle install
The text was updated successfully, but these errors were encountered: