开发者

How to include a .gem file in bundler (not source)

开发者 https://www.devze.com 2023-02-08 12:06 出处:网络
I have a rails app that is dependent on a library that I\'m developing simultaneously. When I deploy the app, I don\'t have the option to use :git => \'\' option in bundler to load in the gem for var

I have a rails app that is dependent on a library that I'm developing simultaneously.

When I deploy the app, I don't have the option to use :git => '' option in bundler to load in the gem for various reasons. Ideally what I want to do is the following

Gemfile

gem 'system-api', :gem => 'vendor/system-api开发者_如何学Python-1.0.0.gem'

I want to pre-build the gem and simply include it into the project and check it into git.

Is there a way to do this with bundler or even without using bundler?

[UPDATE 1]

I tried "gem 'system-api','1.0.0', :path => 'vendor/' " and bundler says it installed correctly, but the gem doesn't show up in 'gem list' nor does the rails project have a reference to it. It is shown with the 'bundle show' command.


It looks like bundler has a :path option. It'll run relative to the project's Gemfile location. The path only specifies the folder, not the actual gem name:

gem 'system-api', :path => "vendor"

See bundler's Gemfile docs for more info.


It MIGHT work if you put the X.gem file into ./vendor/cache

If you run "bundle package", then that's where bundler will put built .gem files. So if you put it there yourself, will bundler find it there? Maybe. But I'm not sure about the idea of having some gems packaged in ./vendor/cache and others not, not entirely sure if Bundler supports that, since I think "bundle package" insists on putting all of em in there.

http://gembundler.com/bundle_package.html http://gembundler.com/man/bundle-package.1.html

If instead of checking your pre-built X.gem into your repo, you can check the SOURCE for the X gem into your repo, and the source includes an X.gemspec file, THEN you can use the :path option. But I think as you've discovered the :path option expects to point at source, not a *.gem package. It's possible that if you simply unzip the *.gem, that will result in a directory that you can use bundler gem :path with. (A *.gem product is just a zipfile... I think.).

Not a definitive answer, but some ideas to explore maybe.


I would say it's normal gem list does not show your gem. You installed it through bundler, and you don't invoke bundler when running gem list. Instead, check with bundler exec gem list.

By the way, when using Bundler you should always use bundler exec before any command line you run (with the exception of rails server which has its own way to get Bundler up and running): bundle-exec man page


I did the following, which works:

gem 'libv8', '3.11.8.3mytest', :path => '../libv8/pkg'

And the ../libv8/pkg folder contains only the binary packaged gem libv8-3.11.8.3mytest-x86_64-linux.gem.

Hope this helps.

0

精彩评论

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