From cf6d9ce75394546930dea9b26447a3acb2b32ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 9 Dec 2024 15:23:40 +0100 Subject: [PATCH] Add Ruby version to Gemfile Since Bundler 2.4.19, including in Ruby 3.2.3, it's possible to define the Ruby version in the Gemfile by indicating which file contains the version [1]. There are at least two practical cases where this is an advantage. First, people using RVM in development will no longer accidentally run the application using the wrong Ruby version (which, before these changes, might happen if they switch to a branch using a different Ruby version and forget to run `rvm use` or exit the current folder and enter it again) because they will get an error when trying to do so. Second, people using services like Heroku no longer need to modify the Gemfile. The disadvantage is that, now, every time we update the Ruby version, we have to remember to run `bundle` so our `Gemfile.lock` gets the new version. [1] https://github.com/rubygems/rubygems/releases/tag/bundler-v2.4.19 --- Dockerfile | 1 + Gemfile | 2 ++ Gemfile.lock | 3 +++ docs/en/installation/deploying-on-heroku.md | 14 +------------- docs/es/installation/deploying-on-heroku.md | 14 +------------- 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6a12659a1..dd6409f63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,7 @@ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz # Use the Gemfiles as Docker cache markers. Always bundle before copying app src. # (the src likely changed and we don't want to invalidate Docker's cache too early) +COPY .ruby-version ./ COPY Gemfile* ./ RUN bundle install diff --git a/Gemfile b/Gemfile index 526497559..8aacd2710 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ source "https://rubygems.org" +ruby file: ".ruby-version" + gem "rails", "7.0.8.7" gem "acts-as-taggable-on", "~> 11.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index 8c7ae0084..6e4374cd3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -804,5 +804,8 @@ DEPENDENCIES wicked_pdf (~> 2.8.1) wkhtmltopdf-binary (~> 0.12.6) +RUBY VERSION + ruby 3.2.5p208 + BUNDLED WITH 2.4.19 diff --git a/docs/en/installation/deploying-on-heroku.md b/docs/en/installation/deploying-on-heroku.md index 1e8db6089..ebd41aee2 100644 --- a/docs/en/installation/deploying-on-heroku.md +++ b/docs/en/installation/deploying-on-heroku.md @@ -58,7 +58,7 @@ This tutorial assumes that you have already managed to clone Consul Democracy on **Remember not to commit the file if you have any sensitive information in it!** -6. To ensure Heroku correctly detects and uses the node.js and ruby versions defined in the project, we need to make the following changes: +6. To ensure Heroku correctly detects and uses the node.js version defined in the project, we need to make the following changes: In package.json, add the node.js version: @@ -74,18 +74,6 @@ This tutorial assumes that you have already managed to clone Consul Democracy on heroku buildpacks:add heroku/nodejs ``` - In _Gemfile_, add the ruby version and run bundle: - - ```Gemfile - ruby file: ".ruby-version" - ``` - - and apply: - - ```bash - heroku buildpacks:set heroku/ruby - ``` - 7. You can now push your app using: ```bash diff --git a/docs/es/installation/deploying-on-heroku.md b/docs/es/installation/deploying-on-heroku.md index 1b8870f7d..89ca34b3e 100644 --- a/docs/es/installation/deploying-on-heroku.md +++ b/docs/es/installation/deploying-on-heroku.md @@ -58,7 +58,7 @@ Este tutorial asume que ya has conseguido clonar Consul Democracy en tu máquina **¡Recuerda no añadir el archivo si tienes información sensible en él!** -6. Para que Heroku detecte y utilice correctamente las versiones de node.js y ruby definidas en el proyecto deberemos añadir los siguientes cambios: +6. Para que Heroku detecte y utilice correctamente la versión de node.js definida en el proyecto deberemos añadir los siguientes cambios: En el _package.json_ añadir la versión de node.js: @@ -74,18 +74,6 @@ Este tutorial asume que ya has conseguido clonar Consul Democracy en tu máquina heroku buildpacks:add heroku/nodejs ``` - En el _Gemfile_ añadir la versión de ruby y ejecutar bundle: - - ```Gemfile - ruby file: ".ruby-version" - ``` - - y aplicar: - - ```bash - heroku buildpacks:set heroku/ruby - ``` - 7. Ahora ya puedes subir tu aplicación utilizando: ```bash