Ruby on Rails project ->Error by "cap production deploy" -> ERROR rbenv: 2.2.2 is not installed or not found
Ruby on Rails project ->Error by "cap production deploy" -> ERROR rbenv: 2.2.2 is not installed or not found
我在尝试执行 "cap production deploy"
时遇到错误
ERROR rbenv: 2.2.2 is not installed or not found in /usr/local/rbenv/versions/2.2.2
这是我的 Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :development do
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-rails', '~> 1.1.3'
gem 'capistrano-rbenv' #'~> 2.2.0'
gem 'capistrano-passenger'
end
这是我的 Capfile:
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rbenv'
set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, '2.2.0'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
这是我的 deploy.rb 文件:
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'blank1'
set :repo_url, 'git@bitbucket.org:r2artene/blank1.git'
# setup rvm.
set :rbenv_type, :system
set :rbenv_ruby, '2.2.0'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/deploy/blank1'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
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}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :deploy do
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
end
在本地机器上的命令 "ruby -v" 我得到的结果是:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
在部署服务器上的命令 "ruby -v" 我得到的结果是:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
您遇到 RVM 和 Rbenv 之间的冲突,其中 RVM 仍在某个地方维护对 Ruby 2.2.2 的引用(可能是 bash 配置文件),即使您似乎有只安装了 Ruby 2.2.0。
RVM 和 rbenv 彼此 incompatible,因此您必须决定要使用哪种工具来管理您的库。删除一个或另一个应该可以解决您的问题。
要卸载 RVM,运行 rvm implode
,这将完全卸载 RVM。
要卸载 rbenv,rm
您的 .rbenv
目录并从您的 shell 脚本中删除对 rbenv 的引用。
我在尝试执行 "cap production deploy"
时遇到错误 ERROR rbenv: 2.2.2 is not installed or not found in /usr/local/rbenv/versions/2.2.2
这是我的 Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :development do
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-rails', '~> 1.1.3'
gem 'capistrano-rbenv' #'~> 2.2.0'
gem 'capistrano-passenger'
end
这是我的 Capfile:
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rbenv'
set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, '2.2.0'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
这是我的 deploy.rb 文件:
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'blank1'
set :repo_url, 'git@bitbucket.org:r2artene/blank1.git'
# setup rvm.
set :rbenv_type, :system
set :rbenv_ruby, '2.2.0'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/deploy/blank1'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
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}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :deploy do
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
end
在本地机器上的命令 "ruby -v" 我得到的结果是:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
在部署服务器上的命令 "ruby -v" 我得到的结果是:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
您遇到 RVM 和 Rbenv 之间的冲突,其中 RVM 仍在某个地方维护对 Ruby 2.2.2 的引用(可能是 bash 配置文件),即使您似乎有只安装了 Ruby 2.2.0。
RVM 和 rbenv 彼此 incompatible,因此您必须决定要使用哪种工具来管理您的库。删除一个或另一个应该可以解决您的问题。
要卸载 RVM,运行 rvm implode
,这将完全卸载 RVM。
要卸载 rbenv,rm
您的 .rbenv
目录并从您的 shell 脚本中删除对 rbenv 的引用。