Search code examples
rubyrubygemsprojectalternate

Making a Ruby project that is not a gem (or some other kind)


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


Solution

  • 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!