・ Ruby 2.5.7 ・ Rails 5.2.4.4 ・ MacOS Catalina 10.15.7 ・ Rbenv 1.1.2
After modifying the Gemfile for deployment to Heroku When I did $ bundle install, the following error occurred.
An error occurred while installing nokogiri (1.10.10), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.10' --source 'https://rubygems.org/'` succeeds before bundling.
As I was told, when I tried to install nokogiri, I got the following error and got stuck.
$ gem install nokogiri -v '1.10.10' --source 'https://rubygems.org/'
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
The solution process almost follows the following article that I referred to. What to do if a permissions error occurs even after bundle install Also, what is a path in the first place? I felt like, so I learned the following article. What is PATH? (Mac OS X)
Where /Users/username/.rbenv/shims/ruby must be It is as follows.
$ which ruby
/usr/bin/ruby
Modify .bash_profile with echo command to fix this correctly, Reboot with exec $ SHELL -l.
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ exec $SHELL -l
If you check with $ which ruby
$ which ruby
/usr/bin/ruby
vi Operation $ vi ~/.bash_profile If you check the contents of .bash_profile, it is edited correctly as below
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
It seems that the shell is not reflected, so type the following command to reflect the edited contents of .bash_profile.
$ source .bash_profile
If you check with $ which ruby
$ which ruby
/Users/username/.rbenv/shims/ruby
After that, I was able to successfully install $ bundle according to the following flow.
$ gem install nokogiri -v '1.10.10' --source 'https://rubygems.org/'
$ gem install bundler
$ bundle install
** * Supplement ** The reason why I did $ gem install bundler is that I did bundle install after installing nokogiri, but I got the following error.
rbenv: bundle: command not found
The `bundle' command exists in these Ruby versions:
2.7.2
That's all, thank you to the mentors who took care of us for the solution.
https://qiita.com/ginokinh/items/45ac4cd16f766a426532
Recommended Posts