简体   繁体   English

自定义 Ruby gem 未使用捆绑程序加载

[英]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,所以到目前为止我所做的是,

  1. created a rails4 project - sample project创建了一个 rails4 项目 - sample project
  2. clone the gem source to vendor/sample_gem将 gem 源克隆到vendor/sample_gem
  3. 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

  1. Create a rails project;创建一个 Rails 项目;

  2. Add to its Gemfile the following line:将以下行添加到其Gemfile中:

     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.注意:如果您的sample_gem gem 需要active_console gem,则在sample_gem gem 的Gemfile中指定最后一个 shell。

Rails 4.导轨 4.

  1. Puts the gem's folder in the root directory of your application将 gem 的文件夹放在应用程序的根目录中
  2. Call your gem in the Gemfile normally like sample_gem通常像sample_gem一样在 Gemfile 中调用您的 gem
  3. Bundle install捆绑安装

This works right now in my Rails 4 app.这现在在我的 Rails 4 应用程序中有效。

我不得不使rvm implode并重新安装 rvm/rubies 才能使其正常工作...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM