(Since my current environment is Mac, I will only write about Mac once. I may write about Windows later)
--Install rbenv anyway. Then talk.
At Terminal
$ rails new {Project name}
Will create a project directory where the Rails app type files are generated.
Enter the project directory created in 1.
$ cd ./{Project name}
Execute the command of ↓
```$ bundle install --path vendor/bundle```
I got an error here.
Click here for the error text (excerpt of only the error part)
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.
There seems to be an error in the installation of what is called nokogiri ([What is nokogiri](http://hetaredream.hatenablog.com/entry/2014/12/20/163310#:~:text=Nokogiri%E3%81%A8] % E3% 81% AF% E4% BD% 95% E3% 81% 8B,% E8% A1% 8C% E3% 81% 86% E3% 81% 93% E3% 81% A8% E3% 81% 8C% E3% 81% A7% E3% 81% 8D% E3% 81% BE% E3% 81% 99% E3% 80% 82))
## 3. Error resolution
--Simply try `gem install nokogiri`
--This is also an error
`` `You have to install development tools first.` ``
--Because you need developer tools, first try installing Xcode from the App Store (it takes quite a while)
--After installing Xcode, start it and
Set "Command Line Tools" in "Xcode"-> "Preference"-> "Location"
([Here](https://qiita.com/kodai_0122/items/56168eaec28eb7b1b93b#bundle-install --- path-vendorbundle% E3% 81% A7an-error-occurred-while-installing-pg-122% E3% 81 % A8% E3% 81% 84% E3% 81% 86% E3% 82% A8% E3% 83% A9% E3% 83% BC% E3% 81% 8C% E5% 87% BA% E3% 81% 9F % E5% A0% B4% E5% 90% 88) It seems that this setting can be done even from Terminal?)
--When I restart Terminal and try to install nokogiri again,
--An error again
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/bin directory.
I don't seem to have write permission for `/ usr / bin`, but I can't change the permission with sudo or chmod.
--It seems that the system Ruby and gem are not easy to use, so it seems better to create an environment with rbenv ([What is rbenv](https://qiita.com/Kodak_tmo/items/73147ed4f0eec54d6e94)). The feeling that I should have done first)
--How to install brew of rbenv and its installer [here](https://qiita.com/kodai_0122/items/56168eaec28eb7b1b93b#bundle-install --- path-vendorbundle% E3% 81% A7an-error-occurred-while -installing-pg-122%E3%81%A8%E3%81%84%E3%81%86%E3%82%A8%E3%83%A9%E3%83%BC%E3%81%8C%E5 % 87% BA% E3% 81% 9F% E5% A0% B4% E5% 90% 88) See
--If the project directory has already been created, the Ruby version should have been set, so install the set version with rbenv. (You can check the set version by looking at the contents of `{project name} /. Ruby-version`)
--Third honesty, `gem install nokogiri` ...
Fetching mini_portile2-2.4.0.gem Fetching nokogiri-1.10.5.gem Successfully installed mini_portile2-2.4.0 Building native extensions. This could take a while... Successfully installed nokogiri-1.10.5 Parsing documentation for mini_portile2-2.4.0 Installing ri documentation for mini_portile2-2.4.0 Parsing documentation for nokogiri-1.10.5 Installing ri documentation for nokogiri-1.10.5 Done installing documentation for mini_portile2, nokogiri after 1 seconds 2 gems installed
did it!
## 4. Reinstall gem after error resolution
```$ bundle install --path vendor/bundle```
Run again
Bundle complete! 17 Gemfile dependencies, 74 gems now installed.
Bundled gems are installed into ./vendor/bundle
Installation is successful when a screen like
## 5. Summary
--Let's use rbenv
-----
【reference】
- https://qiita.com/___xxx_/items/b18795056e98243568fe
Recommended Posts