0

我正在使用 Capistrano 在 Slicehost 上部署一个 rails 应用程序。部署过程的一部分涉及重建 gem 并安装它。

通过 git scm 将代码部署到服务器工作正常,但由于某种原因,当我尝试执行...

run 'gem build /my/app/folder/my.gemspec'

...在 deploy.rb 中的一个单独的任务中,一切顺利。我收到一个奇怪的错误,告诉我 gemspec 中的文件不是文件...

ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
[ ... , "public/images/admin/navigation_shadow.png", "public/images/admin/new_layout.png", "public/images/admin/buttons_background.png", "public/images/admin/expand.png", "public/images/admin/status_spinner
** [out :: MY.IP.ADD.RESS ] .gif", "public/images/admin/draft_page.png", "public/images/admin/vertical_tan_gradient.png", "public/images/admin/status_top_right.png", "public/images/admin/snippet.png", "public/images/admin/spacer.gif", "public/images/admin/status_bottom_right.png", "public/images/admin/spinner.gif", "CONTRIBUTORS", "script", "script/server", "script/breakpointer", "script/generate", "script/dbconsole", "script/about", "script/spec", "script/runner", "script/process", "script/process/reaper", "script/process/inspector", "script/process/spinner", "script/process/spawner", "script/version", "script/plugin", "script/console", "script/autospec", "script/destroy", "script/cucumber", "script/spec_server", "script/performance", "script/performance/profiler", "s ** [out :: MY.IP.ADD.RESS ] cript/performance/request", "script/performance/benchmarker", "script/extension", "LICENSE", "CHANGELOG", ".gitignore", "bin", "my.gemspec", "config", "config/database.mysql.yml", "config/environments", "config/environments/test.rb", "config/environments/production.rb", "config/environments/development.rb", "config/database.yml" ] are not files

这很奇怪,因为当我 ssh 进入盒子并手动执行时,相同的命令可以完美运行,而当我这样做时......

sh -c 'gem build /my/app/folder/my.gemspec'

这就是 capistrano 包装远程命令行调用的方式,当我手动执行时也可以正常工作。

甚至尝试将 Kernel.system() 调用包装在另一个 ruby​​ 文件中并从 deploy.rb 调用它,但仍然遇到同样的问题。疯狂的。

想知道它是否与

** [out :: MY.IP.A.DRES]

以明显随机间隔添加到输出中的字符串。

4

1 回答 1

0

“它工作正常”可能并不完全正确,你确定它不输出 STDERR 吗?

out::IP addr这个东西有点奇怪,不正常;您还应该考虑您的 PATH 是否设置正确,这是 PTY 和 TTY 之间的区别。

最简单的方法(但并不完美)是:

run('echo $PATH')

相对

ssh my.server.addr 'sh -c \'echo $PATH\''

(后者是 Cap 实际上所做的。)

您可能还想尝试:

run("cd /my/app/folder/ && gem build my.gemspec")

^ 其中之一对您有用。

于 2009-12-01T06:59:57.210 回答