2013-05-27 47 views
0

我创建了一个文件宝石类似下面,我在Windows尝试这种7环境如何在Windows中安装使用捆扎机黄瓜7

source :rubygems 

group :test do 
gem 'cucumber', '1.2.1' 
gem 'rspec-expectations', '2.11.2' 
end 

这是在cmd中执行“C:\ mysite的\红宝石test.rb”

System throw following error msg, 
test.rb:1:in '<main>' : undefined method 'source' for main:Object (NoMethodError) 

我已经改变了第一线

source 'http://rubygems.org/' 

但我仍得到相同的错误。很感激,如果任何人都可以给予指点,我很新的黄瓜&红宝石

+1

@Sachin已经给出了解决方案,但也避免在文件名中使用空格,否则会遇到很多问题。 –

+1

**您正在使用不安全的源**!您应该像这样指定HTTPS RubyGems源代码:'source'https:// ruby​​gems.org''。 –

+0

我已经改变了源,如上所述,仍然面临同样的问题 – user1767083

回答

1

首先安装捆绑与

gem install bundler 

然后进入你的项目目录。宝石文件必须被命名为Gemfile。然后,你可以做

bundle install 

此外,您应该使用HTTPS:

source 'https://rubygems.org/' 
+0

感谢您的快速回复。我按照说明和'gem install bundler'按预期工作,但是当我执行bundle install命令时,出现以下错误'Bundler :: GemfileNotFound' – user1767083

+0

您是否将文件重命名为'Gemfile'?你是否从'Gemfile'所在的目录执行命令? –

+0

是的,我的文件名是Gemfile.rb,并且从Gemfile所在的目录执行该命令。 – user1767083

0

看来你已经把“源‘http://rubygems.org/’”行 “test.rb”,这是不允许的,你必须把这个代码的Gemfile

source 'https://rubygems.org/ 

group :test do 
    gem 'cucumber', '1.2.1' 
    gem 'rspec-expectations', '2.11.2' 
end 

文件的Gemfile和 做bundle install

+0

感谢您的快速回复。我按照说明和'gem install bundler'按预期工作,但是当我执行bundle install命令时,出现以下错误'Bundler :: GemfileNotFound' – user1767083

+0

您应该在执行'bundle install'时处于应用程序的根目录。 –