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

Error when loading with irb: "uninitialized constant Coinbase (NameError)" #234

Open
Makazone opened this issue Jan 19, 2025 · 3 comments
Open

Comments

@Makazone
Copy link

Description

It appears that the top-level module Coinbase is not defined before the first require_relative 'coinbase/client'. The code in api_client.rb defines module Coinbase::Client. This causes Ruby to fail when trying to access Coinbase::Client because Ruby doesn’t recognize the Coinbase module yet.

To reproduce (using ruby 2.7.5 and 3+):

  1. Launch IRB.
  2. Run require 'coinbase'
  3. Observe the "uninitialized constant Coinbase (NameError)" error.

Will submit a PR with a suggested fix!

@Makazone
Copy link
Author

Looks like I don't have enough permissions to push a branch with a fix.

Here is how I'm thinking about it:

  1. The first require_relative 'coinbase/client' references lib/coinbase/client/api_client.rb
  2. The file defines module Coinbase::Client and since no module Coinbase was defined before the error appears
  3. The fix is to update api_client.rb with
module Coinbase
  module Client
    class ApiClient

@Makazone
Copy link
Author

@alex-stone let me know how I can help further here. I've tested the fix locally (with make test and using it with irb) and it looks good. I'm also seeing that other files follow the same syntax (module Coinbase module XXX instead of module Coinbase::XXX).

@dwkns
Copy link

dwkns commented Jan 27, 2025

Having the same problem here too.

Image

And can confirm that @Makazone's fix seems to work locally.

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

No branches or pull requests

2 participants