Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Rails 3's "bundle install" of local gem (frozen gem), keep getting "Source does not contain any versions of ..."?

I am using a gem which is in vendor/gems/some-api-0.1.0, copied over from another project, and added to Gemfile:

gem 'some-api', :path => '~/development/myproj/vendor/gems/some-api-0.1.0'

but if I do the following, it will fail with the message:

$ bundle install
Fetching source index for http://rubygems.org/
Could not find gem 'some-api (>= 0)' in source at ~/development/myproj/vendor/gems/some-api-0.1.0.
Source does not contain any versions of 'some-api (>= 0)'

Searching on the net seem to suggest needing a gemspec? So I need to write up a .gemspec some where, is that true? Can someone shred light of how it is done in this situation?

like image 648
nonopolarity Avatar asked Mar 21 '11 18:03

nonopolarity


People also ask

How do I fix a run bundle to install missing gems?

Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .

How do I set gem version in Gemfile?

There are several ways to specify gem versions: Use a specific version: gem "name-of-gem", "1.0" . You can find specific versions on Rubygems.org (provided that's the source you”re using) by searching for your gem and looking at the “Versions” listed. Use a version operator: gem "name-of-gem", ">1.0" .


2 Answers

There are many other similar posts on stackoverflow, but just in case someone stumble across this post:

For some reason, when you are trying to use a gem from local source, you need to specify exactly which version of the gem you are using, e.g.

gem 'some-api', '0.2.0', :path => '~/development/myproj/vendor/gems/some-api-0.1.0'
like image 82
S.Y.Chan Avatar answered Oct 11 '22 14:10

S.Y.Chan


Just claiming there is a gem in the :path doesn't mean there actually is a gem there. Gems have gemspec files describing the name of the gem, what files belong to the gem, and various other information.

If some-api-0.1.0 should contain a file named some-api.gemspec in the :path directory, and it should contain information about the gem that bundler could use to require the gem out of the :path.

like image 39
indirect Avatar answered Oct 11 '22 16:10

indirect