3

我已经在 Ubuntu 服务器上安装了 rbenv。我可以 cd 进入我的应用程序目录并$ bundle毫无问题地运行,但是我需要运行$ sudo bundle exec ...,这给我一个错误:

捆绑包:找不到命令

为什么会这样,我该如何解决?

4

4 回答 4

5

不完全确定,但也许这对你有用:

sudo -i -u $USER bundle exec... 

或者

sudo -i -u username_with_correct_env bundle exec... 
于 2013-02-01T20:23:19.063 回答
4

Dan Carley 的rbenv-sudo看起来会做你想做的事:

rbenv-sudo 是一个用于 rbenv 的插件,它允许您在 sudo 会话中运行 rbenv 提供的 Rubies 和 Gems。

本文提供了有关其工作原理的更详细说明:Sudo Rbenv Me a Sandwich

于 2013-02-01T14:13:04.227 回答
3

您收到错误的原因已经得到解决。但我能够通过说:

sudo /full/path/to/bundle exec ...

就我而言,我使用的是 rbenv,所以我必须:

sudo /home/renier/.rbenv/shims/bundle exec ...

那行得通。要让 sudo 不要求输入密码,您需要为此配置/etc/sudoers文件。请参阅https://serverfault.com/a/160587

于 2014-06-17T16:54:32.573 回答
1

要在不使用 rbenv 或 rvm 的情况下执行此操作,请执行以下操作:

sudo -E bundle exec ...

   -E          The -E (preserve environment) option will override the env_reset option in sudoers(5).  It is only available when
               either the matching command has the SETENV tag or the setenv option is set in sudoers(5).  sudo will return an error
               if the -E option is specified and the user does not have permission to preserve the environment.
于 2015-12-22T22:12:06.893 回答