Question

I have a single app directory for development: d:/some/dir/myapp. I have a single repository called sample-repo, but it has two branches: develop and master.

My app's Gemfile uses the sample-repo repository's environment-specific branch:

RAILS_ENV = ENV['RAILS_ENV'] || 'development'
gem 'sample-repo',  git: "git@bitbucket.org:MyUserName/sample-repo.git", 
                branch: "#{ RAILS_ENV.to_sym == :production ? :master : :develop }"

My web host has two separate directories; one for development and the other for production. Each are updated via a git pull from their respective branches (development => develop, production => master).

This is a problem because when I run bundle update on my development machine, the Gemfile.lock contains the sample-repo gem, specifying the develop branch. I then git push the Gemfile.lock to my repo (both develop and master), and now the master repo contains a Gemfile.lock that specifies the develop branch!

i.e., the problem is that there is only one Gemfile.lock file to go around between the develop and master branches.

Was it helpful?

Solution

This answer solved my problem. I created a file called .rails-env which contains a simple string specifying the environment bundler should use. This file must be kept out of the repository. If not present, bundler defaults to development.

The second part of the problem was that I had to adjust my deployment procedure. I created a small script that runs bundle update under the development environment and waits for a key press before doing the same for production. Once the development Gemfile.lock files are generated, I push the changes to my develop repository branches. After it runs through production, I push to master.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top