LoginSignup
0
0

More than 3 years have passed since last update.

Ruby の Mastodon API ライブラリで uninitialized constant になる

Last updated at Posted at 2019-05-05

Ruby の Mastodon API ライブラリで new すると下記のようなエラーになります。

irb(main):008:0> client = Mastodon::REST::Client.new(base_url: 'xxxx', bearer_token: 'xxxx')
Traceback (most recent call last):
        4: from /Users/xxx/.rbenv/versions/2.6.2/bin/irb:23:in `<main>'
        3: from /Users/xxx/.rbenv/versions/2.6.2/bin/irb:23:in `load'
        2: from /Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        1: from (irb):8
NameError (uninitialized constant Mastodon::REST)

原因がわからず困ったのですが、似た名前の gem (下記)を事前に誤って install していたのが原因でした。

$ gem info mastodon

*** LOCAL GEMS ***

mastodon (0.3.1)
    Author: Colin Shea
    Homepage: http://evaryont.me
    Installed at: /Users/xxxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0

    A Ruby parser for todo.txt files

ちなみに Mastodon API のライブラリはこちら。

$ gem info mastodon-api

*** LOCAL GEMS ***

mastodon-api (2.0.0)
    Author: Eugen Rochko
    Homepage: https://github.com/tootsuite/mastodon-api
    License: MIT
    Installed at: /Users/xxxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0

    A ruby interface to the Mastodon API

誤って install したほうを uninstall してあげたら解決しました。

$ gem uninstall mastodon
Successfully uninstalled mastodon-0.3.1

Mastodon 自体は 一般的な言葉 ですし、こうしたこともあるのかなと思いました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0