【问题标题】:rails 4 rbenv bundle not found找不到rails 4 rbenv包
【发布时间】:2015-12-26 23:23:04
【问题描述】:

我正在尝试将带有 Ruby 2.2.3 和 Capistrano 3 的 Rails 4.2.4 应用程序部署到 VPS 服务器。我之前用 RVM 做过几次,我的其他应用程序没有问题,但现在我在新机器和服务器上使用 rbenv,我得到如下堆栈跟踪:

DEBUG [a326a4c8] Command: cd /home/deploy/myapp/releases/20151226231303 && /usr/bin/env bundle install --path /home/deploy/myapp/shared/bundle --without development test --deployment --quiet
DEBUG [a326a4c8]    /usr/bin/env: 
DEBUG [a326a4c8]    bundle: No such file or directory
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@youspoof.us: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory

SSHKit::Command::Failed: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory

Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing as deploy@youspoof.us: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory

我作为部署用户在我的服务器上安装了 rbenv 和 ruby​​ 2.2.3 global。还做了一个gem install bundler 并安装了它。我从服务器运行bundle -v 并获得Bundler version 1.11.2,所以我知道捆绑器已安装。我知道 ruby​​ 正在使用 rbenv shim ruby​​,因为当我发出 which ruby 时,我得到了 /home/deploy/.rbenv/shims/ruby

我不确定这里到底发生了什么,因为我使用 rbenv 已经有一段时间了。如果有帮助,这是我的 capfile 和 deploy.rb。

Capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'
set :rbenv_type, :user
set :rbenv_ruby, '2.2.3p173'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

deploy.rb

# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'myapp'
set :repo_url, 'git@github.com:shakycode/myapp.git'

set :deploy_to, '/home/deploy/myapp'

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

namespace :deploy do

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

  after :publishing, 'deploy:restart'
  after :finishing, 'deploy:cleanup'
end

我可能遗漏了一些东西,但每次我尝试运行 cap production deploy 时都会收到关于 /usr/bin/env bundle no such file or directory 的调试错误。

非常感谢任何帮助。与此同时,我会继续搜索。

【问题讨论】:

    标签: ruby-on-rails-4 bundler capistrano3


    【解决方案1】:

    我自己能做到这一点

    capfile

    require 'capistrano/rbenv'
    

    部署.rb

    set :rbenv_path, '/home/deploy/.rbenv/'
    

    【讨论】:

    • 如果需要,可以使用set :rbenv_type, :user,而不是设置rbenv路径。
    • @will_in_wi 谢谢我实际上把它们都设置好了。我应该删除路径并留下 rbenv_type 吗?
    猜你喜欢
    • 2018-09-12
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    • 2017-07-14
    • 1970-01-01
    相关资源
    最近更新 更多