CruiseControl.rb 路径

发布于 2024-08-20 23:02:17 字数 716 浏览 6 评论 0原文

我试图让 CruiseControl.rb 在构建期间运行 rcov。目前它失败并出现以下错误:

sh: rcov: not found 

由于我登录时可以从 shell 运行 rcov,因此我认为这是一个 PATH 问题。 (此外,我可以从 shell 运行 rake test:rcovrake Cruise 而不会出现错误)。我在 Cruise.rake 中添加了一条 p 'echo $PATH' 语句(使用正确的反引号来执行命令;感谢 Markdown),并发现路径确实不正确:

"/usr/local/bin:/usr/bin:/bin\n"

rcov 可执行文件位于 / var/lib/gems/1.8/bin/rcov,难怪CC.rb找不到它。

但是,我不知道如何正确设置路径。我在 .profile 的底部设置了此设置:

PATH="$PATH:/var/lib/gems/1.8/bin/"

这使它可以交互工作,但 CC 不会拾取它。

我在 Passenger Phusion 下运行 CruiseControl.rb (因此在 apache 下)。我已经检查了尽可能多的文件,但对我来说没有什么看起来像路径。

我可以在哪里设置路径和/或确定在哪里设置路径?

I'm trying to get CruiseControl.rb to run rcov during a build. It's currently failing with the following error:

sh: rcov: not found 

Since I can run rcov from the shell when I log in, I figure that this is a PATH problem. (Additionally, I can run both rake test:rcov and rake cruise from the shell without errors). I added a p 'echo $PATH' statement (with the correct backticks to execute the command; thanks Markdown) to my cruise.rake and discovered that the path was indeed incorrect:

"/usr/local/bin:/usr/bin:/bin\n"

The rcov executable is at /var/lib/gems/1.8/bin/rcov, so it's no wonder that CC.rb can't find it.

However, I can't figure out how to set the path properly. I have this set at the bottom of my .profile:

PATH="$PATH:/var/lib/gems/1.8/bin/"

This is what makes it work interactively, but it's not being picked up by CC.

I'm running CruiseControl.rb under Passenger Phusion (and thus under apache). I've checked as many files as I can think of, but nothing looks like a PATH to me.

Where can I set the path and/or determine where the path is being set?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狼亦尘 2024-08-27 23:02:17

首先,你的.profile是错误的。您需要先导出环境变量,然后其他进程才能看到该环境变量。像这样:

export PATH=....

PATH=...
export PATH

非导出的环境变量值只能从同一 shell 进程内访问。

但这不是您的问题,因为您正在运行 Phusion Passenger。 .profile 仅由 shell 读取,并且由于 Apache 不是从 shell 启动,而是从系统 init 进程启动,因此您在 .profile 中输入的任何内容都会被忽略。对于 Phusion Passenger,您必须使用 mod_env 和 SetEnv 指令设置 PATH,如下所示:

<VirtualHost *:80>
    ServerName something.test
    DocumentRoot /somewhere/to/cruisecontrol/public
    SetEnv PATH /usr/bin:/usr/local/bin:/bin:/var/lib/gems/1.8/bin    # <---- add this
</VirtualHost>

First of all, your .profile is wrong. You need to export the environment variable before it's visible to other processes. Like this:

export PATH=....

or

PATH=...
export PATH

Non-exported environment variable values can only be accessed from within the same shell process.

But that's not your problem since you're running Phusion Passenger. .profile is only read by the shell, and since Apache is not started from the shell, but from the system init process, whatever you put in .profile is ignored. For Phusion Passenger you have to set your PATH with mod_env and the SetEnv directive, like this:

<VirtualHost *:80>
    ServerName something.test
    DocumentRoot /somewhere/to/cruisecontrol/public
    SetEnv PATH /usr/bin:/usr/local/bin:/bin:/var/lib/gems/1.8/bin    # <---- add this
</VirtualHost>
感悟人生的甜 2024-08-27 23:02:17

我终于一切正常了。

首先,@Hongli 关于在 Apache 中设置 PATH 的建议是正确的; SetEnv 能够设置基于 Passenger 的站点的 PATH。

在深入研究 CruiseControl.rb 代码后,我发现了第二个问题(我在对 Hongli 答案的评论中提到了这个问题)。在启动过程中,CC.rb 为每个项目分叉一个构建器进程。每个进程在创建时都会获取其父进程的 PATH。我的问题是我正在重新启动 Apache,但无论出于何种原因,这都没有重新启动构建器进程。因此,构建者没有获得我的 PATH 更新,因此似乎也没有从 Apache 获得 PATH。这让我相信他们的路径是在其他地方设置的——但事实并非如此。

重新启动系统就可以了;新的构建者从 Apache 获得了新的 PATH,现在一切都按预期工作。可能还有其他方法可以重新启动构建器,但我还没有研究过。

I finally got everything working.

Firstly, @Hongli's advice about setting the PATH within Apache was correct; SetEnv was able to set the PATH for the Passenger-based site.

After digging around through the CruiseControl.rb code I discovered the secondary problem (to which I alluded in my comments to Hongli's answer). During startup, CC.rb forks a builder process for each project. Each process gets the PATH of its parent at the time it was created. My problem was that I was restarting Apache, but this wasn't restarting the builder processes for whatever reason. The builders thus didn't get my PATH updates, and so appeared to not get the PATH from Apache. That led me to believe that their PATHs were set somewhere else -- but this is not the case.

Rebooting the system did the trick; the new builders got the new PATH from Apache and now everything works as expected. There's probably some other way to restart the builders, but I haven't investigated that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文