VSCoder, which recently started Rails, had the following problems.
-** Environment construction is troublesome **
Therefore, I was using Cloud9 on AWS, but this time I have the following problems
-** The editor on the browser is difficult to use and feels strange ** -** I want to use VS Code **
So I started working on the hot ** Visual Studio Codespaces ** and changed my life.
In a nutshell, it's a ** development environment on the cloud **. Quoting from the Official Site, it has the following features.
--** A browser-based editor with a Git repository, extensions, and a built-in command line interface ** -** You can edit, run and debug your application from any device **
Also, the biggest feature for me is
-** Can also be developed with VSCode desktop application **
about it. Of course, you can also add extensions.
VSCode will appear on your browser! !! !!
You can also use the terminal. The workspace is created by a user named vsonline.
Python is included by default.
This is the usual VScode! !!
Cloud9 has a Ruby and Rails environment by default, but unfortunately not in Visual Studio Codespaces ... Anyway, I will change the version even in Cloud9. All of the following is done in the VSCode terminal of the desktop app connected to Codespace. Since Codespaces uses a Linux environment, it is basically the same as building an environment on ordinary Linux.
Refer to the README of here, which is also recommended on Ruby official website. I will install it in. rbenv allows you to manage multiple versions of Ruby.
First, clone the repository, add it to the path, and set it up.
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bashrc
$ ~/.rbenv/bin/rbenv init
After that, you need to restart the terminal, so press the + button ** to open a new terminal **. You can check it by typing the following command, but rbenv install is not found.
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Follow the link given and the solution is below.
$ mkdir -p "$(rbenv root)"/plugins
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
If you check it again, this time it should be working.
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
This completes rbenv. I was in the mountains here.
You can check the major Ruby versions. If you want to see everything, you can do it with $ rbenv install --list-all
.
$ rbenv install --list
After that, you can install your favorite version with $ rbenv install [version number]
.
$ rbenv install 2.7.1
After installation, specify which version of Ruby to use with the following command.
$ rbenv global 2.7.1
You have successfully installed Ruby!
Next, install Rails.
$ gem install rails
You have Rails installed!
After that, you can develop as if it were a local environment. ** You can also use localhost **.
$ rails new SampleApp
After creating a Rails app with
$ rails s
Start the server with.
Click Remote Explorer> Forward Port ...
, type 3000
and press Enter to connect to localhost: 3000, as shown in the image below.
When you access http: // localhost: 3000 /
in your browser ...
that's all. As for Rails, it's been two months since I started, so there may be some points that I can't reach. We look forward to your corrections and comments.
Recommended Posts