简体   繁体   English

使用命令行中的bundler将gem添加到gemfile

[英]Add gem to gemfile with bundler from command line

When using node package manager you can specify npm install --save mynodemodule which automatically pops the module in package.json 使用节点包管理器时,您可以指定npm install --save mynodemodule ,它会自动弹出package.json的模块

I was wondering if there is a command for bundler that allows you to add the gem and version to the gemfile from the command line? 我想知道是否有一个Bundler命令允许你从命令行添加gem和版本到gemfile?

For example bundle install --save nokogiri 例如bundle install --save nokogiri

Just wrote Gemrat to do this. 刚刚写了Gemrat来做这件事。

    $ gem install gemrat 
    $ gemrat nokogiri

    #=> gem 'nokogiri', '1.6.0' added to your Gemfile.
    #=> Bundling...

If you visit this question in 2018, bundler now has a cli to do this: bundle add <gem-name> <version> 如果您在2018年访问此问题, bundler现在有一个cli来执行此操作: bundle add <gem-name> <version>

Version string could be your typical gem version including >= and ~ 版本字符串可能是您典型的宝石版本,包括>=~

echo 'gem "nokogiri"' >> Gemfile

as @zocoi described, you can use bundle and specify the group: 正如@zocoi所描述的,您可以使用bundle并指定组:

bundle add rails --group "development, test"

More information 更多信息

bundle add --help

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

相关问题 从命令行安装gem与更改gemfile - install gem from command line vs changing gemfile 使用Bundler进行宝石开发:包含或排除Gemfile? - Gem development with Bundler: include or exclude Gemfile? 通过捆绑程序安装的Ruby Gem和Gemfile无法加载 - Ruby Gem installed through bundler and Gemfile not loading Bundler 找不到 gem &quot;bundler&quot; 的兼容版本:在 Gemfile 中: - Bundler could not find compatible versions for gem "bundler": In Gemfile: 使Bundler解析并从Gemfile中的Gemfile中加载依赖项: - Have Bundler parse and load dependencies from Gemfile/s in gem/s loaded with :path 将Gem&#39;wdm&#39;添加到您的GemFile - Add Gem 'wdm' to your GemFile 我是否需要将Bundler本身添加到Gemfile中? - Do I need to add Bundler itself to the Gemfile? Bundler找不到与“ bundler”宝石兼容的版本:在Gemfile中:rails(= 3.0.0)已解析为3.0.0,这取决于捆绑程序(〜&gt; 1.0.0) - Bundler could not find compatible versions for gem “bundler”: In Gemfile: rails (= 3.0.0) was resolved to 3.0.0, which depends on bundler (~> 1.0.0) Gem :: LoadError:将`gem'mysql'添加到你的Gemfile中 - Gem::LoadError: Add `gem 'mysql'` to your Gemfile 捆绑器即使安装在Gemfile中也不会安装Jasmine gem - Bundler not installing Jasmine gem even when it's in Gemfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM