Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails NoMethodError:未定义的方法`on';对于main:Object_Ruby On Rails_Ruby_Rake_Capistrano3_Rvm Capistrano - Fatal编程技术网

Ruby on rails NoMethodError:未定义的方法`on';对于main:Object

Ruby on rails NoMethodError:未定义的方法`on';对于main:Object,ruby-on-rails,ruby,rake,capistrano3,rvm-capistrano,Ruby On Rails,Ruby,Rake,Capistrano3,Rvm Capistrano,当我尝试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:defaul

当我尝试
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 <top (required)>'
/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 `each'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:243:in `execute'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:173:in `invoke'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-3.2.1/lib/capistrano/dsl/task_enhancements.rb:12:in `block in after'
/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 `each'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:243:in `execute'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/task.rb:173:in `invoke'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:106:in `each'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:100:in `top_level'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:78:in `block in run'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/rake-11.1.1/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p643/bin/cap:23:in `load'
/usr/local/rvm/gems/ruby-2.0.0-p643/bin/cap:23:in `<main>'
/usr/local/rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => rvm:hook
我的卷宗

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#
 require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
# require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.{cap,rake}').each { |r| import r }
还有我的deploy.rb

#
# Capistrano 3 deployment configuration
#
#   http://www.capistranorb.com/
#   https://semaphoreapp.com/blog/2013/11/26/capistrano-3-upgrade-guide.html

# defaults that can be updated from the environment
set :branch,              ENV["REVISION"] || ENV["BRANCH_NAME"] || "master"

# you probably want to change these
set :application,         'foodsoft'            # application name (whatever you like)
set :domain,              'biomio-giessen.de' # host
set :user,                'deploy'              # ssh deploy user
set :keep_releases,       10
set :repo_url,            'git://github.com/foodcoops/foodsoft.git'
set :deploy_to,            "/www/apps/#{fetch :application}-#{fetch :stage}"

# more settings which are probably ok
set :log_level,           :info
set :linked_files,        %w{config/database.yml config/app_config.yml config/initializers/secret_token.rb config/initializers/session_store.rb}
set :linked_dirs,         %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# assuming one server for everything, with one user for deploy and one for resque
server fetch(:domain), user: fetch(:user), roles: [:web, :app, :resque, :db]

# if you use RVM, uncomment the line in Capfile, and optionally uncomment rvm settings
# set :rvm_ruby_string,     :local

# task hooks
namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # tell mod_passenger to reload the application
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :restart, 'resque:restart'

  after :finishing, 'deploy:cleanup'

  # see lib/capistrano/tasks/plugins.cap
  #before 'bundler:install', 'enable_plugins:auto'

end
有人知道如何解决这个问题吗

多谢各位,
Maxi

在运行bundle更新后,我刚刚遇到了相同的错误,除了Rake到11之外,没有更新主要版本。从capistrano 3.2.1升级到3.4.0为我修复了它

我也有同样的错误

我的capistrano版本是3.1.0,rails版本是4.1.4。 但我的同事没有这个问题。我尝试将我的ruby版本、rvm版本更改为与我同事的配置相同的版本。它仍然不起作用。 所以我试着列出所有这些相关的宝石。我发现我的sshkit比他的高

因此,我将我的sshkit降级到1.7.1


然后它就会工作。

请使用
--trace重新运行,并向我们显示完整的stacktrace。并共享您的
Capfile
Gemfile
please@mudasobwa我调整了问题:)谢谢你的回答answer@maximf我调整了问题:)谢谢;)能否升级到最新的Capistrano、sshkit和Capistrano rails并重试?我不确定这是否是一个问题,但这将使调试更容易。谢谢!这就解决了!我知道我晚了一年,但这次升级(3.2.1到3.4.0)也解决了我的问题!非常感谢。我认为这会有一段时间的相关性,因为有很多遗留项目
#
# Capistrano 3 deployment configuration
#
#   http://www.capistranorb.com/
#   https://semaphoreapp.com/blog/2013/11/26/capistrano-3-upgrade-guide.html

# defaults that can be updated from the environment
set :branch,              ENV["REVISION"] || ENV["BRANCH_NAME"] || "master"

# you probably want to change these
set :application,         'foodsoft'            # application name (whatever you like)
set :domain,              'biomio-giessen.de' # host
set :user,                'deploy'              # ssh deploy user
set :keep_releases,       10
set :repo_url,            'git://github.com/foodcoops/foodsoft.git'
set :deploy_to,            "/www/apps/#{fetch :application}-#{fetch :stage}"

# more settings which are probably ok
set :log_level,           :info
set :linked_files,        %w{config/database.yml config/app_config.yml config/initializers/secret_token.rb config/initializers/session_store.rb}
set :linked_dirs,         %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# assuming one server for everything, with one user for deploy and one for resque
server fetch(:domain), user: fetch(:user), roles: [:web, :app, :resque, :db]

# if you use RVM, uncomment the line in Capfile, and optionally uncomment rvm settings
# set :rvm_ruby_string,     :local

# task hooks
namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # tell mod_passenger to reload the application
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :restart, 'resque:restart'

  after :finishing, 'deploy:cleanup'

  # see lib/capistrano/tasks/plugins.cap
  #before 'bundler:install', 'enable_plugins:auto'

end