ruby 如何创建 Gemfile?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30358612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a Gemfile?
提问by Saurabh Juneja
How do I create a Gemfile? I am trying to follow a tutorial (RSpec Tutorial) that says what is below, and I am not able to do it.
如何创建 Gemfile?我正在尝试遵循说明以下内容的教程(RSpec 教程),但我无法做到。
Here's a basic Gemfile to start with.
这是一个基本的 Gemfile。
source 'http://rubygems.org'
gem "rspec"
Rspec tutorial link: http://www.tweakstreet.io/blog/2015/2/9/using-standalone-jruby-and-rspec-to-test-your-java-projects
Rspec 教程链接:http://www.tweakstreet.io/blog/2015/2/9/using-standalone-jruby-and-rspec-to-test-your-java-projects
采纳答案by CDub
The Gemfile is just a text file within your project which contains a list of gems for use in your application.
Gemfile 只是您项目中的一个文本文件,其中包含在您的应用程序中使用的 gem 列表。
If you do not have one in your application, you can create the file using an editor of your choice, saving it as Gemfile(with no extension), and in your example, containing:
如果您的应用程序中没有,您可以使用您选择的编辑器创建文件,将其另存为Gemfile(无扩展名),在您的示例中,包含:
source 'https://rubygems.org'
gem 'rspec'
回答by Andy Waite
You can run bundle initto create a new, empty Gemfile.
您可以运行bundle init以创建一个新的空 Gemfile。
回答by Richard Hamilton
A gemfile is automatically created when you start a new rails application.
当您启动一个新的 rails 应用程序时,会自动创建一个 gemfile。
type rails new appNameand then it will be generated automatically. It will also be populated with some gems.
类型rails new appName,然后它会自动生成。它还将填充一些宝石。
To install the gems run bundle installor simply bundle
安装 gems 运行bundle install或简单地bundle
Make sure you are requiring the gems you need. specifically rspecand jruby
确保您需要所需的宝石。具体rspec和jruby
group :development, :test do
gem 'rspec-rails', '~> 3.0'
end
Look at this website for more information
查看此网站了解更多信息

