t-ruby: `authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError)

$ t authorize Welcome! Before you can use t, you’ll first need to register an application with Twitter. Just follow the steps below:

  1. Sign in to the Twitter Application Management site and click “Create New App”.
  2. Complete the required fields and submit the form. Note: Your application must have a unique name.
  3. Go to the Permissions tab of your application, and change the Access setting to “Read, Write and Access direct messages”.
  4. Go to the Keys and Access Tokens tab to view the consumer key and secret which you’ll need to copy and paste below when prompted.

Press [Enter] to open the Twitter Developer site.

Enter your API key: <snip> Enter your API secret: <snop> /Library/Ruby/Gems/2.3.0/gems/t-3.1.0/lib/t/cli.rb:82:in authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError) from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in run’ from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in invoke_command' from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in dispatch’ from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor/base.rb:466:in start' from /Library/Ruby/Gems/2.3.0/gems/t-3.1.0/bin/t:20:in <top (required)>’ from /usr/local/bin/t:22:in load' from /usr/local/bin/t:22:in <main>’

$ uname -srm Darwin 17.5.0 x86_64 $ sw_vers ProductName: Mac OS X ProductVersion: 10.13.4 $ system_profiler SPSoftwareDataType Software:

System Software Overview:

  System Version: macOS 10.13.4 (17E202)
  Kernel Version: Darwin 17.5.0
  Boot Volume: osx
  Boot Mode: Normal

$ t --version 3.1.0

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 26
  • Comments: 16

Most upvoted comments

t works with v6.1.0 of the twitter gem, so I fixed it by running:

$ gem install twitter -v 6.1.0
$ gem uninstall twitter -v 6.2.0

The simplest upstream fix is to change t.gemspec’s twitter dependency to ~> 6.1.0 instead of ~> 6.0. (Submitted a pull request with this change: #412)

For anyone who is looking for a quick solution, you can try https://github.com/sferik/twitter/issues/878#issuecomment-392878152

It works for me.

This workaround no longer works as of Ruby 3 on OS/X:

image

Earlier @epitron solution works for authentication, but then dm is still not working https://github.com/sferik/t/issues/405. Updating twitter dependency to 7.0 fixes this, but with it the authentication is broken… So what I ended up doing to be able to log in and to send a dm:

First, authentication is broken after twitter gem 6.1.0 so downgrade to it after t-3.1.0 gem installation:

gem install twitter -v 6.1.0
gem uninstall twitter -v 6.2.0

Now authenticate, most things should work after that. To get dm working make sure first the app has permission for dm’s (hidden under “Permissions” tab on API control panel).

Then to make DM’s work, set up 7.0.0 version of Twitter package to be used as a dependency first in /usr/local/lib/ruby/gems/2.7.0/gems/t-3.1.0/t.gemspec

s.add_runtime_dependency(%q<twitter>.freeze, [">= 6.1"])

And then install it in place of 6.1.0.

gem install twitter -v 7.0.0
gem uninstall twitter -v 6.1.0

Now you should have this installed and working with direct messaging functionality. If you need to re-authorize the app you need roll back 6.1.0 first.

Additionally hide ruby faraday deprecation warnings as noted in https://github.com/sferik/t/issues/424#issuecomment-643549067, this is something else that seems to be glitching on both Ubuntu and Mac homebrew side.

gem uninstall twitter -v 6.1.0

Thank you for your help. In Ubuntu 20.04, the file to edit the dependencies is

/var/lib/gems/2.7.0/specifications/t-3.1.0.gemspec

Hey, that fix works for me. It should be noted that you also need rdoc as well. That’s probably obvious to people who already know ruby, but it wasn’t for me. 😃

t works with v6.1.0 of the twitter gem, so I fixed it by running:

$ gem install twitter -v 6.1.0
$ gem uninstall twitter -v 6.2.0

The simplest upstream fix is to change t.gemspec’s twitter dependency to ~> 6.1.0 instead of ~> 6.0. (Submitted a pull request with this change: #412)

This fixed it for me.

Use this fork instead: https://github.com/xiaocang/t

Build and install instructions:

gem build t.gemspec
gem install t-3.1.1.gem

@epitron’s solution worked for me too. Thank you.

Thanks @epitron your simple solution worked a treat.