[RUBY] A note of someone who stumbled when trying to create a Rails project

(Since my current environment is Mac, I will only write about Mac once. I may write about Windows later)

0. Conclusion

--Install rbenv anyway. Then talk.

1. Project creation (Reference)

At Terminal $ rails new {Project name} Will create a project directory where the Rails app type files are generated.

2. Install various gems (What is a gem)

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

A note of someone who stumbled when trying to create a Rails project
A memorandum when trying to create a GUI using JavaFX
A note for when someone who was Java Java until yesterday came to touch Scala
A series of steps to create portfolio deliverables with Rails
Preparing to create a Rails application
A note that I had trouble when trying to use nginx with Remote-Containers of vscode
A story of frustration trying to create a penetration environment on Ubuntu 20.04
[rails] How to create a partial template
Volume of trying to create a Java Web application on Windows Server 2016
[Rails] How to write when making a subquery
[Rails] rails new to create a database with PostgreSQL
[Rails] How to create a graph using lazy_high_charts
[1st] How to create a Spring-MVC framework project
How to easily create a pull-down in Rails
[Rails] How to create a Twitter share button
About the solution of the error that occurred when trying to create a Japanese file of devise in the Docker development environment
I tried to make a message function of Rails Tutorial extension (Part 1): Create a model
Library not loaded when trying to upgrade the version of ruby and rails s
Docker command to create Rails project with a single blow in environment without Ruby
[Introduction] Try to create a Ruby on Rails application
[Rails] How to create a signed URL for CloudFront
How to create a Spring Boot project in IntelliJ
[Spring Boot] How to create a project (for beginners)
What to do when rails creates a 〇〇 2.rb file
[Beginner] I stumbled upon launching a project with Rails6
I tried to make a message function of Rails Tutorial extension (Part 2): Create a screen to display
Tutorial to create a blog with Rails for beginners Part 1
[Rails] I tried to create a mini app with FullCalendar
[Rails DM] Let's create a notification function when DM is sent!
A note about the seed function of Ruby on Rails
I want to create a form to select the [Rails] category
Tutorial to create a blog with Rails for beginners Part 2
Tutorial to create a blog with Rails for beginners Part 0
Existing records disappear when building a model of has_one (rails)
A note of what I stumbled upon and noticed in catching up with Laravel from Rails
Method definition location Summary of how to check When defined in the project and Rails / Gem
[Rails] Launch a new project
A note when examining Javalin
How to create a method
A funny story stuck in a mess when trying to import fx-clj
[Rails 6] How to create a dynamic form input screen using cocoon
How to create a new Gradle + Java + Jar project in Intellij 2016.03
A note when I was addicted to converting Ubuntu on WSL1 to WSL2
I get a Ruby version error when I try to start Rails.
Easy way to create a mapping class when using the API
(Ruby on Rails6) Create a function to edit the posted content