首先,我在ubuntu上使用rvm 1.15.8(稳定版)通过wayne开发app rails,我将部署到我的vps。
以下是我的vps上构建rails应用程序的历史记录:
在我的vps上使用用户“user”安装rvm,我试用了this,这里是rvm info
[user@myhost ~]$ rvm info
ruby-1.9.3-p392:
system:
uname: "Linux mydomain.com 2.6.32-358.6.1.el6.i686 #1 SMP Tue Apr 2
3 18:13:20 UTC 2013 i686 i686 i386 GNU/Linux"
system: "centos/6.4/i386"
bash: "/bin/bash => GNU bash, version 4.1.2(1)-release (i386-redhat-l
inux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.19.6 (stable) by Wayne E. Seguin <wayneeseguin@gmail.co
m>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
updated: "16 hours 9 minutes 44 seconds ago"
ruby:
interpreter: "ruby"
version: "1.9.3p392"
date: "2013-02-22"
platform: "i686-linux"
patchlevel: "2013-02-22 revision 39386"
full_version: "ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]"
homes:
gem: "/usr/local/rvm/gems/ruby-1.9.3-p392"
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p392"
binaries:
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby"
irb: "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/irb"
gem: "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/gem"
rake: "/usr/local/rvm/gems/ruby-1.9.3-p392/bin/rake"
environment:
PATH: "/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/r
uby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/r
vm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user/bin"
GEM_HOME: "/usr/local/rvm/gems/ruby-1.9.3-p392"
GEM_PATH: "/usr/local/rvm/gems/ruby-1.9.3-p392:/usr/local/rvm/gems/ruby-
1.9.3-p392@global"
MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.3-p392"
IRBRC: "/usr/local/rvm/rubies/ruby-1.9.3-p392/.irbrc"
RUBYOPT: ""
gemset: ""
我在我的vps上使用kloxo控制面板,目录root位于/home/admin/myapp/public
我将部署,这里是deploy.rb
require "bundler/capistrano" require "rvm/capistrano" server "xxx.xxx.xxx.xxx", :web, :app, :db, primary: true set :bundle_cmd, "/usr/local/rvm/gems/ruby-1.9.3-p392@global" set :bundle_dir, "/usr/local/rvm/gems/ruby-1.9.3-p392" set :rvm_ruby_string, EVN['GEM_HOME'].gsub(/.*\?/,"") set :rvm_type, :user set :default_environment, { 'PATH' => "/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/r uby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/r vm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user/bin", 'RUBY_VERSION' => 'ruby 1.9.3', 'GEM_HOME' => "/usr/local/rvm/gems/ruby-1.9.3-p392", 'GEM_PATH' => "/usr/local/rvm/gems/ruby-1.9.3-p392:/usr/local/rvm/gems/ruby- 1.9.3-p392@global", 'BUNDLE_PATH' => "/usr/local/rvm/gems/ruby-1.9.3-p392" } set :application, "myapp" set :user, "user" set :deploy_to, "/home/admin/#{application}" set :deploy_via, :remote_cache set :use_sudo, false set :scm, "git" set :repository, "git@github.com:myuser/#{application}.git" set :branch, "master" default_run_options[:pty] = true ssh_options[:forward_agent] = true after "deploy", "deploy:cleanup" # keep only the
我尝试运行cap deploy:setup
,我收到了错误
executing "mkdir -p /home/admin/myapp /home/admin/myapp/release /home/admin/myapp/shared /home/admin/myapp/shared/system /home/admin/myapp/shared/log /home/admin/myapp/shared/pids"
servers: ["xxx.xxx.xxx.xx"]
Password:
[xxx.xxx.xxx.xxx] executing command
** [out :: xxx.xxx.xxx.xxx] env : /home/user/.rvm/bin/rvm-shell: No such file or directory
failed : "env PATH: .........etc"
你能帮我纠正一下我的步骤和代码吗?
答案 0 :(得分:0)
尝试将rvm-capistrano的require移动到文件末尾。我最近也这样做了。
当你使用rvm时,你不需要设置bundle cmd,bundle_dir或default_environment(除非你为其他东西做这件事吗?
看起来您似乎正在尝试检测本地用于部署的ruby版本,为此set :rvm_ruby_string, :local
就是您所需要的
答案 1 :(得分:0)
对我来说,
set :rvm_ruby_string, :local #doesn't work
没用。我不得不使用显式版本:
set :rvm_ruby_string, "2.1.2" #works