I have a ruby script that scans each type of entity in a given tweet:
status = Twitter::Client.new.status(tweet[:id_str], {:include_entities => "1"})
status[:entities].each do |x|
#job on the entity
end
It was doing good until yesterday. Now I get NoMethodError: undefined method 'entities' for #<Twitter::Status:0x000001033e1800>
I can't figure it out since I've checked that status does include entities after the first line.
Any clues?
EDIT: turns out it's the new version of the twitter gem (v2.0.0) which is in cause. First I'd like to downgrade it to the last version working (v1.7.2), but I'm getting an annoying gem version error:
Bundler could not find compatible versions for gem "hashie":
In Gemfile:
topsy (~> 0.3.6) depends on
hashie (~> 1.0.0)
twitter (= 1.7.2) depends on
hashie (1.1.0)
How can I work it out?
If you need specific gem's version, you can forcely set it throught Gemfile:
gem "rack", "1.0.1"
gem "rails", ">=2.3.2"
In the end it was a conflict in the Gemfile:
gem 'topsy', '~> 0.3.6'
gem 'twitter', '1.7.2'
were requesting different versions of hashie, so I just deleted the version of topsy and it worked.
Related
I have a gem already installed locally, and I wanna add a new dependency into it. I worked with below steps:
Open the gem installation folder as below:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0
Add new dependency below into gemspec file (nesta.gemspec)
s.add_dependency('stacktracer', '>= 0.0.1')
Append gem 'stacktracer' into Gemfile
Add require "stacktracer" into Rakefile
Run command bundle update nesta
Run command bundle install
Check Gemfile.lock, I already found the new dependency like below:
I have next dependencies:
DEPENDENCIES
debugger
mr-sparkle (>= 0.0.2)
nesta!
rack-test (= 0.6.1)
rspec (~> 2.14.0)
**stacktracer**
test-unit (= 1.2.3)
webrat (~> 0.7.3)
But when I met two problems here:
run command gem dependency nesta, I did not find stacktracer dependency list.
I added require "stacktracer" into app.rb, then run the application, it failed due to below error:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0/lib/nesta/app.rb:4:in `require': cannot load such file -- stacktracer (LoadError)
Could any one help me to tackle the problems? Is there any approach that could manage to update gem dependency successfully?
You are not supposed to edit the unpacked gems under .../rvm/gems/ruby-2.1.0/gems. If you need to update the alien gem, you are to follow this approach:
Fork the gem source at github
Clone the repo to your local drive
Update whatever you want + update version
Set the dependency in your Gemfile to either use unpacked version or your git:
gem 'nesta', :path => '.../nesta.git'
gem 'nesta', :git => 'git://...'
Don’t forget to eliminate the original gem presence over your system. Hope it helps.
Specifically, this commit has been merged into mongomapper master to fix a bug that is causing my application to crash:
https://github.com/mongomapper/mongomapper/pull/572
However, it hasn't been released in a new gem. Is it possible to include it prematurely or do I have to wait until it's released? I'm on heroku with a Gemfile.lock that specifies version.
My gemfile.lock currently reads:
mongo_mapper (0.13.0)
activemodel (>= 3.0.0)
activesupport (>= 3.0)
mongo (~> 1.8)
plucky (~> 0.6.5)
I don't know about Heroku, but if you want to use a git version of a gem that is not on Rubygems yet, you must add the git path to your Gemfile.
In your Gemfile change:
gem 'mongomapper'
To:
gem 'mongomapper', :git => 'https://github.com/mongomapper/mongomapper.git'
Or if you're on a more modern ruby, you can also use:
gem 'mongomapper', github: 'mongomapper/mongomapper'
And of course after that you must run bundle install or bundle update mongomapper.
Since the Ruby code isn't compiled, if you have the notes for that patch you can always manually add those changes to the lib directory of the mongomapper gem, although I can't advise against this enough - it's undesirable to change the source code, especially underneath an installed gem.
Once you go down this road you can't really count on any support for related issues until you are updated to a newer version or reverted to the original files.
I try to use mongoid 3.x together with rufus-scheduler 2.x and im always getting a gem conflict over tzinfo.
Unable to activate mongoid-3.1.4, because tzinfo-1.0.1 conflicts with tzinfo (~> 0.3.22)
Looks like mongoid has some dependency on some legacy tzinfo version.
How can I solve this problem?
In your Gemfile, specify the version of TzInfo that suits Mongoid, before Mongoid and before rufus-scheduler (rufus-scheduler accepts any version of TzInfo).
source 'https://rubygems.org'
gem 'tzinfo', '0.3.22'
gem 'mongoid', '3.1.4'
gem 'rufus-scheduler'
UPDATE
Updated rufus-scheduler 2.0.x so that it accepts >= 0.3.22 (https://github.com/jmettraux/rufus-scheduler/commit/18c98010)
Unfortunately, can't seem to be able to push to RubyGems.org for now (it goes 500).
Until I find a workaround, you can point to that new rufus-scheduler with
gem 'rufus-scheduler', :git => 'git://github.com/jmettraux/rufus-scheduler.git', :branch => 'two'
UPDATE
Could push rufus-scheduler 2.0.24 to rubygems https://rubygems.org/gems/rufus-scheduler
It should be OK now.
I've just made a little gem and pushed it to Rubygems.org:
https://rubygems.org/gems/fragrant_wind
However, I can't seem to download it again, any ideas?
$ gem install fragrant_wind
ERROR: Could not find a valid gem 'fragrant_wind' (>= 0) in any repositor
Try fixing your gem name. Choose either underscores or hyphens, but don't mix them.
For example you have:
# .gemspec
s.name = 'fragrant-wind'
Better is:
# fragrant_wind.gemspec
s.name = 'fragrant_wind'
Edit 1: it works for me to download then install, but it doesn't work via RubyGems.
$ gem install fragrant_wind-0.0.2.gem
Successfully installed fragrant_wind-0.0.2
1 gem installed
Installing ri documentation for fragrant_wind-0.0.2...
Building YARD (yri) index for fragrant_wind-0.0.2...
Installing RDoc documentation for fragrant_wind-0.0.2...
$ irb
> require 'fragrant_wind'
=> true
> FragrantWind.new.generate
=> "billowing waterfall"
Edit 2: it works via bundler too.(Thanks to #Bitterzoet for this)
# Gemfile
source 'https://rubygems.org'
gem "fragrant_wind"
$ bundle install
Fetching gem metadata from https://rubygems.org/..
Installing fragrant_wind (0.0.2)
Using bundler (1.2.3)
Your bundle is complete! ...
Edit 3: it works now as expected (Monday 10 a.m. PST). My guess is Rubygems was having a delay or glitch due to its own update last night.
I have a small ruby app that has been working. I am now getting a conflict error with builder. It looks like I updated my gems and now it is conflicting. I have it set in the Gemfile to use v2.1.2. But that is not working either. Thanks for any help you can give me.
Gemfile
gem 'builder', '2.1.2'
Bundler output
$ bundle
Using builder (2.1.2)
Using bundler (1.2.3)
$ bundle show builder
/Users/covard/.rvm/gems/ruby-1.9.3-p327/gems/builder-2.1.2
Conflict message
`raise_if_conflicts': Unable to activate actionpack-3.2.11, because rack-1.5.0 conflicts with rack (~> 1.4.0), builder-3.1.4 conflicts with builder (~> 3.0.0) (Gem::LoadError)
Figured out what my problem was even though I had my Gemfile I wasn't using it. Since rails handles that automatically I didn't know I had to add a require to use it. After adding this to my ruby files it worked perfectly.
require "bundler/setup"