是否可以使用postgres将一个rails项目从windows部署到linux服务器?

iro*_*and 6 ruby windows postgresql ruby-on-rails

当我尝试将rails项目从windows本地环境部署到linux(CentOS6.5)服务器时,我从capistrano 3收到错误.

Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile.
Run Code Online (Sandbox Code Playgroud)

我有一个gem 'pg'Gemfile虽然.我发现了导致问题的一条线Gemfile.lock.

pg (0.17.1-x86-mingw32)

当我删除Gemfile.lock并运行bundle install另一个Linux虚拟主机时,问题就解决了.但我无法找到如何在Windows中解决它的方法.

据我了解,Gemfile.lock如果我使用,我必须发送到服务器Capistrano.而Gemfile.lock在Windows中创建是一个在Linux或OSX创建不兼容.

有没有办法使用capistrano从windows部署到带有postgres的linux服务器?

hou*_*se9 1

看来这多年来一直是捆绑器的一个问题:github 上当前开放的“问题”:https ://github.com/bundler/bundler-features/issues/4

原始问题(4 年前):https ://github.com/bundler/bundler/issues/646

  • 如果你向下滚动很远,有一个 capistrano hack 可以自动修复 Gemfile.lock,可能值得尝试

看起来 Heroku 实际上会删除 Gemfile.lock(如果它引用了 Windows 特定的 gem)

来自: https: //devcenter.heroku.com/articles/bundler-windows-gemfile

在 Windows 上进行开发时,请尽可能在 Gemfile 中具体说明。如果您的团队中只有一名开发人员拥有 Windows 计算机,请考虑在部署之前不要签入他们的 Gemfile.lock 更改或在非 Windows 计算机上手动捆绑安装和提交。

https://ninefold.com/有类似的建议 hacking the Gemfile.lock

https://help.ninefold.com/hc/en-us/articles/201335424-Deploying-a-Windows-Created-Rails-App