Hroft
Hroft

Reputation: 4187

Make ruby script use local gems, instead of common

I'm deploying my rails project to production server. There is only 1.9.3 version of ruby (I developed on 2.1.2) so there is few compatibility problems in gems versions. More over, I downloaded one of gems to vendor/gem_name and made necessary fixes in its sources, so I need to use exactly my version of that gem and, as you understand, It's not possible to update it.

in Gemfile

require 'gem_name', :path => 'vendor/gem_name'

So after cloning project to server I run

bundle install --path vendor/bundle

and it created bundle directory in vendor folder with gems versions, needed to me, inside it.

After that I tried to run fetching script to fill db with some data by command

ruby *_fetch.rb

inside *_fetch.rb:

require 'gem_name'

And it fails with error

You have already activated gem_name older_version, but your Gemfile requires gem_name newest_version. Using bundle exec may solve this. (Gem::LoadError) from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'

So how could I specify script to require my edited local gem?

Upvotes: 1

Views: 834

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51151

Run it with bundle exec That's exactly what bundle exec is for.

Upvotes: 3

Related Questions