0

I'm getting an odd error, where no rails commands of any kind are executing. Whenever I enter a rails command I get the following:

Ignoring racc-1.5.2 because its extensions are not built. Try: gem pristine racc --version 1.5.2

(this is repeated about 100 times before the following):

bin/rails:2:in `load': /Users/robertmorris/Desktop/All Projects/Code School/my9s/bin/spring:11: syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError) rescue Gem::LoadError ^ /Users/robertmorris/Desktop/All Projects/Code School/my9s/bin/spring:14: syntax error, unexpected keyword_end, expecting end-of-input from bin/rails:2:in `<main>'

My bin/spring file:

if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
  gem "bundler"
  require "bundler"

  # Load Spring without loading other gems in the Gemfile, for speed.
  Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring|
    Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
    gem "spring", spring.version
    require "spring/binstub"
  rescue Gem::LoadError
    # Ignore when Spring is not installed.
  end
end

Thanks!

1 Answer 1

1

You are using an old (unsupported) version of ruby.

You should upgrade it using any available local version manager like rvm, rbenv or asdf, to at least 2.5, or better 2.7 or 3.


On ruby 2.4 and previous, you could only rescue inside either a method:

def foo
  # do something
rescue
  # do something else
end

or an explicit begin/end block:

begin
  # do something
rescue
  # do something else
end

Since ruby 2.5 was released, all do/end blocks can have rescue clauses:

foo.bar.baz.tap do
  # do something
rescue
  # do something else
end

while before that you had to

foo.bar.baz.tap do
  begin
    # do something
  rescue
    # do something else
  end
end
Sign up to request clarification or add additional context in comments.

2 Comments

So the answer is to update Ruby to at least 2.5. A couple of days ago Rails 7.0 alpha was released which requires at least Ruby 2.7. Therefore I would suggest updating to Ruby 2.7 or even better 3.0.
Thanks for the comment @spickermann, I will make the answer clearer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.