Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to deploy a rails project from windows to linux server with postgres?

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?

like image 217
ironsand Avatar asked May 11 '14 07:05

ironsand


1 Answers

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

  • if you scroll down pretty far there is a capistrano hack to autofix up the Gemfile.lock, might be worth trying

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

like image 90
house9 Avatar answered Oct 25 '22 14:10

house9