I am including 'acts_as_rateable' gem in my Gemfile like this
gem 'acts_as_rateable', :git => 'git://github.com/azabaj/acts_as_rateable.git'
and then when I do bundle install it gives me this error message!
Could not find gem 'acts_as_rateable
(>= 0, runtime)' in
git://github.com/azabaj/acts_as_rateable.git
(at master). Source does not contain
any versions of 'acts_as_rateable (>=
0, runtime)'
I am developing a plugin of my own, when I include that, even that gives the same error like this..
I assume this has something to do with the gemspec?
Please help
Rails version : 3.0.1
Rubygems version : 1.3.7
Bundler version : 1.0.3
let me know if you need any other details..
If you want to pull a gem directly from GitHub, you can put this into your GemFile:
gem 'twitter', github: 'sferik/twitter'
Which will use the default branch. To specify the branch to use:
gem 'twitter', github: 'sferik/twitter', branch: 'branch_name'
The problem is that the repository you link to is not a RubyGem. You can get with
$ rails plugin install git://github.com/azabaj/acts_as_rateable.git
Edit: This answer was accurate on the date it was published. Rails 4 doesn't support plugins anymore, so you will have to make this into a local gem yourself. Bundler has some commands that will help you with it, or alternatively you can use a different library, e.g. https://github.com/anton-zaytsev/acts_as_rateable.
Jakub Hampl is right, but it seems strange to depend on git repos like that. I guess you're you making it yourself? If so, make it a real gem. It should have a acts_as_rateable.gemspec and you'll be able to depend on it like you wrote. Bundler makes your life easy, create the gemspec with
$ bundle gem acts_as_rateable
Related
This is more of a general question, I'm new to rails.
I trying to use a gem that requires an older version of json, json -v 1.6.5
other gems in my rails application depends on newer version of json, json -v 1.8
I'm wondering if it is possible to specify json version to be used with a specific gem?
Thank you
No it's impossible to use 2 versions of a gem at the same time.
Use 2 versions of gem at same time
If bundle update doesn't resolve the dependencies I would fork on of the gems you need to use the same version as the other and then point to my fork.
gem 'some_gem', git: 'https://github.com/user/My-Fork.git'
Each of your dependencies will have a version constraint and your project can only use one version of each gem.
The answer to your specific question is that yes, you can control the version of an indirect dependency by specifying which version to use directly in your gemfile. However, this version must satisfy the version constraint of the direct dependency.
A brief example. Let's say your gemfile looks like this:
source 'https://rubygems.org/'
gem 'somegem', '~> 1.0'
And your gemfile lock looks something like this (note, some parts omitted for brevity):
GEM
remote: https://rubygems.org/
specs:
somegem (1.0)
json (~> 1.8)
json (1.8)
The Gemfile.lock indicates that somegem is dependent on json and that the json version must be greater than or equal to 1.8 but less than 2.0 (read more about the ~> operator here).
If you want to use lets say json version 1.9, you can modify your gemfile or use bundler commands to update the version used in the lock file.
E.g.
source 'https://rubygems.org/'
gem 'somegem', '~> 1.0'
gem 'json' , '~> 1.9'
In your specific case, if you have two dependencies that use conflicting versions of an indirect dependency, the gems will be incompatible. However, this example is meant to show that you can specify the version of an indirect dependency IF it meets the constraint specified by the direct dependency.
Rails uses Bundler to manage Ruby dependencies. An overview of the gemfile would be a good place to start learning how to manage your project's dependencies.
I'm working on a new project in Ruby, which I'm learning, and I need to install Sinatra gem and I'm getting the following error:
"Following gems were not installed: sinatra-sinatra (0.10.1): While
executing gem ... (Gem::UnsatisfiableDependencyError)
Unable to resolve dependency: 'sinatra-sinatra (= 0.10.1)' requires 'rack (>= 1.0)'"
Currently I'm using, RubyMine (Windows). Any help would be appreciated.
Thanks
The problem is not RubyMine, but some other dependency conflict in your app. The gem sinatra-sinatra requires Rack 1.0, there is probably another gem in your Gemfile that requires a greater or different version of the same gem.
Actually, I believe your problem can easily be fixed by using the proper gem. sinatra-sinatra is a very old gem, if you want to use the Sinatra framework the correct gem is sinatra. Update your Gemfile accordingly.
In you machine
gem install sinatra-sinatra
Check you Gemfile
gem 'sinatra-sinatra', '~> 0.10.1'
Delete the Gemfile.lock and bundle its once again.
I have updated all of my gems, including to Rails 3.2.8, prior to a new deployment. However, my application is now broken because something is trying to install gem "termios" version 0.9.4.
Apparently, 0.9.4 does not work on any computer or server I own. There are some newer versions, 0.9.6 specifically, but they are not posted in wherever bundler looks for gems.
There are some version on Github, but they have been mysteriously renamed "ruby-termios". Well, some gem in my Gemfile is not looking for ruby-termios. It's looking for termios. Failure.
How can I find out which gem is trying to install this so I can see if it can be whacked?
Check your Gemfile.lock - it has all the gems and their dependencies listed in it. As long as you've been able to install these gems in the past, you'll be able to tell where that dependency is coming from.
The gem command will dump out the tree of dependencies for you.
$ gem dependency
Or if you want to check just a specific gem.
$ gem dependency foo
This is a pretty basic question about how the bundler looks up gems.
While trying to revert to a previous version of a gem I'm using in my Rails application, I get the following bundle install error:
Could not find gem 'client_side_validations (= 3.2.0.beta.3) ruby' in https://github.com/bcardarella/client_side_validations.git (at master).
Source contains 'client_side_validations' at: 3.2.0.beta.6
Which is totally weird because I was on 3.2.0.beta.3 a few days ago and the bulder was happy.
I'm super curious to find out what versions of the gem are available though the url ('https://github.com/bcardarella/client_side_validations.git') to the bundler. How do I go about doing that?
Bundler pulls the source from the master branch and it gets the version of the gem here
I'm using the thumbs_up gem and on github there's a master branch (0.4.6) and an engine branch (0.3.2). When I require the gem in my Gemfile with
gem 'thumbs_up'
I see that version 0.4.6 was installed. I verify this is the right version running in my dev environment by doing bundle exec gem which thumbs_up and when I look at the VERSION file I see it's 0.4.6.
So when I look at the code I'm expecting to find an unvote_for method but it doesn't have one. Instead it has one called clear_votes. Now I'm confused because clear_votes is supposed to be in version 0.3.2 but as far as I can tell, I'm on version 0.4.6.
Any ideas what's going on here?
By default, the gem used is the latest available when running 'bundle install'. You can specify a version (or version constraints) in the Gemfile. To update the version of the gem used, you have to run bundle update <gemname>, and it will do so according to your gemfile.
About your problem : ensure that your server/console command is prefixed with bundle exec. You check also which versions of thumbs_up are installer on your system, and remove the version you don't need anymore.
You use Bundler so you can know which version of you gem is using in your Gemfile.lock. Bundler have and use only one version by gem.