Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 895
Undistraction Avatar asked Oct 21 '25 01:10

Undistraction


2 Answers

Not entirely sure, but maybe this would work for you:

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

or

sudo -i -u username_with_correct_env bundle exec... 
like image 97
rainkinz Avatar answered Oct 23 '25 16:10

rainkinz


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

like image 41
Chris Salzberg Avatar answered Oct 23 '25 14:10

Chris Salzberg