3

Rails 4 @ Ruby 2

So i have two engine (A, B) gems that cannot be uploaded to Rubgems because the code is private, so im using git.

A must use B, so basically i should add B as a dependency in A gemspec. As far as i know, gemspec doesn't allow git based gems as a dependency inside gemspec.

I tried to use A gemfile but no luck. Is there a way out?

2
  • take a look at gemfury.com, it is like rubygems but for private gems, it is compatible with .gemspec Commented Sep 13, 2013 at 16:14
  • what did you exactly try with the Gemfile? I think if you include gem B into the Gemfile of gem A, it should work correctly. Don´t forget to run the bundle install command before you build your gem A. The dependencies should be in the Gemfile.lock Commented Sep 13, 2013 at 16:44

1 Answer 1

3

For development or test, you can do it in Gemfile. You can even point it to use your local folder.

gem 'gem_b', path: "/path/to/the/folder"

or to use a git reference

gem 'gem_b', git: "[email protected]:user/gem_b.git"

This will allow you to do the development and testing.

Another option is this. If you have 2 engines, I assume you also have a Rails app to use them. In that rails app, you can simply require them in Gemfile one after another using git reference.

gem 'gem_b', git: "[email protected]:user/gem_b.git"
gem 'gem_a', git: "[email protected]:user/gem_a.git"

If you must declare this dependency in gemspec, you can build the gem using rake;

cd /path/to/gem_b
rake build

This will create a gem_b.gem file under pgk folder.

Then you can install it in your local using gem instal like this

gem install pgk/gem_b.gem 

Now you have gem_b installed in our local. There will be no problem adding it as a dependency in gemspec.

When you are ready to release your application, you need to copy gem_b.gem to your server and install using usual way;

gem install /full/path/to/gem_b.gem 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.