gpt4 book ai didi

ruby-on-rails-4 - Capistrano 3 使用未知的 bundler 和 stderr 进行自定义任务

转载 作者:行者123 更新时间:2023-12-04 07:04:25 25 4
gpt4 key购买 nike

我的文件:

# 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/tree/master/assets
# https://github.com/capistrano/rails/tree/master/migrations
#
require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'sidekiq/capistrano'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

部署.rb:
set :application, 'myapp'
set :user, 'deployer'
set :repo_url, "git@bitbucket.org:citicom/#{fetch :application}.git"

# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

set :deploy_to, "/home/#{fetch :user}/apps/#{fetch :application}"
# set :scm, :git

set :format, :pretty
# set :log_level, :debug
set :pty, true

set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets tmp/sock vendor/bundle public/system}

# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :keep_releases, 3

# for RoR 4
set :default_env, { rvm_bin_path: '~/.rvm/bin' }
set :bundle_gemfile, -> { release_path.join('Gemfile') }
set :bundle_dir, -> { shared_path.join('bundle') }
set :bundle_flags, ''
set :bundle_without, %w{test development}.join(' ')
set :bundle_binstubs, -> { shared_path.join('bin') }
set :bundle_roles, :all
namespace :deploy do

desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
run "cd #{current_path} && /etc/init.d/unicorn_#{fetch :application} restart"
# execute :touch, release_path.join('tmp/restart.txt')
end
end

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end

after :finishing, 'deploy:cleanup'

end

错误:
git:(master) ✗ cap production bundler:install
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /usr/local/share/npm/lib/node_modules in PATH, mode 040777
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:284: warning: Insecure world writable dir /usr/local/share/npm/lib/node_modules in PATH, mode 040777
DEBUG [55d61c51] Running if test ! -d /home/deployer/apps/myapp/current; then echo "Directory does not exist '/home/deployer/apps/myapp/current'" 1>&2; false; fi on 134.19.136.197
DEBUG [55d61c51] Command: if test ! -d /home/deployer/apps/myapp/current; then echo "Directory does not exist '/home/deployer/apps/myapp/current'" 1>&2; false; fi
DEBUG [55d61c51] Finished in 0.895 seconds with exit status 0 (successful).
INFO [166054bd] Running /bin/myapp_bundle --gemfile /home/deployer/apps/myapp/current/Gemfile --path /home/deployer/apps/myapp/shared/bundle --binstubs /home/deployer/apps/myapp/shared/bin --without test development on 134.19.136.197
DEBUG [166054bd] Command: cd /home/deployer/apps/myapp/current && ( RVM_BIN_PATH=~/.rvm/bin /bin/myapp_bundle --gemfile /home/deployer/apps/myapp/current/Gemfile --path /home/deployer/apps/myapp/shared/bundle --binstubs /home/deployer/apps/myapp/shared/bin --without test development )
DEBUG [166054bd] zsh:1: no such file or directory: /bin/myapp_bundle
cap aborted!
bundle stdout: Nothing written
bundle stderr: Nothing written
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:20:in `block (4 levels) in <top (required)>'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/abstract.rb:81:in `within'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:19:in `block (3 levels) in <top (required)>'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `run'
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => bundler:install
(See full trace by running task with --trace)

我使用了 capistrano 2,但是当我将 capistrano 更新到版本 3 时,我的两个 ROR 4 应用程序出现此错误。为什么 capistrano 使用“/bin/myapp_bundle”?

- - - - - - 更新 - - - - - -

@mpapis 帮我解决这个问题:
cap productiom rvm:hook deploy

它正在工作,但是当我使用 mpapis 帮助创建自定义任务时:
namespace :whenever do
desc "Update application's crontab entries using Whenever"
task :update_crontab do
on roles(:app) do
execute "cd /home/deployer/apps/fxfinvis/current/ && bundle exec whenever -w RAILS_ENV=#{fetch :rails_env}"
end
end
before :update_crontab, 'rvm:hook'
end
before "deploy:finishing", "whenever:update_crontab"
# If anything goes wrong, undo.
after "deploy:finishing_rollback", "whenever:update_crontab"

我有同样的错误:
cap production whenever:update_crontab
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /usr/local/share/npm/lib/node_modules in PATH, mode 040777
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:284: warning: Insecure world writable dir /usr/local/share/npm/lib/node_modules in PATH, mode 040777
INFO [1372d0e2] Running cd /home/deployer/apps/fxfinvis/current/ && bundle exec whenever -w RAILS_ENV=production on 134.19.136.197
DEBUG [1372d0e2] Command: cd /home/deployer/apps/fxfinvis/current/ && bundle exec whenever -w RAILS_ENV=production
cap aborted!
cd /home/deployer/apps/fxfinvis/current/ && bundle exec whenever -w RAILS_ENV=production stdout: Nothing written
cd /home/deployer/apps/fxfinvis/current/ && bundle exec whenever -w RAILS_ENV=production stderr: Nothing written
/Users/quatermain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/command.rb:94:in `exit_status='
....

最佳答案

你需要运行:

cap production rvm:hook bundler:install

还要更改 whenever:update_cron任务:
within current_path do
execute :bundle, "exec whenever -w RAILS_ENV=#{fetch :rails_env}"
end

我不太确定 :current_path - 但应该工作。

关于ruby-on-rails-4 - Capistrano 3 使用未知的 bundler 和 stderr 进行自定义任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19640740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com