gel icon indicating copy to clipboard operation
gel copied to clipboard

Add gel add command

Open JuanitoFatas opened this issue 5 years ago • 2 comments

Implement gel add command (Context).

This command will let people add a gem to their Gemfile. Similar to bundle add that adds gem to the Gemfile and run bundle install.

Also introduced a capture_stderr method to test_helper to get the error message.

Todos

  • [ ] Fix tests

Tests

  • [x] bin/setup && bin/rake

JuanitoFatas avatar Oct 25 '19 06:10 JuanitoFatas

Awesome!

Do we also want gel add to run gel install after added to Gemfile?

Hmm.. I think so: it seems like the aim is to have a single command that gets you into a state where you can start using the gem. (Because our install doesn't currently re-resolve when the Gemfile changes [though that's also something we should fix], you'll also need a lock in there too.)

From a quick peek, it looks like Bundler actually does an in-memory resolve of the new-Gemfile-to-be, and verifies that it will be able to be resolved -- so if you try to add something impossible, it'll fail while leaving your Gemfile unchanged. If you're up for a bigger adventure, I think we might have the internal APIs to do that now (I'm thinking of #57 & #58 in particular).

If that looks too hard, though, we might be able to cheat by running the lock command, then undoing our Gemfile change if it fails.

matthewd avatar Oct 28 '19 14:10 matthewd

Thanks for the advice and Happy Friday!

I could not figure out the internal APIs to do in-memory resolving. Should we do something similar to how Gel::Environment.install_gem does here?

Is commit 3826571 the right direction for cheating 😅?

JuanitoFatas avatar Nov 01 '19 06:11 JuanitoFatas