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

Ruby Parser requirement requires Ruby outside of EOL #91

Open
kylesnowschwartz opened this issue Oct 26, 2023 · 0 comments
Open

Ruby Parser requirement requires Ruby outside of EOL #91

kylesnowschwartz opened this issue Oct 26, 2023 · 0 comments

Comments

@kylesnowschwartz
Copy link

tl;dr Let's update the find_step.rb script instead of requiring very old ruby versions. It's easy to fix up!

Hello, I use cucumber within Spacemacs

In GNU Emacs 29.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
 Version 10.14.6 (Build 18G9323)) of 2023-08-17 built on
 builder10-14.lan
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.3.1

And would like to use the feature-goto-step-definition function. But it requires

gem 'ruby_parser', "~> 3.14.2"
gem 'cucumber-gherkin', "14.0.1"

And when I try to install that version of the ruby parser I get

~/Code/theapp (main)$ gem install ruby_parser -v 3.14.2
ERROR:  Error installing ruby_parser:
	ruby_parser-3.14.2 requires Ruby version ~> 2.2. The current ruby version is 3.1.4.

I didn't want to install such an old version of Ruby, but I tried anyway, but the build failed (I tried a few minor versions too)

WARNING: ruby-2.2.0 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew

BUILD FAILED (macOS 13.3.1 using ruby-build 20230428)

Inspect or clean up the working tree at /var/folders/3y/6_str63x5y951rxczj0939pr0000gn/T/ruby-build.20231026114030.41789.DjdOo0
Results logged to /var/folders/3y/6_str63x5y951rxczj0939pr0000gn/T/ruby-build.20231026114030.41789.log

Anyway, after that I failed I decided to just fix up the find_step script in my emacs packages directory and it was pretty easy.

After removing the version requirements for gherkin and ruby parser, simply change @ast[:feature] to @ast.feature and change node.try(:examples) to node.respond_to?(:examples) && node&.examples and the package works again for me!

e.g.

  def step_at(line)
    @ast.feature.children.each do |element|
      node = element.scenario || element.background
      next unless node

      node.steps.each do |step|
        next unless step.location.line == line

        return step_result(step, node)
      end
    end
    nil
  end

  # Return hash of step info
  def step_result(step, node)
    result = { 'name' => step.text }
    return result unless node.respond_to?(:examples) && node&.examples

    return result if node.examples[0].nil?

    add_example_info(node, result)
  end

I hope that helps someone who might be coming here trying to get this package to work without ruby 2.2

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

No branches or pull requests

1 participant