Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

uninitialized constant Apiary::Command::Fetch::OpenStruct (NameError) #219

Open
mark-young-atg opened this issue May 2, 2024 · 2 comments

Comments

@mark-young-atg
Copy link

The apiary fetch command is giving me an OpenStruct error:

➜  apiary fetch --api-name="api" --output="api.apib"
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/user/.rvm/gems/ruby-3.3.1@apidocs/gems/apiaryio-0.17.0/lib/apiary/command/fetch.rb:12:in `initialize': uninitialized constant Apiary::Command::Fetch::OpenStruct (NameError)

      @options = OpenStruct.new(opts)
                 ^^^^^^^^^^
	from /Users/user/.rvm/gems/ruby-3.3.1@apidocs/gems/apiaryio-0.17.0/lib/apiary/cli.rb:28:in `new'

This can be fixed by adding require 'ostruct' after the require 'json' in gems/apiaryio-0.17.0/lib/apiary/command/fetch.rb
e.g.

➜  head -7 /Users/user/.rvm/gems/ruby-3.3.1@apidocs/gems/apiaryio-0.17.0/lib/apiary/command/fetch.rb
# encoding: utf-8

require 'rest-client'
require 'json'
require 'ostruct'

require 'apiary/agent'

I have not raised this as a pull request at this point as I felt it was worth a discussion first.
I'm not sure if this is related to the version of Ruby. I'm using v3.3.1.
Please let me know your thoughts and whether I should raise this as a PR?

@amnerip-fubotv
Copy link

I went ahead and submitted a simple PR to fix this. I'd love to hear the maintainers' comments on how to improve it though. #220

@QuentinLemCode
Copy link

A workaround is to use the environment variable RUBYOPT='-rostruct'

Example : RUBYOPT='-rostruct' apiary preview

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants