I will look back on what I got stuck in when building the environment of Ruby on Rails on Windows as a memorandum for myself. * This method is for Ruby 6.0.0 or earlier.
I used this as a reference. Let's build an environment for Ruby on Rails! (Windows) --Progate Procedure to install Devkit on Windows7-Qiita msys2 and GNU toolchains (gcc, g ++, gfortran, findutils ... How to use different versions of Ruby on Windows (uru) --Qiita
Downloads - Ruby Installer Bold "[Ruby + Devkit 2.6.6-1 (x64)](https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.6-1/rubyinstaller-devkit-2.6. 6-1-x64.exe) ”RubyInstaller was downloaded and the installation proceeded. However, when installing MSYS2, the error "Installation failed" occurred. By the way, the same event occurred even if the FW was dropped. Therefore, I decided to install it individually.
From Downloads-Ruby Installer to [Ruby 2.6.6-1 (x64)](https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6 Download the installer for .6-1 / rubyinstaller-2.6.6-1-x64.exe) and double-click it. If there is no problem, select "I accept the License"
With "Add Ruby exexutables to your PATH", "Associate .rb and .rbw files with this Ruby installation", and "Use UTF-8 as default external encoding" checked, click [Install].
Uncheck "Run'ridk install' to setup MSYS2 and development toolchain." And click [Finish] This completes the Ruby installation.
Just in case, I added "C: \ Ruby26-x64" to the exclusion column of anti-virus software (Windows Defender in my environment).
Download Archives - Ruby Installer Download the installer for Devkit at the bottom right of the above site. Double-click the installer (7z self-extracting file), select the appropriate folder, and click [Extract].
Execute the following command to generate config.yml
cmd.exe
> cd c:\opt\devkit
> ruby dk.rb init
[INFO] found RubyInstaller v2.6.6 at C:/Ruby26-x64
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.
config.yml has been generated.
Open config.yml in an editor and specify the Ruby path if it is not specified.
Install Devkit Execute the following command.
cmd.exe
> ruby dk.rb install
[INFO] Updating existing gem override for 'C:/Ruby26-x64'
[INFO] Installing 'C:/Ruby26-x64/lib/ruby/site_ruby/devkit.rb'
Check "Precompiled Binaries for Windows" on the download page of Sqlite3 and check "[sqlite-dll-win64-x64-3330000.zip](https://www.sqlite.org/2020/sqlite-dll-win64-x64" -3330000.zip) "," sqlite-tools-win32-x86-3330000.zip "download. Unzip the downloaded folder and copy the files "sqlite3.dll" and "sqlite3.exe" to "C: \ Ruby26-x64 \ bin". (* sqlite3.exe has only 32bit version, but it seems that it also supports 64bit.)
If you come to this point and execute the command "gem install rails -v" 5.2.3 "", you can either execute the command of ridk install or I got a message asking me to install MSYS2.
From the MSYS2 site [msys2-x86_64-20200903.exe](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20200903. Download exe). First, set the environment variables from [Control Panel]-[System and Security]-[System]-[Environment Variables (N)].
● System environment variable MSYSTEM: MINGW64
● System environment variables PKG_CONFIG_PATH: / usr / lib / pkgconfig: / usr / share / pkgconfig: / lib / pkgconfig
● Added to the end of the system environment variable Path:
Below is a screenshot of the part where Path seems unnecessary.
Double-click the downloaded file to proceed with the installation. The progress of the installation is as follows. Press [Next] to proceed. You can check the progress by pressing [Show Details]. Press [Next] when the installation is complete. Press [Next] when the installation is complete. Press [Finish]. The bash screen of MSYS2 starts, but closes it once.
Run MSYS2 bash as an administrator. However, in my environment, there was only [Open file location] in the right-click menu, so I opened the file location once and did [Run as administrator] of "MSYS2 MSYS" from the shortcut group of the start menu. Execute the following command and check the environment variables.
bash
>echo $MSYSTEM
>echo $PATH
>echo $PKG_CONFIG_PATH
If the environment variables have been set, the display will be as follows.
Execute the following command, and when you are asked something, type [y] and press the Enter key.
bash
> pacman -Sy pacman
When you are done, close the MSYS screen once. Run MSYS2 MSYS again as administrator. Package database and pacman and core package updates Execute the following command, and when you are asked something, type [y] and press the Enter key.
bash
>pacman -Syu
When you're done, close the MSYS screen.
Package update Run MSYS2 MSYS again as administrator. Execute the following command.
bash
> pacman -Su
In my environment, I got a message saying "I have nothing to do". When you're done, close the MSYS screen.
Start the Windows command prompt and execute the following command.
cmd.exe
> where bash
> where ls
In my environment, "C: \ Windows \ System32 \ bash.exe" was displayed probably because of the effect of installing wsl, but it seems that there is no particular effect.
I think that there will be situations where different versions of Ruby are used properly depending on the environment where Ruby on Rails is used, so I installed uru.
From jonforums / uru / wiki / Downloads — Bitbucket uru-0.8.5-windows-x86 /uru/downloads/uru-0.8.5-windows-x86.7z) Download the file
Execute the following command at the command prompt.
cmd.exe
>uru_rt admin install
---> Installing uru into C:\opt\uru-0.8.5-windows-x86
"Uru.bat" and "uru.ps1" are generated.
Register the path to Ruby in uru.
cmd.exe
> uru admin add C:\Ruby26-x64\bin
---> Registered ruby at `C:\Ruby26-x64\bin` as `266p146`
Check if it is registered in uru.
cmd.exe
> uru ls
266p146 : ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]
Then run ridk install.
cmd.exe
> ridk install
Type [1] and press Enter. It seems that it has already been installed.
Type [2] and press Enter. It seems to be up to date. There are no more errors.
Type [3] and press Enter. Installation is in progress.
"Succeeded" is displayed and it seems that it ended normally. Press Enter.
Start the command prompt again and execute the following command.
cmd.exe
> gem install rails -v "5.2.3"
Since the message "installed" was confirmed, it seems that the installation of the gem was completed.
Let's check the version of rails.
cmd.exe
> rails -v
Rails 5.2.3
The installation of Rails was completed normally.
Let's make a sample app.
Execute the following command.
cmd.exe
> rails new sample_app -G
sample_app is the app name, so you can add it freely, The -G option is on if you don't have Git installed.
The message "Bundle complete!" Is displayed, and it seems that it ended normally. There is a message in NOTICE that chromedriver-helper is no longer supported, but I would like to take this opportunity again.
You have a folder named sample_app, which means you have created your Rails application.
cmd.exe
> cd sample_app
Navigate to the sample_app folder.
Execute the following command.
cmd.exe
> rails s
cmd.exe
rails s
=> Booting Puma
=> Rails 5.2.4.4 application starting in development
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.12.6 (ruby 2.6.6-p146), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
You can see that the server is running at "localhost: 3000".
Try accessing "localhost: 3000" with your browser.
I was able to confirm that the Rails server started.
You can stop the server by pressing [Ctrl] + [C].
Recommended Posts