LoadError:无法加载此类文件 - rvm / capistrano

时间:2016-11-30 14:52:01

标签: ruby-on-rails ruby sinatra

我想部署sinatra项目。

运行命令cap production deploy

错误:

cap aborted!
LoadError: cannot load such file -- rvm/capistrano
config/deploy.rb:1:in `require'
config/deploy.rb:1:in `<top (required)>'
/home/user/.rbenv/versions/2.3.1/bin/cap:23:in `load'
/home/user/.rbenv/versions/2.3.1/bin/cap:23:in `<top (required)>'
/home/user/.rbenv/versions/2.3.1/bin/bundle:23:in `load'
/home/user/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>'

#gemfile
source 'http://rubygems.org'

gem "rake"
gem "sinatra"
gem "sinatra-activerecord"
gem "sinatra-flash"
gem "pg"
gem "bcrypt"
gem "pry"
gem "pony"
gem "capistrano", '~> 3.1.0'
gem "capistrano-bundler", '~> 1.1.2'
gem "capistrano-rvm", github: "capistrano/rvm"

设置capistrano Capgile文件

Capfile

# Load DSL and set up stages
require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'

# If you are using rvm add these lines:
require 'capistrano/rvm'
set :rvm_type, :user
set :rvm_ruby_version, '2.3.1-p112'
#Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

在部署文件中,我为rvm

添加了以下内容
#config/deploy.rb
#RVM and bundler settings
set :bundle_cmd, "/home/deploy/.rvm/gems/ruby-2.3.1-p112@global/bin/bundle"
set :bundle_dir, "/home/deploy/.rvm/gems/ruby-2.3.1-p112/gems"
set :rvm_ruby_string, :local
set :rack_env, :production

我不明白为什么这个错误,也许是因为第一次在本地我使用rbenv来安装ruby和bundle install gems。但是在安装了rvm之后,在目录项目中使用命令rvm use 2.3.1.

选择正确的版本ruby
ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux] 

如何解决这个问题?谢谢你提前。

0 个答案:

没有答案