gpt4 book ai didi

ruby-on-rails - bundle : Permission denied

转载 作者:数据小太阳 更新时间:2023-10-29 07:06:07 28 4
gpt4 key购买 nike

我将服务器更新为 ruby​​ 2.1.1,并使用 Capistrano 部署到我的服务器。但是,当我部署时,我收到各种错误。每次我玩我的部署代码时都会改变。以下是我当前遇到的问题。

更新/新问题

重新安装 rvm 和 ruby​​ 后,我在部署时遇到了不同的问题。这是我当前的 deploy.rb 文件。

require "bundler/capistrano"   
require "rvm/capistrano"

set :rvm_type, :system
set :rvm_ruby_string, "ruby-2.1.1"

require 'bundler/capistrano'

# Capistrano
set :default_environment, {
'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ruby-2.1.1@global/bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1",
'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ruby-2.1.1@global",
"MY_RUBY_HOME" => "/usr/local/rvm/rubies/ruby-2.1.1",
"BUNDLE_PATH" => "/usr/local/rvm/rubies/ruby-2.1.1/bin/bundle"

}

set :rails_env, "production"
set :branch, "master"

set :app_server, "ip"
set :db_server, "ip"
server app_server, :app, :web
role :db, db_server, :primary => true

set :keep_releases, 1

set :deploy_to, "/var/www"
set :user, :jason
set :password, "cool password here"

set :repository, "git url" # Your clone URL
set :scm, "git"
set :scm_username, "jason"
set :scm_passphrase, "password"

set :use_sudo, false

default_run_options[:pty] = true

set :ssh_options, {:forward_agent => true}

after 'deploy:restart', 'deploy:cleanup'
after 'deploy:update', 'deploy:create_symlink'

运行部署时我遇到了这个错误:

Error: RVM was unable to use 'default'

我假设这是指 rvm_ruby_string 我没有设置。除此之外,我不知道为什么会产生错误。也许 RVM 无法识别服务器上的 ruby​​?

旧问题

我将服务器更新为 ruby​​ 2.1.1。通过 SSH 连接到服务器,我运行 gem env 获取相关的 default environment 特性。

set :default_environment, {
'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ruby-2.1.1@global/bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1",
'RUBY_VERSION' => 'ruby 2.1.1',
'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ruby-2.1.1@global"
}

但是,当我运行 cap deploy 时,我得到了这个:

  * executing "cd /var/www/releases/20140517014048 && bundle install --gemfile /var/www/releases/20140517014048/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test"
servers: ["ip address"]
["ip address"] executing command
** [out :: ipaddress] sh: 1: bundle: Permission denied

我假设它是我的默认环境。因为这是我在 deploy.rb 文件中唯一更改的内容。 `

最佳答案

  1. You'll want to use default_env to define the SHELL vars
  2. Permission Denied means your SSH user does not have permission to use SSH, RVM or Bundler

卡皮斯特拉诺

第一步是确保 default_environment 正常工作。虽然我找不到 direct reference (search for default_env on this page) ,我读到 default_environment 已被 default_env 取代

如果你使用的是 capistrano 3.0+,你应该像这样使用 default_env:

set :default_env, {
'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ruby-2.1.1@global/bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1",
'RUBY_VERSION' => 'ruby 2.1.1',
'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ruby-2.1.1@global"
}

许可

其次,您的 ssh 用户将没有正确的权限来访问 Ruby/bundler 的安装

正如您在评论中所讨论的,这可能是由于 rubyrvm 未安装在您的系统上,或者没有访问权限造成的。

@chloe 有一个很棒的建议 - 为了解决这个问题,我会使用 root 用户登录(进行测试),以确保您可以实际访问bundlerrvm 数据正确

关于ruby-on-rails - bundle : Permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23706826/

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