I'm working on a project currently that I don't want to be a gem (or some other kind of project). How would I go about setting it up so that I can still have the same compatibility requirement abilities as a gem (e.g. Gemfile dependencies) but simultaneously not be a gem (or some other kind of project)?
Asked
Active
Viewed 882 times
1 Answers
6
You have to actually try to build a gem so this is easy!
to use bundler without Rails, a gem, whatever just create a directory
mkdir my-non-gem-project
cd my-non-gem-project
install bundler
gem install bundler
and initialize your Gemfile
bundle init
that will create a Gemfile
for you and you can add to it and run bundle
to install the dependencies from it
The simplest way to use bundler in your project would then be to open your main app file and add
require 'bundler/setup'
Bundler.require
This will require all of the gems you have in your Gemfile in the file this is added to. I am pretty sure that this file must be in the same directory as your Gemfile. More information here
Have fun with your Ruby project!

mraaroncruz
- 3,780
- 2
- 32
- 31
-
Well, I might be wrong but why not simply `bundle gem my_gem`but he/she just doesn't have to use *rake tasks* or/and delete some files that he/she doesn't need. ps. above command gives gits repo, does `bundle init` do the same? – Darek Nędza Dec 06 '13 at 17:30
-
1@DarekNędza it doesn't do the same. `bundle gem foo` creates the gemspec, adds the Rakefile for the building the gem tasks, creates a Gemfile and the folder structure for a gem. It would be a bunch of extra stuff in a project where building a gem wasn't your goal. It is awesome though and makes building a gem incredibly easy. `bundle init` just creates an empty `Gemfile` – mraaroncruz Dec 06 '13 at 18:23
-
All right, I get how the Gemfile is created. Is there a way to do the same w/ the Rakefile to require Bundler's tasks? – T145 Dec 06 '13 at 20:52
-
@T145 I don't know what you mean by bundler's tasks. If you mean the gems you get add to you Gemfile, you can do that last require part in your Rakefile and you will have access to all of those gems. If you mean the gem tasks, you should should just make a gem with `bundle gem my_gem_name`. Or you can create a blank `Rakefile` and add `require "bundler/gem_tasks"` to the top. I don't think that would make any sense though. – mraaroncruz Dec 06 '13 at 21:33