Allow Capistrano::NetStorage to deploy different Ruby versions #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
When we are updating Ruby version of a Repository by
.ruby-version
ofrbenv
, we have found out thatbundle
command does not work as expected.This occurs when there is a difference of Ruby version between deploying application version and deployed application version.
Let's assume we have a repository with Ruby 3.0.6, and we are deploying an old version of the same repository with Ruby 2.6.2. In this case, the current
bundle
is being run from Ruby 3.0.6, which is not an intended behavior.How we have fixed
Fixing this issue is divided into 2 phase.
RBENV_VERSION
andRBENV_DIR
RBENV_VERSION
is cleared..ruby-version
,RBENV_DIR
is cleared.rbenv exec
when it worksrbenv exec
whenrbenv version
is successfulOther considerations to this patch
Since
rbenv
and.ruby-version
is a de facto standard of Ruby ecosystem in 2023 and we are using them in production, this patch focuses only onrbenv
.Prepending
rbenv exec
to specific commands in Capistrano is usually achieved bycapistrano-rbenv
. However, this only affectsSSHKit.config.command_map
, which is effective only on remote command execution. Considering the local execution flow ofcapistrano-bundle_rsync
, I thought it is rational to directly prependingrbenv exec
here.https://github.com/capistrano/rbenv#usage
Checklist