ruby-on-rails - 是否可以使用 postgres 将 Rails 项目从 Windows 部署到 Linux 服务器?

标签 ruby-on-rails ruby windows postgresql

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

Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile.

虽然我在Gemfile 中有一个gem 'pg'。我在 Gemfile.lock 中找到导致问题的行。

pg (0.17.1-x86-mingw32)

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

据我所知,如果我使用 Capistrano,我必须将 Gemfile.lock 发送到服务器。 在 windows 中创建的 Gemfile.lock 与在 linux 或 osx 中创建的不兼容。

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

最佳答案

看起来这多年来一直是 bundler 的问题:github 上当前 Unresolved “问题”:https://github.com/bundler/bundler-features/issues/4

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

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

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

发件人: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.

https://ninefold.com/有类似的建议:破解 Gemfile.lock

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

关于ruby-on-rails - 是否可以使用 postgres 将 Rails 项目从 Windows 部署到 Linux 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23590287/

相关文章:

ruby-on-rails - rails : How to pass data to Bash Script

ruby-on-rails - Rails 路线和站点性能

ruby-on-rails - iCalendar 的 Ruby on Rails 命名空间问题

php - 使用 WEBrick 为 PHP Web 应用程序提供服务

java - 无法运行程序 "...\keytool.exe": CreateProcess error=2

windows - 在 Windows 中查找文件夹的实际大小

ruby-on-rails - Google App Engine 上 jRuby on Rails 的 Java 错误

ruby-on-rails - 邮箱程序 : how to display a specific conversation?

ruby - Sinatra 使用 shotgun gem - 未定义的方法默认

c++ - 为什么当我运行带有 d^ 参数的程序时,Windows 命令提示符显示 "More? "?