sferik / t-ruby

A command-line power tool for Twitter.
http://sferik.github.com/t
MIT License
5.43k stars 408 forks source link

t unable to execute #395

Open jasontucker opened 6 years ago

jasontucker commented 6 years ago

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>'
GregBaugues commented 6 years ago

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

dotHTM commented 6 years ago

I have the same issue and error message as the OP, however I'm running macOS 10.12 Sierra, not 10.13 High Serra.

However I have a previous authorization configuration file I've copied over to this system. When trying to authorize a new account, I get the following error:

> t authorize
It looks like you've already registered an application with Twitter.
To authorize a new account, just follow the steps below:
  1. Sign in to the Twitter Developer site.
  2. Select the application for which you'd like to authorize an account.
  3. Copy and paste the consumer key and secret below when prompted.

Press [Enter] to open the Twitter Developer site. Enter your API key: [redacted]
Enter your API secret: [redacted]
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 /usr/local/lib/ruby/gems/2.5.0/gems/t-3.1.0/bin/t:20:in `<top (required)>'
        4: from /usr/local/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
        3: from /usr/local/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        2: from /usr/local/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        1: from /usr/local/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.5.0/gems/t-3.1.0/lib/t/cli.rb:82:in `authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError)
dotHTM commented 6 years ago

I've also confirmed the same behavior in a Linux Docker Container. The program dies in the authorize command.

Dockerfile:

FROM ruby
RUN gem install t
CMD /bin/bash
> docker build ./ -t ruby-t
> docker run -ti ruby-t
root@930f769b1637:/# 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. 

Open: https://apps.twitter.com
Enter your API key: [redacted]
Enter your API secret: [redacted]
Traceback (most recent call last):
        7: from /usr/local/bundle/bin/t:23:in `<main>'
        6: from /usr/local/bundle/bin/t:23:in `load'
        5: from /usr/local/bundle/gems/t-3.1.0/bin/t:20:in `<top (required)>'
        4: from /usr/local/bundle/gems/thor-0.20.0/lib/thor/base.rb:466:in `s
tart'
        3: from /usr/local/bundle/gems/thor-0.20.0/lib/thor.rb:387:in `dispat
ch'
        2: from /usr/local/bundle/gems/thor-0.20.0/lib/thor/invocation.rb:126
:in `invoke_command'
        1: from /usr/local/bundle/gems/thor-0.20.0/lib/thor/command.rb:27:in 
`run'
/usr/local/bundle/gems/t-3.1.0/lib/t/cli.rb:82:in `authorize': uninitialized 
constant Twitter::REST::Client::BASE_URL (NameError)
dotHTM commented 6 years ago

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)
dotHTM commented 6 years ago

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.

deadbaed commented 6 years ago

hi,
i have the same issue, however, i am running arch linux, my ruby version is ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux].

i haven't tried @dotHTM 's workaround yet.

techieshark commented 6 years ago

Confirming this, with Ruby 2.3.6, one of the versions listed as supported by t:

/usr/local/var/rbenv/versions/2.3.6/lib/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 /usr/local/var/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from /usr/local/var/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from /usr/local/var/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    from /usr/local/var/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
    from /usr/local/var/rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/t-3.1.0/bin/t:20:in `<top (required)>'
    from /usr/local/var/rbenv/versions/2.3.6/bin/t:22:in `load'
    from /usr/local/var/rbenv/versions/2.3.6/bin/t:22:in `<main>'
marksolaris commented 6 years ago

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

Searge commented 6 years ago

@dotHTM, no… it doesn’t work 😔

/Users/searge/.rvm/gems/ruby-2.4.2/gems/t-3.1.0/lib/t/cli.rb:82:in `authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError)
    from /Users/searge/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from /Users/searge/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/searge/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    from /Users/searge/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
    from /Users/searge/.rvm/gems/ruby-2.4.2/gems/t-3.1.0/bin/t:20:in `<top (required)>'
    from /Users/searge/.rvm/gems/ruby-2.4.2/bin/t:23:in `load'
    from /Users/searge/.rvm/gems/ruby-2.4.2/bin/t:23:in `<main>'
    from /Users/searge/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/searge/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `<main>'

~ 36s

OS X El Capitan, ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]

@marksolaris also — no…

johnniehard commented 6 years ago

@Searge There are two places in the file where you need to change Client to Request.

audunmo commented 6 years ago

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

bpg1968 commented 6 years ago

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

deadbaed commented 6 years ago

same error as @bpg1968

dardo82 commented 6 years ago

I've had this problem too… This one-liner should fix it. sed -i '' ’s/Client/Request/g' $(gem env | awk '/ - \//&&!/bin/{print $2}' | xargs -I @ find @ -type d -name t)/cli.rb

norcalli commented 6 years ago

How is it that such a basic error hasn't been fixed yet? Is this project abandoned?

dardo82 commented 6 years ago

Fix it yourself or use one of the improved forks...

deadbaed commented 6 years ago

can you link us to a good one @dardo82 ?

dotHTM commented 6 years ago

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

dotHTM commented 6 years ago

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

dardo82 commented 6 years ago

No, I can’t, as obviously I’m using the fix I posted!

sonovawolf commented 6 years ago

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

dardo82 commented 6 years ago

@thisisalessandro it should be the same thing but I don’t use it now, then I’m not sure.

telepathics commented 5 years ago

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