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

Add gel add command #94

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add gel add command #94

wants to merge 3 commits into from

Conversation

JuanitoFatas
Copy link
Collaborator

@JuanitoFatas JuanitoFatas commented Oct 25, 2019

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

  • bin/setup && bin/rake

To capture standard error output
$ gel add pry

will add pry to the end of Gemfile.
@matthewd
Copy link
Member

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.

@JuanitoFatas
Copy link
Collaborator Author

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 😅?

Base automatically changed from master to main January 16, 2021 11:41
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 this pull request may close these issues.

2 participants