Search code examples
ruby-on-railsrubyenvironment-variablesgemfile

how to manage gem path in development with team?


i've been having a problem working in a project with my team, and i want to know how you manage situations like this.

We're working in the same project, and the project has gems made by us, and we're working on those gems as well.

So our gemfile looks like:

# Person 1
gem "my_gem", '1.1', :path => '/Users/person1/apps/my_gem/'

# Person 2
gem "my_gem", '1.1', :path => '/Users/person2/apps/my_gem/'

# Person 3
gem "my_gem", '1.1', :path => '/Users/person3/apps/my_gem/'

The problem is that when we push to our remote with Git, we're having conflicts everytime (sounds logic). I tried to use environment variables with dotenv gem, doing something like:

# Person x
gem "my_gem", '1.1', :path => ENV["MY_PATH"]

I tried a lot, differents ways, using as reference many stackoverflow's posts... but doesn't work.


Solution

  • You could also agree on a relative path-structure? You could do something like

    gem "my_gem", :path => '../../apps/my_gem/'
    

    Personally I always use the path to develop against a gem, locally, but I always push the git reference to my collegues (because that also means that the code I am developing against --the gem, is released -- at least pushed to the repo).

    gem "my_gem", git: '[email protected]:username/my_gem.git'
    

    And in the Gemfile.lock (which we also push to repository) we see the revision so that when collegues install, or upon deploy we get the same version.