Using the bundles inside my gem

I wanted to use bundler inside the gem that I wrote. I had a gemfile and in my_gem_file.rb I have

require 'rubygems'
require 'bundler'
Bundler.setup
Bundler.require(:default)

But when I build and install my stone, I get a Bundler :: GemfileNotFound exception: Could not find the Gemfile. Is there any solution for using bundles inside gems?

+1
source share
3 answers

The Bundler is not suitable for managing gems in a gem source. Inside the gem, just require the library you need.

+2
source

.gemspec, , . Bundler.

, Bundler . Gemfile:

source :rubygems
gemspec

Bundler .gemspec, , . : http://jeffkreeftmeijer.com/2010/bundler-because-your-gems-depend-on-gems-too/

+3

, Bundler . . gemspec ?

dev

Gem::Specification.new do |s|
  s.add_development_dependency("mocha", ["~>0.9.8"])

, s.add_dependency("i18n", ["~>0.4.1"]) , .

You can end up with a Gemfile (as Theo shows), for example

source :rubygems
gemspec

group :test do
  gem 'rails', '3.0.0'
  gem 'mocha'
  gem 'rspec-rails', "~>2.0.1"
end

Nice and clean, easy to read. Hope this helps.

+2
source

Source: https://habr.com/ru/post/1771346/


All Articles