【问题标题】:Deploying Ruby on rails on Deamhost fails在 Deamhost 上部署 Ruby on rails 失败
【发布时间】:2011-01-23 01:47:21
【问题描述】:

我正在尝试将一个简单的 Ruby on Rails 应用程序部署到 dreamhost,但我收到了与 bundle 命令相关的错误。这是错误:

    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
  * executing "find /home/USER-NAME/MY-DOMAIN/releases/20110123014150/public/images /home/USER-NAME/MY-DOMAIN/releases/20110123014150/public/stylesheets /home/USER-NAME/MY-DOMAIN/releases/20110123014150/public/javascripts -exec touch -t 201101230141.52 {} ';'; true"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
    triggering after callbacks for `deploy:update_code'
  * executing `bundle:install'
  * executing "ls -xt /home/USER-NAME/MY-DOMAIN/releases"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
  * executing "bundle install --gemfile /home/USER-NAME/MY-DOMAIN/releases/20110123014150/Gemfile --path /home/USER-NAME/MY-DOMAIN/shared/bundle --deployment --quiet --without development test"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
*** [err :: bullseye.dreamhost.com] sh: bundle: command not found
    command finished
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/USER-NAME/MY-DOMAIN/releases/20110123014150; true"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
failed: "sh -c 'bundle install --gemfile /home/USER-NAME/MY-DOMAIN/releases/20110123014150/Gemfile --path /home/USER-NAME/MY-DOMAIN/shared/bundle --deployment --quiet --without development test'" on bullseye.dreamhost.com

这是我的 deploy.rb 文件。

require 'bundler/capistrano'

set :user, "MY-USERNAME"
set :password, "MY-PASSWORD"
set :domain, 'bullseye.dreamhost.com'  # Dreamhost servername where your account is located 
set :project, 'blog'  # Your application as its called in the repository
set :application, 'MY-DOMAIN'  # Your app's location (domain or sub-domain name as setup in panel)
set :applicationdir, "/home/#{user}/#{application}"  # The standard Dreamhost setup

# version control config
set :scm_username, 'MY-SVN-USERNAME'
set :scm_password, 'MY-SVN-PWD'
set :repository, "http://MY-SVN-URL/01/blog/"

# roles (servers)
role :web, domain
role :app, domain
role :db,  domain, :primary => true

# deploy config
set :deploy_to, applicationdir
set :deploy_via, :export

# additional settings
default_run_options[:pty] = false  # Forgo errors when deploying from windows

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

我在Bundle install failing when deploying a Rails 3 app to Dreamhost with Capistrano 发现了一个类似的问题,但解决方案不起作用。有人对我的情况可能发生什么有任何想法吗?

【问题讨论】:

  • 也许 'bundler' 不在您运行这些命令时获得的 PATH 中?作为第一个开始,which bundler 在您刚刚 ssh 时是否返回任何内容?如果bundler 在交互式登录shell 的PATH 中,您可能需要移动命令以将PATH 设置为不同的bash 启动文件,如bash(1) 手册页的INVOCATION 部分所述。 (这是一个部分的野兽,但请尝试~/.bashrc~/.bash_profile~/.profile。)
  • @sarnold,感谢您的提示,但我无法让它发挥作用。但是我确实想通了,请参阅下面的答案。

标签: ruby-on-rails-3 deployment capistrano bundler dreamhost


【解决方案1】:

我最终明白了这一点。我所做的是

  • ssh进入dreamhost服务器并执行which bundle命令
  • 从 ssh 会话执行 echo $PATH 命令
  • 编辑 config/deploy.rb 并将两个字符串与 : 组合并放在 default_environment PATH 值内,见下文

    设置:默认环境,{ 'PATH' => "'/usr/lib/ruby/gems/1.8/bin//bundle:/home/sayed3/.gems/bin:/usr/lib/ruby/gems/1.8/bin/:/usr/本地/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games'" }

一旦我这样做了,它就能够成功地执行 bundle 命令,但后来我开始遇到一些其他问题。我最终决定使用我在其他地方托管的 VPS,但我敢肯定,如果我花更多的时间,我就能弄明白。

【讨论】:

  • default_environment["PATH"] = "$PATH:/usr/lib/ruby/gems/1.8/bin/" 是我添加的
【解决方案2】:

除了添加捆绑路径,如上所述,我还必须将以下行添加到我的 config/deploy.rb 以强制 capistrano 使用 bash,而不是默认的shell,在dreamhost上,它是破折号:

set :shell, '/bin/bash'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    • 2012-07-26
    • 1970-01-01
    • 2012-01-07
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    相关资源
    最近更新 更多