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

Psych & Ruby 3 incompatibility #789

Closed
VictorMotogna opened this issue May 23, 2022 · 0 comments · Fixed by #859
Closed

Psych & Ruby 3 incompatibility #789

VictorMotogna opened this issue May 23, 2022 · 0 comments · Fixed by #859

Comments

@VictorMotogna
Copy link

I am upgrading a Rails project to Ruby 3.1.2, from 2.6.6. I initially ran into this problem, but fixed it with adding gem 'psych', '< 4' into the Gemfile. I should note that an answer there mentioned downgrading to Ruby 3.0.3, but that does not fix my issue.

After adding that, the project worked fine regarding Psych. Unfortunately, when trying to commit/push, the overcommit hook returns this error:

/.rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/runtime.rb:309:in 'check_for_activated_spec!': You have already activated psych 4.0.4, but your Gemfile requires psych 3.3.2. Prepending 'bundle exec' to your command may solve this. (Gem::LoadError)

I also tried changing overcommit's version and got this error: Since "psych" is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports psych as a default gem.

Versions

ruby 3.1.2p20
psych (3.3.2)
overcommit (0.58.0)
xjunior added a commit to xjunior/overcommit that referenced this issue Jan 23, 2025
sds pushed a commit that referenced this issue Jan 27, 2025
Fixes #789

`psych` is no longer a default gem, but current and old ruby still ships
with it. When we `require 'yaml'`, we activate that gem in whatever
version that is bundled with ruby. Later on, we load bundler, and we
`Bundler.setup`, which will then activate whatever version specified in
the lock file. More often than not, they might not match.

The approach in this PR is to strip the `yaml` dependency completely
from the hook scripts, while retaining the ability to configure the
Gemfile using it.
@sds sds closed this as completed in #859 Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants