Q:

Rails Capistrano deploy with and without rbenv

Old rails project on production has no rbenv, uses ruby installed manually. I've set a staging for it WITH rbenv, added capistrano-rbenv gem and capistrano staging deploy config params. Now it keeps searching for rbenv folders even while deploying to production and it of course fails.
Is there a way I can configure capistrano not to use rbenv while deploying to production?
Here are my current config files:
deploy.rb
# config valid only for Capistrano 3.1
lock '3.4.1'

# Git repo URL
set :repo_url, '...'

# Default value for :pty is false
set :pty, true

# Don't use sudo
set :use_sudo, false

# Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/secrets.yml}

# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

namespace :deploy do
 ...
end

deploy/staging.rb
# Application name
set :application, '...'

# Use a specific tmp dir
set :tmp_dir, "/home/user_name/apps/#{fetch(:application)}/tmp"

# Deploy to this location
set :deploy_to, "/home/user_name/apps/#{fetch(:application)}"

# Branch to deploy from
set :branch, 'staging'

# rbenv stuff
set :rbenv_type, :user
set :rbenv_ruby, '2.2.5'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

# General
server '...', user: 'user_name', roles: %w{app web db}

deploy/production.rb
# Application name
set :application, 'production'

# Use a specific tmp dir
set :tmp_dir, "/home/user_name/apps/#{fetch(:application)}/tmp"

# Deploy to this location
set :deploy_to, "/home/user_name/apps/#{fetch(:application)}"

# Branch to deploy from
set :branch, 'master'

# General
server '...', user: 'user_name', roles: %w{app web db}

production ruby
production@server_name:~$ ruby -v
ruby 2.2.10p489 (2018-03-28 revision 63023) [x86_64-linux]

production@server_name:~$ which ruby
/usr/bin/ruby

A:

To avoid the gem getting loaded in production environment,
Try moving the capistrano-rbenv to staging group in Gemfile if you don't already have it there. 
Also, you must have an entry in Capfile
require 'capistrano/rbenv'

You need to make it conditional so that you don't end up requiring it in production environment
There is an old issue which solves a similar issue, please take a look
https://github.com/capistrano/rbenv/issues/31
Add this in Capfile
if Rake.application.top_level_tasks.first == "staging"
  require 'capistrano/rbenv'
end

