Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Capistrano::NetStorage to deploy different Ruby versions #27

Closed
wants to merge 1 commit into from

Conversation

aeroastro
Copy link
Contributor

Background

When we are updating Ruby version of a Repository by .ruby-version of rbenv, we have found out that bundle 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.

  • Clearing environment variables of RBENV_VERSION and RBENV_DIR
  • Prepend rbenv exec when it works
    • For backward compatibility, we only append rbenv exec when rbenv version is successful

Other 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 on rbenv.

Prepending rbenv exec to specific commands in Capistrano is usually achieved by capistrano-rbenv. However, this only affects SSHKit.config.command_map, which is effective only on remote command execution. Considering the local execution flow of capistrano-bundle_rsync, I thought it is rational to directly prepending rbenv exec here.
https://github.com/capistrano/rbenv#usage

Checklist

@aeroastro
Copy link
Contributor Author

The branch name is not so good. I will remake Pull Requests.

@aeroastro aeroastro closed this Aug 7, 2023
@aeroastro aeroastro deleted the feature/document-consistency branch August 7, 2023 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant