Question

I want to use MiniProfiler on my own dev server, but don't want to force all other devs on the project to install and use it. The only way I would know how would be to have git ignore updates to my gemfile, but that's definitely not what I want. Is there a way to start a rails server with a custom gemset?

Was it helpful?

Solution

Gemsets for different projects

Check out rvm (or rbenv with rbenv-gemset) for custom gemsets for various projects. For tests, appraisal is nice. In GitHub, using TravisCI can be a good thing.

I think that on its own will probably answer your question, but I'd like to also address the problem of working with different gems in the same project (not just the same server), so that is what follows...

Different gemsets for same project

If you want a specific Gemfile and Gemfile.lock just for you, and if those are in your source control (which they should be), yours are going to differ from theirs if you want to do what you are saying.

You could physically separate your Gemfile and Gemfile.lock from theirs, but it wouldn't be a good idea. Here's why:

Per standard practice, you want to usually use a pessimistic version constraint ~> ... in Gemfile for non-prerelease versions, or for prereleases use '>= ...', '< ...'. Then Gemfile.lock becomes the place where the gems for the project are locked down. Then, you or any other developer can try bundle update on specific gems to update them and, assuming everything works and everyone is using rational versioning and sane dependency declarations (which isn't always the case and it will break periodically), it should just update the gem you depend on to a version that hopefully won't break things.

When another developer updates gems or adds removes gems, they will make the changes to Gemfile and Gemfile.lock and you will get those from source control and you will see that you need to do a bundle install to add them.

So, what are some sane options? The easiest (really), though it is error-prone, might be to just remember to add/remove your stuff from Gemfile and be careful. This way you can be sure that you get changes from others.

You could also work in a different source control branch that has your changes and be constantly merging their changes into your branch. However, eventually you will want to merge your changes to the branch they are working in, so I don't really think this provides a lot of benefit.

The real solution to having different gems in the same project than others on your team is to have a discussion with them as to why you are both in the same project and not using the same gems. They might be willing to use them, or maybe you shouldn't be using them.

But, again, if it is just having gemsets for each project, that's easy: rvm and rbenv are two well-used solutions, and there are other ways to do that answered elsewhere on S.O.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top