Tag:

NoMethodError:main:Object的未定义方法`on’

当我尝试bundle exec cap production deploy –trace我收到一条错误消息: deploy@h2540559:/www/apps/foodsoft$ bundle exec cap production deploy –trace ** Invoke production (first_time) ** Execute production ** Invoke load:defaults (first_time) ** Execute load:defaults ** Invoke rvm:hook (first_time) ** Execute rvm:hook cap aborted! NoMethodError: undefined method `on’ for main:Object /usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:17:in `block (2 levels) in ‘ /usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:248:in `call’ /usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:248:in `block in execute’ /usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:243:in […]

如何使用OptionParser解析rake参数

我正在尝试使用OptionParser来解析rake参数。 我从那里简化了示例,我不得不添加两个ARGV.shift以使其工作。 require ‘optparse’ namespace :user do |args| # Fix I hate to have here puts “ARGV: #{ARGV}” ARGV.shift ARGV.shift puts “ARGV: #{ARGV}” desc ‘Creates user account with given credentials: rake user:create’ # environment is required to have access to Rails models task :create => :environment do options = {} OptionParser.new(args) do |opts| opts.banner = […]

如何加快Ruby / Rake任务的速度

rake –tasks需要大约18秒才能运行。 这只是加载所有任务所需的时间,因此我定义的任何任务至少需要花费这么多时间来运行: $time rake –tasks rake db:clean # Cleaning up database rake passenger:restart # Restart Application rake spec # Run specs real 0m18.816s user 0m7.306s sys 0m5.665s 我的Rakefile: $: < :spec 知道为什么rake需要多次? 谢谢

如何在使用JRuby或bundle exec时使用rspec启用颜色?

我正试图用JRuby运行我的rspec: rake spec 这导致: jruby -S bundle exec rspec –color spec/foo_spec.rb 没有颜色出现,所以我从等式中删除了Jruby: bundle exec rspec –color spec/foo_spec.rb 没有颜色。 如何将“–color”选项传递给rspec? 我在项目的根目录中也有一个.rspec文件,在这些情况下似乎没有帮助。 但是,当我运行时,会提取或使用.rspec文件: rspec spec/foo_spec.rb 有任何想法吗?

如何在运行selenium ruby​​ webdriver脚本时从命令提示符ruby窗口输出文件时导出结果

目前,我正在我的测试套件中运行所有selenium脚本(由Selenium Ruby Webdriver编写),在“使用Ruby启动命令提示符”终端中使用rake gem。 要做到这一点,我必须创建一个名为“rakefile.rb”的文件,其中包含以下内容,并在我的终端中调用“rake”:(我在之前的post中根据一个人的指南了解这些知识)。 task :default do FileList[‘file*.rb’].each { |file| ruby file } end 但是,如果执行时有一个脚本失败,则将终止运行。 请帮忙指导我如何修改“rakefile.rb”,这样如果有一个脚本失败,系统会忽略它并继续在我的测试套件中运行下一个脚本? 另外,您可以建议我在将脚本运行到一个输出文件时编写所有结果吗?或者将每个脚本的结果放在每个输出文件中,输出文件将显示脚本列表失败。 任何帮助表示赞赏。 非常感谢。

无法找到捆绑exec的rake

当我尝试执行’ bundle exec rake anything ‘时,我收到错误: Could not find rake-10.1.0 in any of the sources. Run `bundle install` to install missing gems. 但是当我执行简单的“耙任何东西”时 ,耙子正在工作。 当然,我试过以任何方式设置gem,我知道: gem install rake -v = 10.1.0 在Gemfile中写了“gem’rake ‘,’10 .1.0 ‘ ”,然后执行bundle install 我为所有rvm安装了gem: rvm都做了gem install rake -v 10.1.0 这种情况真的很沮丧,因为简单的rake工作,但是捆绑exec不想要。 我需要使用bundle exec执行rake 真的需要你的帮助!

无法在任何来源中找到rake-10.0.4(Bundler :: GemNotFound)

我最近一直试图在服务器上运行我的ruby应用程序,并且我一直遇到这个错误: Could not find rake-10.0.4 in any of the sources (Bundler::GemNotFound) 我正在运行Rails 3.2.12和Ruby 1.9.3p392。 到目前为止,我在访问服务器时没有遇到任何问题,这是我第一次遇到此错误。 我一直在寻找答案,但由于我对ruby和rails相对较新,我找不到一个简单易懂的答案。 Gemfile : source ‘http://rubygems.org’ # STANDARD SET OF GEMS, SEE BOTTOM OF FILE FOR A LIST OF OTHER USEFUL GEMS gem ‘rails’, ‘3.2.12’ gem ‘haml-rails’ gem ‘retina_tag’ gem ‘mysql2’ gem ‘will_paginate’ gem ‘bootstrap-will_paginate’ gem ‘contact_form’ gem ‘draper’ gem ‘pony’ […]

如何在rails应用程序中运行rake任务

我想做的事: 在model.rb中,在after_commit中,我想运行rake task ts:reindex ts:reindex通常使用rake ts:index运行

如何在我的Sinantra应用程序/环境下运行Rake任务?

我正在使用Sinatra,我想设置一些Rails具有的便利rake任务,特别是rake db:seed 。 我的第一关是这样的: namespace :db do desc ‘Load the seed data from db/seeds.rb’ task :seed do seed_file = File.join(File.dirname(__FILE__), ‘db’, ‘seeds.rb’) system(“racksh < #{seed_file}") end end racksh是一个模仿Rails控制台的gem。 所以我只是将种子文件中的代码直接输入其中。 它有效,但显然不理想。 我想做的是创建一个环境任务,允许命令在Sinanta应用程序/环境下运行,如下所示: task :environment do # what goes here? end task :seed => :environment do seed_file = File.join(File.dirname(__FILE__), ‘db’, ‘seeds.rb’) load(seed_file) if File.exist?(seed_file) end 但我无法弄清楚如何设置环境以便rake任务可以在其下运行。 任何帮助将非常感激。

在mac上安装cocoapods失败

我试图按照http://cocoapods.org/的说明在mac上安装cocoapods,但是得到了如下错误: $sudo gem install cocoapods ERROR: While executing gem … (Gem::RemoteFetcher::FetchError) bad response Service Unavailable: Back-end server is at capacity 503 (https://api.rubygems.org/api/v1/dependencies?gems=cocoapods) 但有时,错误信息是不同的。 $ sudo gem install cocoapods Password: Building native extensions. This could take a while… ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension. rake RUBYARCHDIR=/Users/tap4fun/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-12/1.9.1/xcodeproj-0.17.0 RUBYLIBDIR=/Users/tap4fun/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-12/1.9.1/xcodeproj-0.17.0/Users/tap4fun/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:298:in `to_specs’: Could not find […]