When installing Bundler, the Ruby package manager, or when installing a Gem using Bundler, you may encounter various permission errors or installation failures.
A permission error may occur when running gem install bundler
. This is because it attempts to install in the system area by default. To avoid this problem, you can install it in the user area as sudo gem install bundler -n /usr/local/bin/
.
In addition, you can avoid problems later by matching the version of bundler in the Gemfile.lock
with the version to be installed. For example, sudo gem install bundler -n /usr/local/bin/ -v 1.17.3
.
On the other hand, a permission error may also occur when executing bundle install
. This is because it tries to install the Gem in the system (global) area by default. To solve this problem, use bundle install --path vendor/bundle
to specify that Gem should be installed in the local directory of the project.
However, in some cases, bundle install --path vendor/bundle
may fail. In particular, if you get an error like “An error occurred while installing http_parser.rb (0.6.0), and Bundler cannot continue. If you get an error like “An error occurred while installing http_parser.rb (0.6.0, and Bundler cannot continue.