开发者

How do I properly gem unpack a gem in a rails application?

开发者 https://www.devze.com 2023-01-17 01:05 出处:网络
I tried rake gems:unpack rake gems:unpack:dependencies Then i ran rake gems:refresh_specs which gave me this error

I tried

rake gems:unpack
rake gems:unpack:dependencies 

Then i ran

rake gems:refresh_specs 

which gave me this error

undefined method `installed_source_index' for #<Gem::SourceIndex:0x100549718>

then i ran this

rake gems:install

Then i ran script/console and tried to use the gem and error

ITunesSearchAPI.lookup(:id => 3996865, :entity => :song)
NameError: uninitialized constant开发者_运维知识库 ITunesSearchAPI

this is

RAILS_GEM_VERSION = '2.3.8'


In case anyone else comes across the error above: "undefined method `installed_source_index' for #"

When running: rake gems:refresh_specs

The error is caused when rails 2.3.x is running as a gem as apposed to running from within your applications vendor/rails directory. It was reported and fixed https://rails.lighthouseapp.com/projects/8994/tickets/2978-rake-gemsrefresh_specs-not-working-as-expected

If you can't get the fix or if you'd rather work around it you can freeze your version of rails into your application first: rake rails:freeze:gems

Then try rake gems:refresh_specs again and it should work


On a side note, instead of unpacking gems, I've used bundler with 2.3 apps. Works like a charm and you can use it to cache your .gem files inside your app's vendor/cache folder.

Not an option for everyone, but if you can use bundler, it makes your life much easier.

0

精彩评论

暂无评论...
验证码 换一张
取 消