sameera207
sameera207

Reputation: 16629

Custom Ruby gem is not loading with bundler

I'm creating a custom gem (sample_gem) and I want to use it inside one of my sample Rails app and see how it works. In my gem version is 0.0.1 (default)

So What I did so far is,

  1. created a rails4 project - sample project
  2. clone the gem source to vendor/sample_gem
  3. in the the sample_project gem file added

    gem 'active_console', '0.0.1', path: './vendor/active_console'

but when I run bundle install I'm getting the following error

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'sample_gem (= 0.0.1) ruby' in source at ./vendor/sample_gem.
Source does not contain any versions of 'sample_gem (= 0.0.1) ruby'

I searched the web and for several gems, but seems like I couldn't figure out the issue.

Upvotes: 0

Views: 197

Answers (3)

Малъ Скрылевъ
Малъ Скрылевъ

Reputation: 16514

Do fix thine sequence with the following:

Let's assume that sample_gem custom gem is resided in the /home/user/git/sample_gem folder, and bundler is already installed.

  1. Create a rails project;

  2. Add to its Gemfile the following line:

     gem 'sample_gem', path => '/home/user/git/sample_gem'
    
  3. Issue bundling with:

     $ bundle install
    

NOTE: If thine sample_gem gem requires active_console gem, the last shell be specified in the Gemfile of the sample_gem gem.

Upvotes: 1

Sam Lehman
Sam Lehman

Reputation: 343

I had to rvm implode and re-install rvm/rubies for this to work...

Upvotes: 0

skozz
skozz

Reputation: 2720

Rails 4.

  1. Puts the gem's folder in the root directory of your application
  2. Call your gem in the Gemfile normally like sample_gem
  3. Bundle install

This works right now in my Rails 4 app.

Upvotes: 1

Related Questions