Skip to content

Fix error when using Appraisal and install_if#226

Merged
nickcharlton merged 1 commit intothoughtbot:mainfrom
n-rodriguez:wip/combustion
Sep 23, 2024
Merged

Fix error when using Appraisal and install_if#226
nickcharlton merged 1 commit intothoughtbot:mainfrom
n-rodriguez:wip/combustion

Conversation

@n-rodriguez
Copy link
Copy Markdown
Contributor

An error occurred while loading ./spec/draper/draper_spec.rb.
Failure/Error: Bundler.require(*Rails.groups)

SyntaxError:
  /Users/nicolas/.asdf/installs/ruby/3.3.3/lib/ruby/gems/3.3.0/gems/appraisal-2.5.0/lib/appraisal/gemfile.rb:52: syntax error, unexpected `end'
# ./spec/dummy/config/application.rb:10:in `<top (required)>'
# ./spec/dummy/config/environment.rb:4:in `require_relative'
# ./spec/dummy/config/environment.rb:4:in `<top (required)>'
# ./spec/spec_helper.rb:12:in `<top (required)>'
# ./spec/draper/draper_spec.rb:1:in `<top (required)>'

I've added some debug around def dup (puts YAML.dump(for_dup) right before gemfile.run(for_dup, __FILE__, __LINE__) :

def dup
Gemfile.new.tap do |gemfile|
gemfile.git_sources = @git_sources
gemfile.run(for_dup, __FILE__, __LINE__)
end

Instead of using a raw String as explained here (#176) it uses the interpreted version:

--- |-
  source "https://rubygems.org"

  gem "appraisal"
  gem "capybara"
  gem "cuprite"
  gem "database_cleaner"
  gem "factory_bot"
  gem "faker"
  gem "guard-rspec"
  gem "puma"
  gem "rake"
  gem "rspec-rails"
  gem "rspec-retry"
  gem "rubocop"
  gem "rubocop-capybara"
  gem "rubocop-factory_bot"
  gem "rubocop-rake"
  gem "rubocop-rspec"
  gem "simplecov"
  gem "sqlite3", "~> 1.5.0"
  gem "rails", "6.1.7"

  install_if #<Proc:0x000000011f590cc0 /Users/nicolas/PROJECTS/CONCERTO/gems/draper/gemfiles/rails_6.1.7.gemfile:25 (lambda)> do
    gem "net-imap"
    gem "net-pop"
    gem "net-smtp"
  end

  install_if #<Proc:0x000000011f5909f0 /Users/nicolas/PROJECTS/CONCERTO/gems/draper/gemfiles/rails_6.1.7.gemfile:31 (lambda)> do
    gem "base64"
    gem "bigdecimal"
    gem "mutex_m"
    gem "drb"
    gem "logger"
  end

  gemspec path: "../"

Copy link
Copy Markdown
Member

@nickcharlton nickcharlton left a comment

Choose a reason for hiding this comment

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

This looks good! We can merge this in once we've gone through #230.

```sh
An error occurred while loading ./spec/draper/draper_spec.rb.
Failure/Error: Bundler.require(*Rails.groups)

SyntaxError:
  /Users/nicolas/.asdf/installs/ruby/3.3.3/lib/ruby/gems/3.3.0/gems/appraisal-2.5.0/lib/appraisal/gemfile.rb:52: syntax error, unexpected `end'
```

Instead of using a raw String as explained here (#176) it uses the interpreted version:

```sh
--- |-
  source "https://rubygems.org"

  gem "appraisal"
  gem "capybara"
  gem "cuprite"
  gem "database_cleaner"
  gem "factory_bot"
  gem "faker"
  gem "guard-rspec"
  gem "puma"
  gem "rake"
  gem "rspec-rails"
  gem "rspec-retry"
  gem "rubocop"
  gem "rubocop-capybara"
  gem "rubocop-factory_bot"
  gem "rubocop-rake"
  gem "rubocop-rspec"
  gem "simplecov"
  gem "sqlite3", "~> 1.5.0"
  gem "rails", "6.1.7"

  install_if #<Proc:0x000000011f590cc0 /Users/nicolas/PROJECTS/CONCERTO/gems/draper/gemfiles/rails_6.1.7.gemfile:25 (lambda)> do
    gem "net-imap"
    gem "net-pop"
    gem "net-smtp"
  end

  install_if #<Proc:0x000000011f5909f0 /Users/nicolas/PROJECTS/CONCERTO/gems/draper/gemfiles/rails_6.1.7.gemfile:31 (lambda)> do
    gem "base64"
    gem "bigdecimal"
    gem "mutex_m"
    gem "drb"
    gem "logger"
  end

  gemspec path: "../"
```
@nickcharlton nickcharlton merged commit 24feeea into thoughtbot:main Sep 23, 2024
javierjulio added a commit to javierjulio/dartsass-rails that referenced this pull request Nov 11, 2024
This bumps the Bundler version to resolve `warning: constant DidYouMean::SPELL_CHECKERS is deprecated` warnings.

This installs zeitwerk 2.6 for now. I couldn't get this work with appraisal's `install_if` method introduced in v2.5.0 which has a hard error. It's been fixed in thoughtbot/appraisal#226 but has no release. For now we'll install zeitwerk 2.6 since 2.7 requires Ruby 3.2+.
@n-rodriguez n-rodriguez deleted the wip/combustion branch June 13, 2025 23:40
santiagorodriguez96 added a commit to cedarcode/devise-webauthn that referenced this pull request Jan 7, 2026
We were running into a weird issue after starting using `install_if` in
4e7fdb6:

```
SyntaxError:

  /home/runner/work/devise-webauthn/devise-webauthn/vendor/bundle/ruby/3.4.0/gems/appraisal-2.5.0/lib/appraisal/gemfile.rb:46: syntax error found (SyntaxError)
    44 | install_if #<Proc:0x00007fb6ce1724d8 /home/runner/work/devise-webauthn/devise-webauthn/gemfiles/devise_5_0.gemfile:22 (lambda)> do
    45 |   gem "rack", "~> 2.2"
  > 46 | end
       | ^~~ unexpected 'end', ignoring it
    47 |
    48 | gemspec path: "../"
```

This is an Appraisal bug fixed in
thoughtbot/appraisal#226, but not released yet.

However, as this happens when loading `appraisal` when using our
`devise_5_0` generated gemfile that has the `install_if` directive, we
can simply fix it by preventing it from loading using `require: false`
(which allow us to continue using `appraisal` normally as we were too).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants