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

[#1][Backend] Setup project #24

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

captainnimble
Copy link
Owner

[Backend] Setup project

What happened 👀

To ensure that everything works properly after setting up the project and using the codebase from rails-template on different Ruby versions, Rails versions, and Node versions

  • Changed gem psych version from < 4.0 to 3.3.4

Insight 📝

From this StackOverflow answer, mention is made of a major change in Ruby 3.1 with Psych 4.0 that is incompatible with Ruby 3.0.

For Psych version 4.0.0 or above working with rails-template, there will be an error about saf_load (see picture below).

Screenshot 2566-04-17 at 15 03 38

Proof Of Work 📹

Set gem psych to version below 4.0.0

Screenshot 2566-04-17 at 15 11 05

Running the server locally works properly.

Screenshot 2566-04-17 at 09 52 37

Screenshot 2566-04-17 at 10 23 34

Screenshot 2566-04-17 at 11 26 24

@byhbt
Copy link
Collaborator

byhbt commented Apr 18, 2023

hi @captainnimble !
Could you please share which Ruby version you use for this project? 🤔 In the ticket description I see you mention about Ruby 3.1. However, when checking out the source code locally, I see a different version. Ruby 3.2.1 in the .tool-version. I am not sure which version we will use.

At Nimble, for the development dependencies (Ruby, Node, Yarn, Elixir,...) we use asdf for manage the version. So if you intent to use the Ruby v3.1 please update the file .tool-version in this codebase as well.

@captainnimble
Copy link
Owner Author

In this project I use

  • Ruby 3.2.1
  • Rails 7.0.4.3
  • Node 19.8.1

I mention Ruby 3.1 because there is a major change in the gem psych version since Ruby 3.1 that also affects the above version.

@longnd longnd self-requested a review April 19, 2023 10:27
@@ -32,7 +32,8 @@ gem 'jsbundling-rails' # Bundle and transpile JavaScript
gem 'i18n-js', '3.9.0' # A library to provide the I18n translations on the Javascript
# gem 'devise-i18n' # Translations for Devise

gem 'psych', '< 4.0'
# Fix Ruby 3.1 that uses psych version 4.0 and conflicts with rails-template
Copy link
Collaborator

Choose a reason for hiding this comment

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

this comment does not reflect the actual situation. What does it mean by "conflicts with rails-template"?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I tried to create a rails app without a template using Ruby 3.2.1 without downgrading Psych to version 3, and everything worked fine. So, I think there will be some issue that does not work properly in the template.

I might be misunderstanding the root issue in this case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You mean you created the project without using the Rails template, and it worked, right?
It's because Rails template uses the Figaro gem, and it will break if you use Ruby 3.1 and above (which requires psych v4).
So, even if you initialized the project without the Rails template, later, if you add the Figaro gem (or any other gem that depends on psynch but has not been updated to work with psynch v4), it will break again.
Check this issue for more details
nimblehq/rails-templates#316.

So instead of forcing psych < 4.0, I would suggest, either

Copy link
Collaborator

Choose a reason for hiding this comment

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

also to clarify: in the end, did you use the Rails-template to initialize this project?

@@ -32,7 +32,8 @@ gem 'jsbundling-rails' # Bundle and transpile JavaScript
gem 'i18n-js', '3.9.0' # A library to provide the I18n translations on the Javascript
# gem 'devise-i18n' # Translations for Devise

gem 'psych', '< 4.0'
# Fix Ruby 3.1 that uses psych version 4.0 and conflicts with rails-template
gem 'psych', '3.3.4'
Copy link
Collaborator

Choose a reason for hiding this comment

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

the root cause is that Ruby 3.1 comes with psych v4 which is a breaking change. But the gem file here is limiting the version to < 4 already. So why we need to set a specific version 3.3.4?

Copy link
Owner Author

@captainnimble captainnimble Apr 19, 2023

Choose a reason for hiding this comment

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

The line gem 'psych', '< 4.0, is that I accidentally committed it with initial commit. I think it can make some confused, so I set it to a specific version to have a clear understanding, and 3.3.4 is the latest version before 4.0.

@longnd longnd self-requested a review April 20, 2023 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants