sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.3k forks source link

uninitialized constant Twitter::REST #878

Closed cheater closed 1 year ago

cheater commented 7 years ago

Assuming this got fixed in #479 and reared its head due to some other issue now.

I literally only installed ruby 2.4, then did gem install t, and this is what happened.

Traceback:

/var/lib/gems/2.4.0/gems/t-3.1.0/lib/t/cli.rb:82:in `authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError)
    from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
    from /var/lib/gems/2.4.0/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>'

gem list says:

*** LOCAL GEMS ***

addressable (2.5.2)
bigdecimal (1.3.2, default: 1.3.0)
buftok (0.2.0)
domain_name (0.5.20170404)
equalizer (0.0.11)
geokit (1.11.0)
htmlentities (4.3.4)
http (3.0.0)
http-cookie (1.0.3)
http-form_data (2.0.0)
http_parser.rb (0.6.0)
io-console (default: 0.4.6)
json (2.1.0, default: 2.0.4)
launchy (2.4.3)
memoizable (0.4.2)
multipart-post (2.0.0)
naught (1.1.0)
oauth (0.5.3)
openssl (2.0.6, default: 2.0.5)
psych (2.2.4, default: 2.2.2)
public_suffix (3.0.1)
rdoc (5.1.0, default: 5.0.0)
retryable (2.0.4)
simple_oauth (0.3.1)
t (3.1.0)
thor (0.20.0)
thread_safe (0.3.6)
twitter (6.2.0)
unf (0.1.4)
unf_ext (0.0.7.4)

Not sure how to progress. Workarounds?

cheater commented 7 years ago

Tried this in ruby 2.1 as well, with same result.

elliotblackburn commented 7 years ago

I'm getting the same issue, not quite sure what to do either. My ruby version is ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16].

It seems to be failing to find a constant in the twitter library, it's looking in Twitter::REST::Client but from what I can see in the file - https://github.com/sferik/twitter/blob/d7951759da897e6a8e3ed0069b2e850470991e3f/lib/twitter/rest/client.rb it's not there. It seems to actually be in Twitter::REST::Request I believe?

elliotblackburn commented 7 years ago

Ah I see the issue - https://github.com/sferik/twitter/compare/v6.1.0...v6.2.0 BASE_URL used to reside in that file but has been moved. So when Twitter 6.2.0 was released, versions of this are breaking.

Any chance someone could fix the version to 6.1.0 so this library will continue working? I'm not a huge ruby expert, you'd also need publish access.

gtramontina commented 7 years ago

Yeah, I guess if moving the constant out to a different location was a deliberate move, then this should be flagged as a breaking change, thus a major release should've been released. Got here from getting the same error when running a fresh install of https://github.com/sferik/t (gem install t).

I'd suggest unpublishing v6.2.0 (gem yank?) and republishing it as v7.0.0.

sferik commented 7 years ago

Iā€™m working on a fix for this issue now. Sorry for the trouble.

elliotblackburn commented 6 years ago

Thanks @sferik, looking forward to being able to use the CLI client šŸ‘

ghost commented 6 years ago

Thank you for working on this, waiting on it :D

garybunofsky commented 6 years ago

Patiently waiting for this fix as well. Thanks for working on it! šŸ‘

ghamarian commented 6 years ago

Also waiting :-) Thanks!

chrisvoncsefalvay commented 6 years ago

Also waiting. Thanks for working on this! šŸ‘

vuiermark commented 6 years ago

waiting here as well...thanks!

cheater commented 6 years ago

OK guys i know you're impatient but this nagging absolutely has to stop. I get retarded "bump" notifications every day. This isn't goddamn twitter. Go live out your ADHD over there. The guy obviously hasn't been on github since november - look at his activity - so what are you trying to achieve with this? He's busy with his real life (yeah, some people have one) and is going to get around to it... WHEN HE GETS AROUND TO IT. Stop nagging or I'll close the bug report!

rvagg commented 6 years ago

Here's your workaround folks: edit /Library/Ruby/Gems/2.3.0/gems/t-3.1.0/lib/t/cli.rb, or maybe /Library/Ruby/Gems/*/gems/t-*/lib/t/cli.rb if you don't have that file. Replace the two instances of Twitter::REST::Client::BASE_URL with Twitter::REST::Request::BASE_URL and you're good to go.

rdmarsh commented 6 years ago

expanding on @rvagg: ubuntu 17.10, file was located at /var/lib/gems/2.3.0/gems/t-3.1.0/lib/t/cli.rb

hexwaxwing commented 6 years ago

expanding on @rvagg: OS X 10.12.6 w/ rvm, file was located at ~/.rvm/gems/ruby-2.4.3/gems/t-3.1.0/lib/t/cli.rb

DavidCWGA commented 6 years ago

rvagg's workaround doesn't work for me. The error changes to:

/var/lib/gems/2.3.0/gems/t-3.1.0/lib/t/rcfile.rb:89:in `profiles': undefined method `[]' for false:FalseClass (NoMethodError)
jm3 commented 6 years ago

