Skip to content

Update ruby to 3.1.1#9449

Merged
ahukkanen merged 13 commits intodecidim:developfrom
CodiTramuntana:chore/upgrade_to_ruby_3_1_1
Jul 27, 2022
Merged

Update ruby to 3.1.1#9449
ahukkanen merged 13 commits intodecidim:developfrom
CodiTramuntana:chore/upgrade_to_ruby_3_1_1

Conversation

@tramuntanal
Copy link
Copy Markdown
Contributor

@tramuntanal tramuntanal commented Jun 17, 2022

🎩 What? Why?

The develop version of Decidim runs on Ruby 3.0.2, but that Ruby version does not compile on Ubuntu 22.04 LTS (see https://bugs.ruby-lang.org/issues/18658). Ruby 3.1.1 instead compiles on Ubuntu 22.
As Ubuntu is one, as far as I know, of the popular choices to install Decidim, and version 22 is starting to be the default in many datacenters this PR tries to address the mentioned problem.
Anyway, using the latest Ruby version is always desirable.

This is the stacktrace:

oliver@oliver-XPS-13-9305:~$ rbenv install 3.0.2
Downloading ruby-3.0.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.gz
Installing ruby-3.0.2...

BUILD FAILED (Ubuntu 22.04 using ruby-build 20220426-3-g1038c07)

Inspect or clean up the working tree at /tmp/ruby-build.20220617104403.117644.RXzpC0
Results logged to /tmp/ruby-build.20220617104403.117644.log

Last 10 log lines:
make[2]: Leaving directory '/tmp/ruby-build.20220617104403.117644.RXzpC0/ruby-3.0.2/ext/json/generator'
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
linking shared-object socket.so
make[2]: Leaving directory '/tmp/ruby-build.20220617104403.117644.RXzpC0/ruby-3.0.2/ext/socket'
linking shared-object ripper.so
make[2]: Leaving directory '/tmp/ruby-build.20220617104403.117644.RXzpC0/ruby-3.0.2/ext/ripper'
make[1]: Leaving directory '/tmp/ruby-build.20220617104403.117644.RXzpC0/ruby-3.0.2'
make: *** [uncommon.mk:300: build-ext] Error 2

📌 Related Issues

Link your PR to an issue

Testing

  • Run the test suite (GithubActions)
  • Create a development_app
  • Run the development_app application

📋 Checklist

🚨 Please review the guidelines for contributing to this repository.

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

📷 Screenshots

No screenshots

♥️ Thank you!

@andreslucena
Copy link
Copy Markdown
Member

Just a couple of questions and comments:

The current 0.26.x and develop versions of Decidim run on Ruby 3.0.2

release/0.26-stable branch is on Ruby 2.7.5: https://github.com/decidim/decidim/blob/release/0.26-stable/.ruby-version
I just rechecked it, and v0.26.0, v0.26.1 and v0.26.2 are also in Ruby 2.7.5, from #8629

that Ruby version does not compile on Ubuntu 22 OS

That's weird. Do you have a link/traceback or anything else to investigate it further?

The development_app is working on my machine, I have Pop!_OS 22.04 LTS, that's based on Ubuntu 22.04 LTS. I can compile it well with asdf-vm.

nightly.decidim.org is on v0.27.0.dev (with Ruby 3.0.2) on Ubuntu 20.04.4 LTS with rbenv.

Which ruby version manager are you using?

@tramuntanal
Copy link
Copy Markdown
Contributor Author

tramuntanal commented Jun 17, 2022

You are totally right about the Ruby version on Decidim v0.26.x series, they are all using Ruby 2.7. I wrote it without checking :(

That's weird. Do you have a link/traceback or anything else to investigate it further?

This is the bug: https://bugs.ruby-lang.org/issues/18658
I'll update the description with the stacktrace.

The development_app is working on my machine, I have Pop!_OS 22.04 LTS, that's based on Ubuntu 22.04 LTS. I can compile it well with asdf-vm.

No a Pop!OS user, maybe it uses a different openssl version?

nightly.decidim.org is on v0.27.0.dev (with Ruby 3.0.2) on Ubuntu 20.04.4 LTS with rbenv.

Yes 3.0.2 compiles well with Ubuntu 20.

Which ruby version manager are you using?

I use rbenv but I don't think its related.

I was exploring the difficulty to upgrade to Ruby 3.1.1 with this PR. I wont be as easy as it was when upgrading the Ruby 2.x series but I can take some time each week to work on it.

@andreslucena
Copy link
Copy Markdown
Member

No a Pop!OS user, maybe it uses a different openssl version?

Yes, it is:

$ dpkg -l |grep libssl-dev
ii  libssl-dev:amd64                          3.0.2-0ubuntu1.2                                                  amd64        Secure Sockets Layer toolkit - development files

And on Ubuntu 20.04, with an older libssl-dev but it seems like it's still working:

$ dpkg -l |grep libssl-dev
ii  libssl-dev:amd64                  1.1.1f-1ubuntu2.13                amd64        Secure Sockets Layer toolkit - development files
$ rbenv install 3.0.1 
Downloading ruby-3.0.1.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.1.tar.gz
Installing ruby-3.0.1...
Installed ruby-3.0.1 to /home/ruby-data/.rbenv/versions/3.0.1

$ rbenv install 3.0.2 # Just to be extra sure 
rbenv: /home/ruby-data/.rbenv/versions/3.0.2 already exists
continue with installation? (y/N) y
Downloading ruby-3.0.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.gz
Installing ruby-3.0.2...
Installed ruby-3.0.2 to /home/ruby-data/.rbenv/versions/3.0.2

I use rbenv but I don't think its related.

Yes, I agree.

I was exploring the difficulty to upgrade to Ruby 3.1.1 with this PR. I wont be as easy as it was when upgrading the Ruby 2.x series but I can take some time each week to work on it.

Mind that there are some unrelated specs failing (expected no Exception, got #<ActiveModel::UnknownAttributeError: unknown attribute 'description' for Decidim::Elections::Question.). This will be fixed when #9448 is merged.

Also, thanks for taking care of this one! I agree that using the latest versions of Ruby/Rails is desirable

@tramuntanal tramuntanal force-pushed the chore/upgrade_to_ruby_3_1_1 branch from 6692f55 to abe49ee Compare June 17, 2022 10:24
@tramuntanal tramuntanal force-pushed the chore/upgrade_to_ruby_3_1_1 branch 4 times, most recently from f861855 to 38dc2d5 Compare June 28, 2022 16:51
@andreslucena andreslucena changed the title Upgrade Ruby to 3.1.1 Update ruby to 3.1.1 Jun 29, 2022
@andreslucena
Copy link
Copy Markdown
Member

I was bitten by this one too 😅

I had a problem with bundler, tried to reinstall ruby 3 and couldn't because of this error. My theory is that I installed ruby 3.0.2 when I had Pop OS 21.10 (Ubuntu 21.10), and then updated my system.

The workaround that I found is:

  1. Compile locally openssl1.1 following this guide https://help.dreamhost.com/hc/en-us/articles/360001435926-Installing-OpenSSL-locally-under-your-username
  2. Install ruby 3 with tthe env var: RUBY_CONFIGURE_OPTS="--with-openssl-dir=/home/username/openssl" asdf install ruby 3.0.2

/opt/hostedtoolcache/Ruby/3.1.1/x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:27:in `require': cannot load such file -- net/pop (LoadError)
@tramuntanal tramuntanal force-pushed the chore/upgrade_to_ruby_3_1_1 branch from 38dc2d5 to c877f07 Compare June 29, 2022 10:37
@tramuntanal
Copy link
Copy Markdown
Contributor Author

tramuntanal commented Jun 29, 2022

I had a problem with bundler, tried to reinstall ruby 3 and couldn't because of this error. My theory is that I installed ruby 3.0.2 when I had Pop OS 21.10 (Ubuntu 21.10), and then updated my system.

Ah @andreslucena that will explain why you got it under Ubuntu 22

I saw that workaround, anyway, thanks for the link to the guide, it may be useful in the meantime.

@tramuntanal
Copy link
Copy Markdown
Contributor Author

@ahukkanen
The PR is nearly ready but there is a strange problem with Rubocop: https://github.com/decidim/decidim/runs/7110278822?check_suite_focus=true

It raises an error from a line that does not exist in the file where Rubocop complains:

decidim-blogs/spec/events/decidim/blogs/create_post_event_spec.rb:14:54: C: [Correctable] Style/HashSyntax: Omit the hash value.
    let(:assembly) { create(:assembly, organization: organization, title: { en: "It's a test" }) }
                                                     ^^^^^^^^^^^^

there is no line with let(:assembly)... inside that file. I even have searched for that line inside the whole project and couldn't find it.
Running Rubocop locally doesn't find any problem..
Have you been in this situation before?

@tramuntanal
Copy link
Copy Markdown
Contributor Author

I've merged develop and it turns out that the "phantom" line was from there like if the linter was running agains develop instead of the code in this branch... strange things.. 😅
So after merging I have been able to apply Rubocop's autocorrection, let's see if tests succeed now.

@tramuntanal tramuntanal reopened this Jun 29, 2022
@tramuntanal tramuntanal force-pushed the chore/upgrade_to_ruby_3_1_1 branch from 0eb8f3a to 92fb1ae Compare June 29, 2022 14:27
@tramuntanal
Copy link
Copy Markdown
Contributor Author

@ahukkanen the two failing tests are because of a temporal GitHub malfunction. I'll push -f again to see if they succeed.

@tramuntanal tramuntanal force-pushed the chore/upgrade_to_ruby_3_1_1 branch from 92fb1ae to 7afad99 Compare June 29, 2022 15:19
@tramuntanal tramuntanal marked this pull request as ready for review June 30, 2022 05:37
@andreslucena andreslucena added module: core target: developer-experience dependencies Pull requests that update a dependency file or issues that talk about updating dependencies labels Jun 30, 2022
Copy link
Copy Markdown
Contributor

@ahukkanen ahukkanen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @tramuntanal !

Few things before merging:

  1. Could you please merge with develop since there are some merge conflicts
  2. After the merge, could you fix the newly introduced rubocop linter issues from other PRs (I believe most of them should be resolved with the auto correct)

I've checked through the changes and have not noticed anything problematic. I've also tested locally and everything I tested worked fine after these changes.

Only thing I noticed was this issue with bundler but it's not related directly to these changes:
ruby/rubygems#5234

So the problem is every time running bundler, I get this deprecation warning:

Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.

But that can be quite easily fixed locally by running this within the instance (as suggested in the related issue):

$ bundle update --bundler

@tramuntanal
Copy link
Copy Markdown
Contributor Author

@ahukkanen I've merged develop and now the budgets test suite fails because it's also failing in develop. I'll merge again when develop is green.

@ahukkanen
Copy link
Copy Markdown
Contributor

I've merged develop and now the budgets test suite fails because it's also failing in develop. I'll merge again when develop is green.

Thanks @tramuntanal! Don't worry about the test, it's a flaky one (or the comments functionality is a bit flaky with machine users). I'll just re-run it and merge once it passes.

#9614 should fix that particular issue with the comments.

@ahukkanen ahukkanen merged commit 2d0ec19 into decidim:develop Jul 27, 2022
@tramuntanal tramuntanal deleted the chore/upgrade_to_ruby_3_1_1 branch July 27, 2022 14:28
eliegaboriau pushed a commit to eliegaboriau/decidim that referenced this pull request Oct 25, 2022
* Upgrade Ruby to 3.1.1

* Fix LoadError when loading net/smtp

* Downgrande psych to <4 until all libraries adapt to new defaults

Aliases are not suported by default on psych 4

* Apply Rubocop cops for Ruby 3.1

* Upgade Brakeman to v5.2.3

As v5.2.2 failed when executing with Ruby 3.1.1

* Add net-smtp as a direct decidim-generators dependecy

* Add dependency to net-* gems to avoid crash during tests

/opt/hostedtoolcache/Ruby/3.1.1/x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:27:in `require': cannot load such file -- net/pop (LoadError)

* Rubocopify

* Rubocopify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file or issues that talk about updating dependencies module: core target: developer-experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants