flyte321
flyte321

Reputation: 420

Specify dependent gem version

due to server restrictions I do not have the permission to install specific gem versions on production environment.

On development I have installed delayed_job_active_record (0.3.3), which depends on delayed_job, bundler uses the newest version 3.0.4. Unfortunately on production there's only v. 3.0.3 installed. Therefore I edited the gemfile.lock manually. It works now on production, but I assume, this is absolutely not the right way to do. So, how can I specify a version of a dependent gem?

Upvotes: 0

Views: 471

Answers (1)

Brian Campbell
Brian Campbell

Reputation: 333304

Just declare in your Gemspec that you depend on "delayed_job", "3.0.3". Bundler will figure out a set of dependencies that satisfies all of the requirements, if possible. If delayed_job_active_record depends on delayed_job version 3 or greater (say), and you depend on specifically 3.0.3, then Bundler will figure out that version 3.0.3 is sufficient to meet both of those requirements.

Also, you should be able to bundle the appropriate versions of the gems with your application. One of the main points of Bundler is to allow you to do this; gather all of the gems you depend on into your application, so you are not at the mercy of what is installed on your host. You run bundle install --deployment, and it will copy all of your gems into vendor/bundle directory. See the docs on deploying with Bundler for details.

Upvotes: 2

Related Questions