I am working on a rails gem that has dependency on the following
gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'
How can I add this in the gem spec as a dependency? Specifically I need to specifiy the path and branch in the dependency.
You definitely want to use Bundler then. You would put exactly what you have into the Gemfile file. Go checkout the link to Bundler I left below.
-- older info --
For jeweler you would add something like this:
gem.add_dependency 'authlogic', '> 1.0', '<= 2.0'
But you might be better off using Bundler. It's not just for rails: http://gembundler.com/
You need generate the gem. Publish it and after use this gem deploy.
Related
I am creating a gem, which has a dependency on another published gem.
In my_gem.gemspec, I have added the dependency to the other gem:
gem.add_dependency "other_gem", "~> 1.0.0"
Now, I found a feature that can be tweaked in other_gem, so I forked the repository, made my changes and committed it to the fork (It has not been pulled into the original repository).
My question is how do I tell my_gem to lookup other_gem locally? The below code snippet is not valid, as :path is not an option in add_dependency call, as mentioned in Gem Specification Reference:
gem.add_dependency "other_gem", "~> 1.0.0", :path => '/path/to/local/other_gem
Locally it's much easier: while you're doing development, you can include:
gem "other_gem", :path => '/path/to/local/other_gem'
or
gem "other_gem", :git => "git#github.com:/your_github/other_gem.git"
in your gemfile, as this should override the gemspec
Locally it is not likely possible to give path to the gem dependency because if you are doing so that means you are imposing a restriction to the self made gem that it is depending locally to any other gem.
This is not desirable as when you will upload it, this will not work. So the solution is to add remote dependency in your own plugin's gemspec.
See my SO post for the same here.
I would create and install a new other_gem-version, e.g. '1.0.0.Subash_fix' and use it as
gem.add_dependency "other_gem", "= 1.0.0.Subash_fix"
When there is a new official version of the gem with your patch you switch back to the official one:
gem.add_dependency "other_gem", "~> 1.0.1"
I'm using 'rails3-jquery-autocomplete' gem, but it doesn't have multi column search, but there is a fork that does it ( more details at: https://github.com/crowdint/rails3-jquery-autocomplete/pull/95).
Now I need to deploy to Heroku but it will install the official gem. How can I edit it? Or if it's not possible, how can I import a gem to the application?
Thanks.
you can use the fork by specifying the :git path in your Gemfile declaration
something like
gem "_GEM_NAME_", :git => "git://git/repository.git"
your other option would be to just vendor the gem inside your into a directory like vendor/gems/_gem_name and then you could use the :path option as well
gem "_GEM_NAME_", :path => "vendor/gems/_gem_name"
I've been trying (in vain) to get the latest version of the Sunspot gem (currently 2.0.0.pre.111215, incorporating Solr 3.5) working with Solr Cell.
Currently I am using the older version of Sunspot in combination with Solr Cell provided by the following plugin - https://github.com/chebyte/sunspot_cell.
My Gemfile for this configuration is as follows;
gem 'sunspot', '1.2.1'
gem 'sunspot_rails'
Unfortunately this older combination of Solr/Solr cell does not work with many newer PDF files. The recommended solution by Apache is to upgrade to the latest version of both.
The Sunspot Solr Cell bolt-on doesn't seem to be very well supported. The most recently updated version has been switched from a Plugin to a Gem, but I still can't get it to work with the latest version of the Sunspot Gem. https://github.com/zheileman/sunspot_cell
Does anyone know the correct Gemfile configuration to get the elements to play nicely together? The closest I have is this.
gem 'sunspot_cell', :git => 'git://github.com/zheileman/sunspot_cell.git'
gem 'sunspot', :git => "git://github.com/sunspot/sunspot.git"
gem 'sunspot_rails', :git => "git://github.com/sunspot/sunspot.git", :require => "sunspot_rails"
group :development, :test do
gem 'sunspot_solr', :git => "git://github.com/sunspot/sunspot.git"
end
When I run any rake task I get the following error.
uninitialized constant Sunspot::RSolr
If I comment the sunspot_cell gem out temporarily, I can get Rake tasks to run but actual searching fails.
I've tried manually using the Solr jar files in this gem instead of the ones bundled in sunspot_solr but also without success.
After a bit of trial and error, the answer to this turned out to be easier than I had hoped. The gems were apparently specified in the wrong order. I didn't realise it made any difference. I changed the order so that sunspot_cell was last and it burst into like. Magic! (almost).
gem 'sunspot', :git => "git://github.com/sunspot/sunspot.git"
gem 'sunspot_rails', :git => "git://github.com/sunspot/sunspot.git", :require => "sunspot_rails"
gem 'sunspot_cell', :git => 'git://github.com/zheileman/sunspot_cell.git'
Glad to know you already fixed it.
This is my current setup. A pretty big mess of gems, I know =)
gem 'rsolr', :git => 'git://github.com/mwmitchell/rsolr', :branch => "38b5b69a0d63cdf85560806c06f3187ea4339f5a" # 1.0.6 plus the timeout patch
gem 'sunspot'
gem 'sunspot_solr'
gem 'sunspot_rails'
gem 'sunspot_index_queue'
gem 'sunspot_cell', :git => 'git://github.com/zheileman/sunspot_cell.git', :branch => "bc8ac18de1410b3e29af89c4d028acc6deba1e1c"
I have a git submodule of git://github.com/rails/rails in vendor/rails of my Rails 3 app. This is where an unpacked/vendorized Rails would go prior to 3.0.
How do I instruct my Gemfile that vendor/rails is the correct location, and not my system-wide rails install?
So, some people have noted that you can do simply:
gem 'rails', :path => "vendor/rails"
You can also include a version number, e.g.,
gem 'rails', '3.0.3', :path => "vendor/rails"
Both of these depend on what you actually have in vendor/rails. For example, if I do git checkout v3.0.3 in vendor/rails, both of these will work fine on their own (3.0.3 is the current).
But if I use a beta instead, I seem to need to add some additional dependencies:
gem 'rails', :path => "vendor/rails"
gem 'arel', :git => 'git://github.com/rails/arel.git'
gem 'rack', :git => 'git://github.com/rack/rack.git'
I could also extract these into vendor as git submodules, I suppose, and again use :path.
Do be aware that rack comes from rack/rack on github, not rails/rack. The latter is a fork and hasn't been updated since 2009. I made this mistake and spent hours fixing it.
If you've got older versions of rails installed on your machine, you may also need to take care to use script/rails instead of the rails command.
Isn't it just gem 'rails', '3.0.3', :path => "vendor/rails" in your Gemfile?
Use this line in your Gemfile:
gem 'rails', :path => "vendor/rails"
I am trying to use this forked version of the searchlogic gem. In my gemfile, I have
gem "searchlogic", :git => "http://github.com/railsdog/searchlogic.git"
when I do bundle install, I get this error:
Could not find gem 'searchlogic (>= 0, runtime)' in http://github.com/railsdog/searchlogic.git (at master).
Source does not contain any versions of 'searchlogic (>= 0, runtime)'
What is causing this error? Thanks for reading.
It's because your fork not define searchlogic gem by rd_searchlogic gem. So use in your Gemfile :
gem "rd_searchlogic",
:git => "rd_searchlogic.gemspec",
:require => "searchlogic"
Use:
gem 'rd_searchlogic', :git => 'https://github.com/railsdog/searchlogic.git', :require => 'searchlogic'
The .gemspec of your fork might contain a different name to that of the gem on RubyGems, for example when I forked active_merchant on GitHub their .gemspec file had:
s.name = 'activemerchant'
but the gem is defined as active_merchant on RubyGems so I changed my Gemfile from:
gem "active_merchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"
to:
gem "activemerchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"
note the lack of _.
All worked perfectly after that. This may be an obscure case, but hope it helps someone!
It doesn't look like that gem has been upgraded for Rails3. From the issues listed in Github, it seems that searchlogic is heavily dependent on ActiveRecord2 and may not be easily upgraded for Rails 3. It may be worth looking into an alternative.
Will searchlogic work with Rails 3?
http://github.com/binarylogic/searchlogic/issues/issue/65