2014-09-25 80 views
2

好吧,我正在制作一个名为dogify的hello世界宝石,但我无法将它安装在我的演示项目中。安装自己的宝石

这里是我的gemspec,请向任何其他文件:

# coding: utf-8 
lib = File.expand_path('../lib', __FILE__) 
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 
require 'my_dogify/version' 
Gem::Specification.new do |spec| 
    spec.name   = "my_dogify" 
    spec.version  = MyDogify::VERSION 
    spec.authors  = ['me'] 
    spec.email   = ['me'] 
    spec.summary  = 'summmary' 
    spec.description = 'description' 
    spec.homepage  = "" 
    spec.license  = "MIT" 

    spec.files   = `git ls-files -z`.split("\x0") 
    spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 
    spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 
    spec.require_paths = ["lib"] 

    spec.add_development_dependency "bundler", "~> 1.7" 
    spec.add_development_dependency "rake", "~> 10.0" 
    spec.add_development_dependency 'rspec' 

    spec.add_dependency 'engtagger' 
end 

这里是我的Gemfile

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '4.1.5' 
# Use sqlite3 as the database for Active Record 
gem 'sqlite3' 
# Use SCSS for stylesheets 
gem 'sass-rails', '~> 4.0.3' 
# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 
# Use CoffeeScript for .js.coffee assets and views 
gem 'coffee-rails', '~> 4.0.0' 
# See https://github.com/sstephenson/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use jquery as the JavaScript library 
gem 'jquery-rails' 
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 
gem 'turbolinks' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.0' 
# bundle exec rake doc:rails generates the API under doc/api. 
gem 'sdoc', '~> 0.4.0',   group: :doc 

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 
gem 'spring',  group: :development 
# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# Use unicorn as the app server 
# gem 'unicorn' 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 

# Use debugger 
# gem 'debugger', group: [:development, :test] 

gem 'my_dogify' 

命令行:

$ bundle install 
Fetching gem metadata from https://rubygems.org/.......... 
Resolving dependencies... 
Could not find gem 'my_dogify (>= 0) ruby' in the gems available on this machine. 
+2

您必须指定您已建立的本地gem的路径。 – 2014-09-25 13:40:34

回答

3

默认情况下,宝石被搜索的RubyGems存储库。这意味着为了使用my_dogify它必须是published on RubyGems

如果你不关心发布它,你只是想在本地使用它,然后use the path option来指定gem的路径。

gem 'extracted_library', :path => './vendor/extracted_library' 
+0

谢谢你这么多!只是为了帮助他人,路径应该是你宝石的根文件夹。所以对我来说,它是宝石''extracted_library',:path =>'dogify' – Starkers 2014-09-25 14:01:42