如果我下载了一个。gem文件到我电脑的文件夹中,我以后可以使用gem install安装它吗?
当前回答
进入gem所在的路径,调用gem install -l gemname.gem
其他回答
如果你用bundler创建宝石:
# do this in the proper directory
bundle gem foobar
你可以在它们写完之后用rake安装它们:
# cd into your gem directory
rake install
很有可能,你下载的gem也知道rake的安装。
这是我的DRY装置:
Look into a computer with already installed gems needed in the cache directory (by default: [Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache) Copy all "*.gems files" to a computer without gems in own gem cache place (by default the same patron path of first step: [Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache) In the console be located in the gems cache (cd [Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache) and fire the gem install anygemwithdependencieshere (by example cucumber-2.99.0)
这是DRY,因为安装任何宝石后,默认情况下,rubygems把宝石文件在缓存宝石目录和没有意义的复制文件,这是更容易,如果你想两台计算机有相同的版本(或被妄想的安全规则:v)
编辑:在ruby或rubygems的某些版本中,它不能工作和发射 警报或错误,你可以把宝石放在其他地方,但不会得到DRY, 其他替代方案是使用启动集成命令gem服务器和 在gem源代码中添加localhost url,更多信息在: https://guides.rubygems.org/run-your-own-gem-server/
你可以从https://rubygems.org/gems/下载宝石,或者通过捆绑和机架构建你的本地宝石。
eg:
捆绑宝石yourGemName 耙式安装
在安装真正的宝石之前,要注意安装依赖项。
gem install——local /pathToFolder/xxx-2.6.1.gem
注意:如果在同一台机器上使用fluentd td-agent和ruby。请务必使用td-agent的td-agent-gem命令。td-agent有自己的Ruby。
你也可以使用完整的文件名到你的gem文件:
gem install /full/path/to/your.gem
这个方法也很有效——这可能是最简单的方法
如果你从github或其他SCM主机站点下载项目文件,首先使用gem build来构建项目,这样你就可以得到一个任何东西。Gem文件在当前目录。然后gem安装它!
推荐文章
- 一行if语句不工作
- 在Ruby中将整数转换为十六进制字符串
- 如何记录Ruby代码?
- Ruby:包含的反义词是什么?Ruby数组?
- 在Ruby中,proc和lambda有什么区别?
- 如何传递参数到一个Rake任务与环境在Rails?
- 获取当前正在执行的方法的名称
- 如何在Rails中计算相对时间?
- 在Ruby中使用范围填充数组的正确方法
- “for”和“each”在Ruby中
- 我如何复制一个哈希在Ruby?
- Ruby/Rails:将Date转换为UNIX时间戳
- 我如何编码/解码HTML实体在Ruby?
- Ruby有一个string. startwith ("abc")内置方法吗?
- 如何从URL下载文件并保存在Rails中?