Rails 【低级问题】su -c 命令执行和直接执行的区别?

dothide · 2014年09月20日 · 最后由 beiersi 回复于 2014年09月25日 · 11049 次阅读

最近小弟部署了应用,发现一个奇葩的问题,在应用根目录直接使用bundle exec unicorn_rails -E production -D -c config/unicorn.rb 可以正常启动服务器 但是如果使用 su apps -c 'bundle exec unicorn_rails -E production -D -c config/unicorn.rb',就会报如下错误:

bundler: command not found: unicorn_rails
Install missing gem executables with 'bundle install'

真是费解啊,我已经配置好了 rvm,但始终没找到根本原因,求大神帮助

rvm 的问题吧,cd 到一个目录的时候,rvm 还会执行一些东西

项目根目录写个 .versions.conf su apps -c 'cd /path && bundle exec unicorn_rails -E production -D -c config/unicorn.rb'

或者

su apps -c 'cd /path && rvm 2.1.1@xxx do bundle exec unicorn_rails -E production -D -c config/unicorn.rb'

有一个 rvmsudo 命令

需要 登录 后方可回复, 如果你还没有账号请 注册新账号