RVM和独角兽部署
我的 RVM 以 root 身份安装。 当我尝试启动 unicorn 套接字时,它会打印
user@9001-3:~$ /etc/init.d/unicorn start
Starting myapp app: /usr/bin/env: ruby: No such file or directory
unicorn.
But if I type
user@9001-3:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/unicorn
path contains.
我的独角兽配置: https://gist.github.com/1010519
My RVM is installed as root.
When I'm trying to start unicorn socket, it prints
user@9001-3:~$ /etc/init.d/unicorn start
Starting myapp app: /usr/bin/env: ruby: No such file or directory
unicorn.
But if I type
user@9001-3:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/unicorn
path exists.
My unicorn config: https://gist.github.com/1010519
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
/etc/init.d/unicorn
不知道在哪里可以找到 Ruby,因为它是通过 RVM 管理的。通常,您的.bashrc
或类似文件会被执行并设置环境;这不会发生在初始化脚本中(或者可能由 root 执行的任何其他脚本)。解决方案是使用包装器。例如,要创建一个名为
system_ruby
的二进制文件来加载 RVM 的 1.9.2p180 环境并然后执行ruby
,请执行以下命令:了解更多信息和更多详细信息,请查看我的这个答案 ,它解决了类似的问题。
/etc/init.d/unicorn
doesn't know where to find Ruby because it's managed via RVM. Normally, your.bashrc
or similar file is executed and sets up the environment; this doesn't happen in init scripts (or likely anything else executed by root).The solution is to use wrappers. For example, to create a binary called
system_ruby
that loads up RVM's 1.9.2p180 environment and then executesruby
, execute the following:For more information and more details, check out this answer of mine, which addresses a similar problem.
符号链接也有效,
Symlink also works,
类型 :
which ruby
(显示 ruby bin 路径),然后输入:ln -s (change_to_ruby_path) /usr/bin/env/ruby
(为您的系统构建正确的访问权限)Type :
which ruby
(show the ruby bin path) then type this :ln -s (change_to_ruby_path) /usr/bin/env/ruby
(construct the correct access for your system)我遇到了同样的问题,这对我来说
I had the same problem and this for me