@sferik would love some help getting this fixed so i can use t again!

fuzz commented 6 years ago

It's not the prettiest solution, but if anyone just wants to get this working you can do it with bundler: Make a Gemfile with gem "t" and gem "twitter", "6.1.0", call bundle install and then run it with bundle exec t

ialexs commented 6 years ago

Also not the prettiest solution: I copy the .twurlrc (from Twurl https://github.com/twitter/twurl) to .trc then run t as usual.

cheers

jasonhemann commented 6 years ago

@fuzz or @ialexs, could either of you describe these two solutions in a little more detail?

I didn't see .twurlrc in the Twurl repo, and I don't know that I have bundle installed. I'm not familiar with that tool, and the name seems pretty Google-proof.

Thanks,

DelphicOkami commented 6 years ago

@jasonhemann

  1. Go to https://apps.twitter.com/
  2. Ensure your app (whether newly created or otherwise) has Read, Write and Access direct messages permissions
  3. Locally run gem install twurl
  4. Run twurl authorize --consumer-key {YOUR APP'S CONSUMER KEY} --consumer-secret {YOUR APP'S CONSUMER SECRET}
  5. Follow the steps it requests that you do
  6. Copy ~/.twurlr to ~/.trc

Essentially what @ialexs seems to mean is, copy the file generated by twurl

DelphicOkami commented 6 years ago

The above totally worked for me

cprkrn commented 6 years ago

Ah editing the cli.rb worked fine! Didn't realize there were two instances. Many thanks.

kylejohnston commented 6 years ago

The path to my cli.rb file was listed in the error message output after I entered my API keys (my path was different from the paths listed above).

Once I edited both instances of Twitter::REST::Request::BASE_URL, the installation completed.

albill commented 6 years ago

Really, this has been broken for eight months without a fix? WTH?

eobrain commented 6 years ago

Let's be nice here. This is a 12-year old open-source project. It is not unreasonable that the original maintainer might not jump in and fix bugs after all that time.

Anyone with Ruby skills and sufficient interest could contribute a fix. (I myself actually spent a little while freshening my rusty Ruby skills to see if I could fix this issue, but I just have not had time to devote to it.)

166 people have contributed to this repo over the years, so I suspect there are multiple people out there who would be able and willing to fix this.

jm3 commented 6 years ago

@eobrain any suggestions for how best to appeal to some of those people?

kennethreitz commented 6 years ago

For those just running into this issue (like myself), this solution worked for me.

thebitstick commented 5 years ago

Holy shit happy new year. Also having this issue. When is a fork coming to Rubygem that will be maintained, jesus.

patwalls commented 5 years ago

This bug totally sucks, spent a ton of time trying all these solutions and none worked. Are there any alternatives to the twitter ruby gem?

cognitive137 commented 5 years ago

@jasonhemann

  1. Go to https://apps.twitter.com/
  2. Ensure your app (whether newly created or otherwise) has Read, Write and Access direct messages permissions
  3. Locally run gem install twurl
  4. Run twurl authorize --consumer-key {YOUR APP'S CONSUMER KEY} --consumer-secret {YOUR APP'S CONSUMER SECRET}
  5. Follow the steps it requests that you do
  6. Copy ~/.twurlr to ~/.trc

Essentially what @ialexs seems to mean is, copy the file generated by twurl

@jasonhemann

  1. Go to https://apps.twitter.com/
  2. Ensure your app (whether newly created or otherwise) has Read, Write and Access direct messages permissions
  3. Locally run gem install twurl
  4. Run twurl authorize --consumer-key {YOUR APP'S CONSUMER KEY} --consumer-secret {YOUR APP'S CONSUMER SECRET}
  5. Follow the steps it requests that you do
  6. Copy ~/.twurlr to ~/.trc

Essentially what @ialexs seems to mean is, copy the file

I now get this error:

/Library/Ruby/Gems/2.3.0/gems/twurl-0.9.3/lib/twurl/cli.rb:94:in parse_options': invalid option: --8yZ1Sso8SKsPJG7F0BYMT62QG (OptionParser::InvalidOption) from /Library/Ruby/Gems/2.3.0/gems/twurl-0.9.3/lib/twurl/cli.rb:17:inrun' from /Library/Ruby/Gems/2.3.0/gems/twurl-0.9.3/bin/twurl:4:in <top (required)>' from /usr/local/bin/twurl:22:inload' from /usr/local/bin/twurl:22:in `

'

elliotblackburn commented 5 years ago

@cognitive137 I think you should probably reset/delete that API key as it looks like it's been printed out in your error log there. (Editing your github comment will not remove it as there is a history of comments avalible). You should do this asap or someone may be able to use twitter as you šŸ˜¢

cognitive137 commented 5 years ago

@BlueHatbRit , thank you!

DennisFaucher commented 4 years ago

@jasonhemann

  1. Go to https://apps.twitter.com/
  2. Ensure your app (whether newly created or otherwise) has Read, Write and Access direct messages permissions
  3. Locally run gem install twurl
  4. Run twurl authorize --consumer-key {YOUR APP'S CONSUMER KEY} --consumer-secret {YOUR APP'S CONSUMER SECRET}
  5. Follow the steps it requests that you do
  6. Copy ~/.twurlr to ~/.trc

Essentially what @ialexs seems to mean is, copy the file generated by twurl

That's the fix! Many thanks @jasonhemann

bnsv commented 4 years ago

@jasonhemann

1. Go to https://apps.twitter.com/

2. Ensure your app (whether newly created or otherwise) has Read, Write and Access direct messages permissions

3. Locally run `gem install twurl`

4. Run `twurl authorize --consumer-key {YOUR APP'S CONSUMER KEY} --consumer-secret {YOUR APP'S CONSUMER SECRET}`

5. Follow the steps it requests that you do

6. Copy ~/.twurlr to ~/.trc

Essentially what @ialexs seems to mean is, copy the file generated by twurl

It's works for me too. You missing c on the last command (should be cp ~/.twurlrc ~/.trc). Thank you.

BitumFelix commented 3 years ago

Here's your workaround folks: edit /Library/Ruby/Gems/2.3.0/gems/t-3.1.0/lib/t/cli.rb, or maybe /Library/Ruby/Gems/*/gems/t-*/lib/t/cli.rb if you don't have that file. Replace the two instances of Twitter::REST::Client::BASE_URL with Twitter::REST::Request::BASE_URL and you're good to go.

This worked for me too! I was almost giving up.

cmdrfletcher commented 3 years ago

@jasonhemann

  1. Go to https://apps.twitter.com/
  2. Ensure your app (whether newly created or otherwise) has Read, Write and Access direct messages permissions
  3. Locally run gem install twurl
  4. Run twurl authorize --consumer-key {YOUR APP'S CONSUMER KEY} --consumer-secret {YOUR APP'S CONSUMER SECRET}
  5. Follow the steps it requests that you do
  6. Copy ~/.twurlr to ~/.trc

Essentially what @ialexs seems to mean is, copy the file generated by twurl

This is still working! Thanks! šŸ‘