t-ruby: t unable to execute

I’m having issues with getting t to work on my High Sierra Mac I cant seem to get past this part:

/usr/local/opt/gems/gems/t-3.1.0/lib/t/cli.rb:82:in `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: fdsfdasfdasfasdfsadfads (not real)
Enter your API secret: fdasfdsafadsfadsfadsfasddasfdas (not real)
/usr/local/opt/gems/gems/t-3.1.0/lib/t/cli.rb:82:in `authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError)
	from /usr/local/opt/gems/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
	from /usr/local/opt/gems/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
	from /usr/local/opt/gems/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
	from /usr/local/opt/gems/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
	from /usr/local/opt/gems/gems/t-3.1.0/bin/t:20:in `<top (required)>'
	from /usr/local/bin/t:23:in `load'
	from /usr/local/bin/t:23:in `<main>'

About this issue

Most upvoted comments

Workaround for the above bug in the authorize step:

Uninstall the current t gem:

sudo gem uninstall t

Install a previous version without this bug and do the authorize

sudo gem install t -v 2.10
...
t authorize

Update t to the current version

sudo gem update t

If you have another workstation you want to use t at, then you can copy the ~/.trc file . Although, be aware this contains your authenticated twitter identity, so this could be used to impersonate you elsewhere.

+1 can confirm got the same result on High Sierra.

Quick and dirty fix mentioned elsewhere, edit the t “cli.rb” file (change the path for your ruby version):

# vi gems/ruby-2.4.1/gems/t-3.1.0/lib/t/cli.rb

Change: Twitter::REST::Client::BASE_URL To: Twitter::REST::Request::BASE_URL

I’d suggest the name of this thread be changed to reflect the error on authorization:

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

Fix it yourself or use one of the improved forks…

a little late to the convo but @dardo82 's script worked for me if i changed the first ’ to ’

sed -i '' 's/Client/Request/g' $(gem env | awk '/ - \//&&!/bin/{print $2}' | xargs -I @ find @ -type d -name t)/cli.rb

I have the same error as OP. I’m using Ubuntu 18.04 LTS and ruby 2.5.1p57

$ 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: Created new window in existing browser session.
XXXXXXXX
Enter your API secret: XXXXXXXXXXX
Traceback (most recent call last):
	7: from /usr/local/bin/t:23:in `<main>'
	6: from /usr/local/bin/t:23:in `load'
	5: from /var/lib/gems/2.5.0/gems/t-3.1.0/bin/t:20:in `<top (required)>'
	4: from /usr/lib/ruby/vendor_ruby/thor/base.rb:444:in `start'
	3: from /usr/lib/ruby/vendor_ruby/thor.rb:369:in `dispatch'
	2: from /usr/lib/ruby/vendor_ruby/thor/invocation.rb:126:in `invoke_command'
	1: from /usr/lib/ruby/vendor_ruby/thor/command.rb:27:in `run'
/var/lib/gems/2.5.0/gems/t-3.1.0/lib/t/cli.rb:82:in `authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError)

– Brian

@dardo82’s script didn’t work for me, but manually editing the file like @marksolaris suggested worked like a charm!

Might also consider rainbowstream: https://github.com/orakaro/rainbowstream

Twitter’s API changes this summer is gonna break a lot of the use of this utility anyway.

Background on third party APIs: http://apps-of-a-feather.com

can you link us to a good one @dardo82 ?

Issue still occurring on High Sierra. Is a permanent fix being worked on?