[RUBY] The road from Git clone to building the environment and participating in the project (all in full)

I want to participate in a project made by another person! I thought, Git Clone for the time being, but after that it's quite a pain. If you are hit by version matching (using Ruby / MySQL here) along the way, or if you are planning to collaborate, the participants ([listed at the end of the article](# what the creator side does)) should also be in advance. There are some things I need to keep, so I made a complete record of the journey. I would be happy if there is a reference, even if only partially.

Clone from Git repository

Visit the GitHub page you want to join. You can get the URL by clicking the "Clone or download" button. スクリーンショット 2020-06-13 12.17.02.png If you copy this URL and type the following command in the terminal, a folder will be created in your current location.

$ git clone https://github.com/xxxx/xxxx.git

gem installation

Go to the created folder

$ cd xxxx

When you do bundle install

$ bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching rake 13.0.1
Installing rake 13.0.1
Fetching concurrent-ruby 1.1.6
Installing concurrent-ruby 1.1.6
Fetching i18n 1.8.2
Installing i18n 1.8.2
Fetching minitest 5.14.0
Installing minitest 5.14.0
Fetching thread_safe 0.3.6
Installing thread_safe 0.3.6
Fetching tzinfo 1.2.7
(Omitted)

Ideally, it will be completed, but sometimes it does not happen.

When the Ruby version does not match

When you try to bundle install, you may see the following:

rbenv: version `2.6.3' is not installed

In the above case, Ruby version 2.6.3 is not installed.

You can see the list of installables below.

$ rbenv install --list
Available versions:
  1.8.5-p52
  1.8.5-p113
  
(Omitted)

If you don't have the version you are looking for, type the following command

$ brew upgrade rbenv ruby-build

Perform the installation.

$ rbenv install 2.6.3
ruby-build: using openssl from homebrew
Downloading ruby-2.6.3.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.3.tar.bz2
Installing ruby-2.6.3...
ruby-build: using readline from homebrew

After doing the above, try bundle install.

When the version of bundler does not match

When you try to bundle install, you may get the following display.

Could not find 'bundler' (2.1.2) required by your /Users/xxx/projects/xxxx/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.2`

Perform bundler gem install according to the display.

$ gem install bundler:2.1.2
Fetching bundler-2.1.2.gem
Successfully installed bundler-2.1.2
Parsing documentation for bundler-2.1.2
Installing ri documentation for bundler-2.1.2
Done installing documentation for bundler after 4 seconds
1 gem installed

After seeing the above, try bundle install.

Furthermore, when the DB (MySQL) version does not match

I think that bundle install has finally progressed, and the following display appears.

An error occurred while installing mysql2 (0.5.3), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'`
succeeds before bundling.

I want to perform a MySQL gem install following the display, but I get a series of errors.

$ gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
ERROR: Failed to build gem native extension.

(Omitted)

In this case, I referred to the following. (Thank you.)

[Reference] MySQL could not bundle install in Rails project

$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"

Prepare the database

Creating the database is as follows.

$ rake db:create

Next, create tables and columns. If you do the following and it doesn't work, it may be quick to ask the creator. If there is an inconsistency in the past creation / addition / deletion process, it will not work.

$ rake db:migrate

If there is a seed file (initial data), also execute the following.

$ rake db:seed

What the producer does

If you want to share your work using GitHub, the creator should do the following in advance.

Sharing master.key

Share the config / master.key that the person who launched the app has locally reserved to the participants. Participants create the same in the same directory. This file is not normally created on Git, so it should not be created by the cloned person. So don't forget to share it individually.

Participants must be included in Manage Access (on GitHub)

To work together, you need to add participants to setting> Manage access on the GitHub repository page.

at the end

As mentioned above, the measures I have taken this time are the main ones, but I would be happy if there is any reference. Thank you very much.

Recommended Posts

The road from Git clone to building the environment and participating in the project (all in full)
From building to deploying Ruby on Jets in docker-compose environment <Part 1>
How to install the language used in Ubuntu and how to build the environment
From "Create mvn project" to "Create remote repository in GitLab" to "git init"
The road from JavaScript to Java
Confirmation and refactoring of the flow from request to controller in [httpclient]
Clone and duplicate the app from GitHub (initialization)
How to use git with the power of jgit in an environment without git commands
Tokoro I rewrote in the migration from Wicket 7 to 8
Java classes and instances to understand in the figure
In Java, I want to trim multiple specified characters from only the beginning and end.
I want to recreate the contents of assets from scratch in the environment built with capistrano