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

Factory Bot 6.4.5: Syntax error with Ruby < 2.7, but the ruby gem requirement is still >= 2.5.0 #1614

Closed
tagliala opened this issue Jan 1, 2024 · 9 comments · Fixed by #1622
Labels

Comments

@tagliala
Copy link

tagliala commented Jan 1, 2024

Description

Factory Bot 6.4.5 contains syntax which is not compatible with Ruby < 2.7, but the ruby gem requirement is still >= 2.5.0

Probably introduced in: #1612

I understand that the intent is to drop Ruby < 3.0, but the requirement in the Gemfile was not updated accordingly.

I would suggest to yank 6.4.5 and release 6.4.6 with the minimum ruby version at 3.0

Ref:

Reproduction Steps

Run the following script:

# frozen_string_literal: true

require 'bundler/inline'

begin
  gemfile(true) do
    source 'https://rubygems.org'

    gem 'factory_bot', '6.4.5'
  end

  puts "\nRuby version: #{RUBY_VERSION}"
rescue Gem::LoadError => e
  puts "\nMissing Dependency:\n#{e.backtrace.first} #{e.message}"
rescue LoadError => e
  puts "\nError:\n#{e.backtrace.first} #{e.message}"
  puts DATA.read
  exit 1
end

require 'factory_bot'

Expected behavior

No raise

Actual behavior

~/.rvm/gems/ruby-2.5.9/gems/factory_bot-6.4.5/lib/factory_bot.rb:25:in `require': ~/.rvm/gems/ruby-2.5.9/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:38: syntax error, unexpected ... (SyntaxError)
...method_missing(method_name, ...)
...                            ^~~
~/.rvm/gems/ruby-2.5.9/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:40: syntax error, unexpected ..., expecting ')'
[email protected](method_name, ...)
...                            ^~~
~/.rvm/gems/ruby-2.5.9/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:42: syntax error, unexpected ..., expecting ')'
...unner.new.send(method_name, ...)
...                            ^~~
~/.rvm/gems/ruby-2.5.9/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:80: syntax error, unexpected end-of-input, expecting keyword_end

System configuration

factory_bot version: 6.4.5
rails version: n/a
ruby version: 2.6.10, 2.5.9

@tagliala tagliala added the bug label Jan 1, 2024
@kyrofa
Copy link

kyrofa commented Jan 2, 2024

Just ran into this myself, it appears due to 36bd065 .

@skunkworker
Copy link

I just ran into this on a JRuby 9.3 project (2.6 parser).

samuelhwilliams added a commit to alphagov/notifications-ruby-client that referenced this issue Jan 4, 2024
thoughtbot/factory_bot#1614

This version introduced a breaking change for Ruby 2 when trying to add
Ruby 3 compatibility (and it didn't note that it was no longer
compatible with ruby 2).

Pinning for now, but should be able to be removed if they jank the
version and release new versions with a requirement on Ruby 3+
samuelhwilliams added a commit to alphagov/notifications-ruby-client that referenced this issue Jan 4, 2024
thoughtbot/factory_bot#1614

This version introduced a breaking change for Ruby 2 when trying to add
Ruby 3 compatibility (and it didn't note that it was no longer
compatible with ruby 2).

Pinning for now, but should be able to be removed if they jank the
version and release new versions with a requirement on Ruby 3+
mshibuya added a commit to railsadminteam/rails_admin that referenced this issue Jan 7, 2024
Earlopain added a commit to Earlopain/factory_bot that referenced this issue Jan 30, 2024
mike-burns pushed a commit that referenced this issue Jan 30, 2024
winebarrel pushed a commit to mixigroup/activerecord-turntable that referenced this issue Mar 15, 2024
@luke-hill
Copy link

Whilst this release is good and has come out. It's now breaking some CI stuff in cucumber-rails.

Did the decision to yank ever get done? I appreciate it's likely low priority but thought I'd ask incase I can avoid doing the work there.

@mike-burns
Copy link
Contributor

If cucumber-rails supports an EOL'ed Ruby version, then it needs to lock its dependencies to the last version that supports that now-unsupported Ruby.

@samuelgaco
Copy link

I am running into this with ruby "2.7.2"

@ryabrody
Copy link

ryabrody commented Apr 5, 2024

My rails engine is on ruby version ruby 2.6.5p114 2.7.2p137 and i got following error:

Failure/Error: require 'factory_bot'

SyntaxError:
  /Users/xxx/.rvm/gems/ruby-2.7.2/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:38: syntax error, unexpected (...
  ...method_missing(method_name, ...)
  ...                            ^~~
  /Users/xxx/.rvm/gems/ruby-2.7.2/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:40: syntax error, unexpected ')'
  ...instance.send(method_name, ...)
  ...                              ^
  /Users/xxx/.rvm/gems/ruby-2.7.2/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:42: syntax error, unexpected ')'
  ...nner.new.send(method_name, ...)
  ...                              ^
  /Users/xxx/.rvm/gems/ruby-2.7.2/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:80: syntax error, unexpected end-of-input, expecting `end'

I also needed to downgrade to

s.add_development_dependency 'factory_bot', '6.4.4'

to get rid of the error.

@luke-hill
Copy link

You can clearly see @ryabrody - You're using ruby 2.7 in your stacktrace. The solution is to use the latest version on 3.0 or 6.4.4

@Glitch-art
Copy link

It works for me:

gem 'factory_bot', '!= 6.4.5'

MaicolBen added a commit to MaicolBen/devise_token_auth that referenced this issue May 14, 2024
Since factory bot doesn't
support it anymore
thoughtbot/factory_bot#1614
MaicolBen added a commit to MaicolBen/devise_token_auth that referenced this issue May 14, 2024
Since factory bot doesn't
support it anymore
thoughtbot/factory_bot#1614
MaicolBen added a commit to MaicolBen/devise_token_auth that referenced this issue May 14, 2024
Since factory bot doesn't
support it anymore
thoughtbot/factory_bot#1614
MaicolBen added a commit to lynndylanhurley/devise_token_auth that referenced this issue May 14, 2024
Since factory bot doesn't
support it anymore
thoughtbot/factory_bot#1614
@DaviGaldeano
Copy link

Ruby version 3.0.3 worked for me

JuanVqz added a commit to JuanVqz/factory_bot_rails that referenced this issue Jul 4, 2024
I am currently in the process of upgrading from Ruby 2.6 to Ruby 3.0. Initially, I didn't find any restrictions on updating my current factory_bot_rails version to the latest one. Unfortunately, this turned out to be incorrect. The latest version of factory_bot_rails requires factory_bot v6.4, which in turn requires Ruby 3, causing my update to fail.

```
SyntaxError: /root/project/vendor/bundle/ruby/2.6.0/gems/factory_bot-6.4.5/lib/factory_bot/evaluator.rb:38: syntax error, unexpected ...
...method_missing(method_name, ...)
```

So, adding the `required_ruby_version` might help to prevent the misconception.

References:
  - thoughtbot/factory_bot#1614
  - thoughtbot/factory_bot@36bd065
  - https://github.com/thoughtbot/factory_bot/pull/1622/files
mshibuya added a commit to railsadminteam/rails_admin that referenced this issue Jul 6, 2024
Earlopain added a commit to Earlopain/factory_bot that referenced this issue Aug 13, 2024
neilvcarvalho pushed a commit that referenced this issue Jan 27, 2025
They were dropped from CI in #1612.
Also see #1614 and 1622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants