gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 13:46:56 26 4
gpt4 key购买 nike

当我尝试从 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com