Skip to content
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

Run bundle install after all hooks #265

Closed
cllns opened this issue Nov 8, 2024 · 2 comments · Fixed by #269
Closed

Run bundle install after all hooks #265

cllns opened this issue Nov 8, 2024 · 2 comments · Fixed by #269
Milestone

Comments

@cllns
Copy link
Member

cllns commented Nov 8, 2024

hanami new bookshelf runs bundle install, so users shouldn't have to run it themselves manually.

However hanami/rspec adds gem "capybara" to the generated Gemfile after that bundle install has already ran so the Gemfile.lock doesn't include it. The effect of that users think they've installed all the dependencies but they're missing any that were added from other gems.

To reproduce:

hanami new bookshelf
cd bookshelf/
git init && git add .
bundle install

and you'll see Gemfile.lock is now updated for capybara's dependencies.

I think it'd be great if we could add it in this repo, so any other gems that use after hooks to add to the Gemfile don't need to manually run bundle install themselves. If this isn't possible, then we should at least update hanami/rspec to run bundle install and document this.

I haven't looked into it but maybe we could use a before hook instead of an after hook to add the gems to the Gemfile before the bundle install is ran.

@timriley
Copy link
Member

timriley commented Nov 10, 2024

@cllns Thank you for finding this! I'd occasionally seen new hanami created with a not-consistent Gemfile/Gemfile.lock state, but I could never figure out how to reproduce it.

One fix here would be to move to using a before hook instead of after.

Unfortunately, Hanami::CLI.before "install" reads a bit strangely to my eyes. The hooks from these gems are intended to run at the end of a Hanami install process, so the "before" seems out of place.

If we left the gem CLI hooks alone, perhaps a simpler fix is this: at the end of Hanami::CLI::Commands::Gem::New, right after we call run_install_command!, we just re-run the bundler and npm instals again. What do you reckon?

This also feels like an easy-enough fix for us to make in the next day or so, so we can have it included in the 2.2.1 release we make before your workshop.

@timriley timriley added this to the v2.2.1 milestone Nov 10, 2024
@timriley
Copy link
Member

Actually, I take it back, I think before "install" feels fine. And if we did that, it would allow us to do a bundle install inside the body of the "install" command, and all would be right in the world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants