Search code examples
ruby-on-railsrubybundlersudorbenv

Using $ sudo bundle exec ... raises 'bundle: command not found' error


I have installed rbenv on an Ubuntu sever. I can cd into my application directory and run $ bundle without issue, however I need to run $ sudo bundle exec ... and this gets me an error:

bundle: command not found

Why is this and how can I fix it?


Solution

  • Dan Carley's rbenv-sudo looks like it will do what you want:

    rbenv-sudo is a plugin for rbenv that allows you to run rbenv-provided Rubies and Gems from within a sudo session.

    A more detailed explanation of how it works is provided in this article: Sudo Rbenv Me a Sandwich