Setting my own environment: Visual Studio Code, Git and Bundler
First, I create a repository in Github.
Then, I create a new folder in my laptop where I want to clone the repository.
I open this folder in my VS code and open the terminal (ctrl + `).
I run: git clone + the https from the repository.
When I make changes:
First, I stage this changes.
Second, I write commit message and commit.
Third, I push my changes.
Installing Bundler
First I make sure I have the latest version of RubyGems. I run in the VS code terminal $gem update –system
Then I instal Bundler: gem install bundler but I got an error message![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-10.15.09.png)
I don’t have write permissions. I googled this error output and I am trying something I found in stack overflow: sudo gem install bundler. I gave the personal password for my computer and it worked!
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-10.19.35-1.png)
The purpose of sudo is to execute the command given to it with root privileges.
Adding Gems to gemfile
I created a new file gemfile and I am adding my gems to it, bundler.
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-10.37.32.png)
~>
is called “Twiddle-Wakka.” '~> 2.0'
means any minor version above 2.0, 2.1, 2.2, 2.3 … and 2.9 included would work (including patches); but version 3.0 wouldn’t work because it indicates a new major version.
The second specification '>= 2.0.1'
means any version greater than or equal to 2.0.1
. Both specifications have to be true, so this gem couldn’t use version 2.0
because it’s lower than 2.0.1
.
My Gemfile.lock file
I run in the VS code terminal $bundle install
Automatically a file was created in my directory: Gemfile.lock
Reviewing my installed gems
I run in the VS code terminal $gem list![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-10.50.29.png)
Checking where my Bundler is
I run in the VS code terminal $bundle show [bundler]
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-10.53.42.png)
Adding Gemfile and Gemfile.lock to my repository
I run in the VS code terminal $git add Gemfile Gemfile.lock.
I could staged the changes in my VS code, they do the same thing that the git add command.
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-11.00.52.png)
I check my Github repository….and it didn’t work.
Ok! I forgot to push my changes, so I ran: $git push origin master
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-11.11.37.png)
Done! I got my two new files in my repository.
Now, I want to install Nokogiri
Installing Nokogiri
I run in the VS code terminal $sudo gem install nokogiri![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-11.31.58.png)
And after the installation was successfully I add my new gem to the Gemfile
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-11.37.03.png)
I check if my changes are in Github and…no! They are not! Why? BecauseI forgot to push them.
My work flow in VSC:
Save changes – stage changes – commit changes – push changes
Installing pry
I run in the VS code terminal $sudo gem install pry![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-11.48.48-1.png)
And then I add the new gem to the Gemfile
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-11.54.24.png)
And I don’t forget about my VSC workflow! Save, stage, commit and push.
Installing ‘open-uri’
I was trying to install it and got this error:
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-12.44.28.png)
I googled it and…
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-12.43.32-1.png)
OpenUri is part of Ruby standard library, I just need to require it.
After all this installations I checked my Gemfile.lock and I couldn’t see anything about nokogiri or pry. I run $bundle install and my Gemfile.lock is updated.![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-12.08.39-1.png)
Installing ‘colorize’
I run in the VS code terminal $sudo gem install colorize
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-20-at-16.02.37.png)
I add my new gem to the Gemfile.
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-20-at-16.05.21.png)
And run $bundle install to update my Gemfile.lock.
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-20-at-16.06.21.png)
I open my Gemfile and do this with my pry gem:
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-12.26.26.png)
This is Group Syntax and I am specifying the environment where it is going to be used pry. I am going to change it for a shorter syntax, the hash syntax: gem ‘pry’, :group => :development
After installing all my gems I need to require them where I am going to use them.
config/environment.rb
Now, I create a folder config and a file environment.rb inside. In this file I will be loading, requiring, all of my app’s dependencies like my gems.
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-15-at-12.37.36.png)
With this code all the gems that are inside Gemfile are required.
I need to require ‘open-uri’ and ‘colorize’ too in my environment.
![](http://carolinabadas.com/wp-content/uploads/2019/02/Screenshot-2019-02-20-at-16.07.20.png)