How do I specify local .gem files in my Gemfile?

I have a couple of gem files which I install via gem install xx.gem. Can I tell Bundler to use them? Or do I have to specify the source path?

How can I specify a local gem in my Gemfile?

I’d like Bundler to load a local gem. Is there an option for that? Or do I have to move the gem folder into the .bundle directory?

RoR: Bundler: How do I set up a gem in my gemfile with build options?

standard is this: gem mysql, 2.7 but.. when I install this gem in the terminal, I have to run this command: export ARCHFLAGS=-arch x86_64 ; sudo gem install –no-rdoc –no-ri mysql -v 2.7 — –

How do I copy files from a gem to the local directory

I’m authoring a gem and would like to copy template files that are packaged in my gem into the local directory that the gem is being called from.

What to do after removing a gem from the Gemfile?

I removed a gem ‘mygem’ from the Gemfile, but just now I realized it’s still installed. So how do I tell bundler to rescan the Gemfile and update Gemfile.lock, without updating every gem? Coming from

Can I edit the gem installed using ‘gem install’ or from my gemfile?

On my server (or laptop for that matter) whenever I install a gem using: gem install mygemname or in my gemfile: gem ‘mygemname’ It will install on the computer to some folder on my computer. Can I

How do I specify different versions of a gem for development and production

I need to have different versions of a gem for development and production, so I put the following in my gemfile. group :development, :test do gem ‘rspec-rails’, ‘2.11.0’ gem ‘bcrypt-ruby’, ‘3.1.2’ end

How does Bundler utilize Gemfile.lock to load gems?

I’m a bit confused at the moment as to how bundler handles the files Gemfile and Gemfile.lock. Inside my Gemfile, I have the following group :development do gem ‘ruby-debug19’, :require => ‘ruby-d

Specify a plugin as gem from github in Gemfile

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

How do I know if I have a gem on my local machine?

I have the Rails gem and the data_mapper gem installed on my local machine (macbook). When I am in my terminal, I can type which rails and it give me a directory like /Users/andyhuynh/.rvm/gems/ruby-1

Thinking_sphinx Search method doesn’t work when I include ransack gem in my Gemfile

I included thinking_sphinx gem in my project. Article.search Bla-bla-bla works fine. But when I include ransack gem in my Gemfile I get the error: NoMethodError: undefined method `with_indifferent_a

Answers

By default Bundler will check your system first and if it can’t find a gem it will use the sources specified in your Gemfile.

You can force bundler to use the gems you deploy using “bundle package” and “bundle install –local”

On your development machine:

bundle install

(Installs required gems and makes Gemfile.lock)

bundle package

(Caches the gems in vendor/cache)

On the server:

bundle install --local

(–local means “use the gems from vendor/cache”)

Seems bundler can’t use .gem files out of the box. Pointing the :path to a directory containing .gem files doesn’t work. Some people suggested to setup a local gem server (geminabox, stickler) for that purpose.

However, what I found to be much simpler is to use a local gem “server” from file system: Just put your .gem files in a local directory, then use “gem generate_index” to make it a Gem repository

mkdir repo
mkdir repo/gems
cp *.gem repo/gems
cd repo
gem generate_index

Finally point bundler to this location by adding the following line to your Gemfile

source "file://path/to/repo"

If you update the gems in the repository, make sure to regenerate the index.

This isn’t strictly an answer to your question about installing .gem packages, but you can specify all kinds of locations on a gem-by-gem basis by editing your Gemfile.

Specifying a :path attribute will install the gem from that path on your local machine.

gem "foreman", :path => "/Users/pje/my_foreman_fork"

Alternately, specifying a :git attribute will install the gem from a remote git repository.

gem "foreman", :git => "git://github.com/pje/foreman.git"

# ...or at a specific SHA-1 ref
gem "foreman", :git => "git://github.com/pje/foreman.git", :ref => "bf648a070c"

# ...or branch
gem "foreman", :git => "git://github.com/pje/foreman.git", :branch => "jruby"

# ...or tag
gem "foreman", :git => "git://github.com/pje/foreman.git", :tag => "v0.45.0"

(As @JHurrah mentioned in his comment.)

i would unpack your gem in the the vendor folder

gem unpack your.gem /path_to_app/vendor/gems/

then add the path on the Gemfile, like this

gem 'your', '2.0.1', :path => 'vendor/gems/your'

I found it easiest to run my own gem server using geminabox

See these simple instructions.