When I tried to deploy a rails project from windows local environment to linux(CentOS6.5) server, I got a error from capistrano 3.
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile.
I had a gem 'pg'
in Gemfile
though. I found a line that cause the problem in Gemfile.lock
.
pg (0.17.1-x86-mingw32)
When I removed Gemfile.lock
and run bundle install
in another linux virtual host, the problem was solved. But I couldn't find out the way how to solve it in windows.
As far as I understand, I must send Gemfile.lock
to server if I use Capistrano
.
And Gemfile.lock
created in windows is incompatible with one created in linux or osx.
Is there no way to deploy from windows to linux server with postgres by using capistrano?
Looks like this has been an issue with bundler for many years: current open 'issue' on github: https://github.com/bundler/bundler-features/issues/4
original issue (4 years old) : https://github.com/bundler/bundler/issues/646
Looks like Heroku actually removes Gemfile.lock if it references Windows specific gems
From: https://devcenter.heroku.com/articles/bundler-windows-gemfile
Be as specific in your Gemfile as you possibly can when developing on Windows. If only one developer on your team has a Windows machine, consider not checking in their Gemfile.lock changes or manually bundle installing and committing on a non-Windows machine before deploying.
And https://ninefold.com/ has similar recommendation: hacking the Gemfile.lock
https://help.ninefold.com/hc/en-us/articles/201335424-Deploying-a-Windows-Created-Rails-App
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With