[英]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.我正在创建一个自定义 gem ( sample_gem
),我想在我的一个示例 Rails 应用程序中使用它,看看它是如何工作的。 In my gem version is 0.0.1 (default)在我的 gem 版本中是 0.0.1(默认)
So What I did so far is,所以到目前为止我所做的是,
sample project
创建了一个 rails4 项目 - sample project
vendor/sample_gem
将 gem 源克隆到vendor/sample_gem
in the the sample_project
gem file added在添加的sample_project
gem 文件中
gem 'active_console', '0.0.1', path: './vendor/active_console'宝石“active_console”,“0.0.1”,路径:“./vendor/active_console”
but when I run bundle install
I'm getting the following error但是当我运行bundle install
出现以下错误
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.我在网上搜索了几个宝石,但似乎我无法弄清楚问题所在。
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.假设sample_gem
自定义 gem 位于/home/user/git/sample_gem文件夹中,并且已经安装了bundler
。
Create a rails project;创建一个 Rails 项目;
Add to its Gemfile the following line:将以下行添加到其Gemfile中:
gem 'sample_gem', path => '/home/user/git/sample_gem'
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.注意:如果您的sample_gem
gem 需要active_console
gem,则在sample_gem
gem 的Gemfile中指定最后一个 shell。
Rails 4.导轨 4.
sample_gem
通常像sample_gem
一样在 Gemfile 中调用您的 gemThis works right now in my Rails 4 app.这现在在我的 Rails 4 应用程序中有效。
我不得不使rvm implode
并重新安装 rvm/rubies 才能使其正常工作...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.