LoginSignup
6
7

More than 5 years have passed since last update.

sudo bundle execを実行可能にする

Last updated at Posted at 2016-06-23

概要

Chef実行時など、bundleコマンドをsudoで実行したい場合の方法。

bundleコマンド(rbenv)は、ユーザー環境別にインストールされる。
そのため、sudoで実行すると、rootの環境変数を読みに行き、
sudo: bundle: command not foundとなる。
そこで、rbenv-sudoという方法で実行するために下記をインストールする。

rbenv-sudoのインストール

Github: rbenv-sudo

$ git clone https://github.com/dcarley/rbenv-sudo.git ~/.rbenv/plugins/rbenv-sudo

これで、下記のコマンドでsudoでbundleコマンドの実行が可能になる。

$ rbenv sudo bundle exec [command]

visudoを編集する方法もあるけど、こっちのほうが楽。

以上。

[参考]
http://qiita.com/snaka/items/1fbc655a3fc931dd2fff
https://blog.dakatsuka.jp/2015/02/19/rbenv-sudo.html

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7