From 4080d1d1b80b5cf0d3e3e6829794ac2ec328fb89 Mon Sep 17 00:00:00 2001 From: Alejandro Rebollar Date: Wed, 12 Nov 2025 13:16:38 -0600 Subject: [PATCH 1/3] Revise README for installation guide and version updates Updated the README to reflect changes in installation steps and version updates for Rails and Node.js. Improved clarity and organization of the guide. --- README.md | 199 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 120 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 67a1533..d3032b1 100755 --- a/README.md +++ b/README.md @@ -1,72 +1,46 @@ -# Rails from Scratch - -A simple guide to installing rails on WSL. Not super unique, but complete.... +# Ultimate guide +This guide is based off the [original one by Matthew Schultz](https://github.com/MatthewSchultz/Install-Rails-on-WSL) and [this one from GoRails](https://gorails.com/setup/windows/11). +It also considers you are installing rails >= 7.x. ## Step 1 - WSL -* Admin powershell, execute `Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux` -* Reboot -* In Microsoft Store, find Ubuntu, download that stuffs... -* Hit the Launch button in store, or find Ubuntu in start menu. Watch and wait while it unpacks itself. -* Run `sudo apt update && sudo apt upgrade` to start getting packages - -## Step 2 - Install NodeJS and YARN - -Rails 6 now requires the YARN package manager to function, since it likes webpack more than other stuff now. It also tends to be built heavily around Node packages. While it's theoretically possible to use Rails without these things, in modern web apps, Node and YARN should be installed. - -### Setup NodeJS as a Javascript runtime - +On Windows 11 it is easier to just do: ```bash -curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - -sudo apt install -y nodejs +wsl --install ``` -This sets up NodeJS by downloading a setup script from the NodeJS site and running it. This is superior to simply installing node Ubuntu's managed repos, since that version is ususally woefully out of date. - -Be sure to change the version your trying to get in the URI - the above URI gets the latest version of the v14 major branch. - -### Setup the YARN package manager - -First, let's add the YARN server to the package repo list (since the one that is included with repo lists is nearly guaranteed to be out of date): +We are going with the default distro (Ubuntu) for simplicity. +You can also see what other distros you can install by doing: ```bash -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - -echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list -sudo apt update +wsl --list --online ``` -Now install YARN... - +And install your preferred one with: ```bash -sudo apt install yarn +wsl --install ``` -...and test - -```bash -yarn --version -``` +Finish the installation and reboot your PC. Then run `sudo apt update && sudo apt upgrade` to start getting packages. +You can search for "Ubuntu" in the Windows Start Menu anytime to open the Ubuntu terminal. -Rails 6, as of this writing, requires at least YARN 1.0. +## Step 2 - Install dependencies for Ruby -## Step 3 - Pre-Installation - -### Setup Dependencies +The first step is to install dependencies for compiling Ruby. +Open your Terminal and run the following commands to install them. ```bash -sudo apt install curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev -sudo apt install libpq-dev +sudo apt-get update +sudo apt install build-essential rustc libssl-dev libyaml-dev zlib1g-dev libgmp-dev curl zlib1g-dev libssl-dev libreadline-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev sudo apt install imagemagick sudo apt install graphviz ``` Here we install a bunch of dependencies, of which libxml2-dev is particularly important for nokogiri. -The second line can be omitted if (for some probably terrible reason, you are not using postgresql). - -The third line install imagemagick, a critical image-processing library. If you know you don't need this it's ok to omit, but it's a common enough library I suggest installing it. +The second line installs imagemagick, a critical image-processing library. If you know you don't need this it's ok to omit, but it's a common enough library I suggest installing it. -The fourth line installs graphviz, a graphical generation utility. Not sure how important this is, but I use it often. +The third line installs graphviz, a graphical generation utility. Not sure how important this is, but I use it often. ### Setup QOL Tools @@ -76,37 +50,44 @@ sudo apt-get install tmux tty-clock htop cowsay postgresql-client fortune These are somewhat optional, but make living in semi-linux bearable. -## Step 4 - Ruby via rbenv +## Step 3 - Install Ruby +Next, we'll install Ruby using a version manager called Mise. This allows you to easily update Ruby and switch between versions anytime. -This will install Ruby via rbenv. Doing it via ruby-full seems to suck. +```bash +curl https://mise.run | sh +echo 'eval "$(~/.local/bin/mise activate)"' >> ~/.bashrc +source ~/.bashrc +``` +Then install Ruby with Mise: ```bash -cd -git clone https://github.com/rbenv/rbenv.git ~/.rbenv -echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc -echo 'eval "$(rbenv init -)"' >> ~/.bashrc -exec $SHELL +mise use --global ruby@3 +``` -git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build -echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc -exec $SHELL +Confirm that Ruby is installed and works: -rbenv install 3.1.2 -rbenv global 3.1.2 -ruby -v +```bash +ruby --version +#=> 3.4.7 ``` -Now, write the following to `~/.gemrc` (this is optional, of course, but I mean, who really wants to wait for everything to compile it's documentation): +You also want to ensure you're using the latest version of Rubygems. ```bash -echo 'gem: --no-document' >> ~/.gemrc +gem update --system ``` -Finally: +## Step 4 - Installing Node + +Optionally, if you plan to use Node.js for handling assets, you can use Mise to install Node as well. ```bash -gem install bundler -rbenv rehash +mise use --global node@24.11.0 +``` + +```bash +node -v +#=> 24.11.0 ``` ## Step 5 - Setup GIT @@ -115,12 +96,32 @@ rbenv rehash git config --global color.ui true git config --global user.name "YOUR NAME" git config --global user.email "YOUR@EMAIL.com" -ssh-keygen -t rsa -b 4096 -C "YOUR@EMAIL.com" +ssh-keygen -t ed25519 -C "YOUR@EMAIL.com" ``` -This sets up GIT and runs keygen. Now `cat ~/.ssh/id_rsa.pub` to get the key to paste into BitBucket/GitHub. Make sure to make a new window if you're in a tmux pane so you can copy that noise. +The next step is to take the newly generated SSH key and add it to your Github or Bitbucket account. You want to copy and paste the output of the following command and paste it here. -Now do `ssh -T git@bitbucket.org` or `ssh -T git@github.com` to test it. +```bash +cat ~/.ssh/id_ed25519.pub +``` + +Once you've done this, you can check and see if it worked: + +```bash +ssh -T git@github.com +``` + +or + +```bash +ssh -T git@bitbucket.org +``` + +You should get a message like this: + +```bash +Hi your_name! You've successfully authenticated, but GitHub does not provide shell access. +``` ## Step 6 - Because we Can @@ -130,33 +131,73 @@ gem install lolcat Helps make sure gems are working anyways.......not really. I just find lolcat funny. -## Step 7 - Install the Rails +## Step 7 - Installing Rails + +Choose the version of Rails you want to install: ```bash -gem install rails +gem install rails -v 8.1.1 ``` -Here we are just going for the latest version, at the time of this writing, **6.0.3**. +> Note: If you want to use [Solidus](https://github.com/solidusio/solidus), the latest supported version at the time of writing is 7.2. For your consideration. -Because we installed all that dependencies in step 2, this *should* install nokogiri correctly. +Now that you've installed Rails, you can run the rails -v command to make sure you have everything installed correctly: -Test by `rails -v` +```bash +rails -v +# Rails 8.1.1 +``` -## Step 8 - Change the Way WSL Handles CHMOD +If you get a different result for some reason, it means your environment may not be setup properly. -THIS STEP SHOULD NO LONGER BE REQUIRED - ONLY DO THIS IF YOU RUN INTO ISSUES. +## Step 8 - Setting up PostgreSQL -Do `sudo vim /etc/wsl.conf` - we need to write a wsl config to turn on metadata tracking for mounted noise. Into that file write: +For PostgreSQL, we're going to add a new repository to easily install a recent version of Postgres. ```bash -[automount] -enabled = true -options = "metadata" -mountFsTab = false +sudo apt install postgresql libpq-dev +sudo service postgresql start ``` -Now, restart the entire Ubuntu instance, and Rails will suddenly behave itself. Skipping this causes Rails to fail on Rails new with some complete rubbish about permissions... +You'll need to start postgresql each time you load your WSL environment. + +The postgres installation doesn't setup a user for you, so you'll need to follow these steps to create a user with permission to create databases. Feel free to replace zam with your username. + +```bash +sudo -u postgres createuser zam -s +# If you would like to set a password for the user, you can do the following +sudo -u postgres psql +postgres=# \password zam +``` ## Step 9 - Get to Project Directory Do `cd /mnt/` to get to the project directory. Project directories ARE case sensitive, use linux folder seperation, do not use the colon notation for drives, and the drive letter is lowercased, so `C:\Users\You\Projects\SomeFolder\` becomes `/mnt/c/Users/You/Projects/SomeFolder`. + +## Step 10 - Test it out +Let's create your first Rails application on Windows! + +```bash +rails new myapp -d postgresql -c tailwindcss +``` + +With this, we are creating a project using postgres as the DB and tailwind as the CSS framework. + +Then, move into the application directory +```bash +cd myapp +``` + +If you setup Postgres with a username/password, modify the config/database.yml file to contain the username/password that you specified above. + +Create the database +```bash +rake db:create +``` + +Start your server +```bash +rails server +``` + +You can now visit http://localhost:3000 to view your new website! From 9e5c93dce40ecb9e7290f6c160b3501188001039 Mon Sep 17 00:00:00 2001 From: Alejandro Rebollar Date: Wed, 12 Nov 2025 13:26:08 -0600 Subject: [PATCH 2/3] Update README with optional zsh installation Added optional zsh and Oh My Zsh installation steps to the README. --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3032b1..0d49e84 100755 --- a/README.md +++ b/README.md @@ -24,6 +24,23 @@ wsl --install Finish the installation and reboot your PC. Then run `sudo apt update && sudo apt upgrade` to start getting packages. You can search for "Ubuntu" in the Windows Start Menu anytime to open the Ubuntu terminal. +## Step 1.5 - (Optional) Install zsh and Oh My Zsh! +I just love all the aliases and themes Oh My Zsh! offers, so I am including its installation in this guide. + +First we install zsh: +```bash +sudo apt install zsh +zsh --version +# Expected result: zsh 5.0.8 or more recent +``` + +Then we proceed with Oh My Zsh: +```bash +sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +``` + +Once that is done, you may want to check [this](https://github.com/ohmyzsh/ohmyzsh/wiki#getting-started) for more information and customization. + ## Step 2 - Install dependencies for Ruby The first step is to install dependencies for compiling Ruby. @@ -77,7 +94,7 @@ You also want to ensure you're using the latest version of Rubygems. gem update --system ``` -## Step 4 - Installing Node +## Step 4 - Install Node Optionally, if you plan to use Node.js for handling assets, you can use Mise to install Node as well. @@ -131,7 +148,7 @@ gem install lolcat Helps make sure gems are working anyways.......not really. I just find lolcat funny. -## Step 7 - Installing Rails +## Step 7 - Install Rails Choose the version of Rails you want to install: From 74b34f25117e819f266d66b0f6bb0365daf06f93 Mon Sep 17 00:00:00 2001 From: Alejandro Rebollar Date: Wed, 12 Nov 2025 15:03:30 -0600 Subject: [PATCH 3/3] Modify Ruby installation instructions for zsh Updated installation instructions for Ruby to use zshrc instead of bashrc. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0d49e84..cf6faaa 100755 --- a/README.md +++ b/README.md @@ -70,10 +70,12 @@ These are somewhat optional, but make living in semi-linux bearable. ## Step 3 - Install Ruby Next, we'll install Ruby using a version manager called Mise. This allows you to easily update Ruby and switch between versions anytime. +(If you skipped step 1.5, replace **zshrc** with **bashrc**) + ```bash curl https://mise.run | sh -echo 'eval "$(~/.local/bin/mise activate)"' >> ~/.bashrc -source ~/.bashrc +echo 'eval "$(~/.local/bin/mise activate)"' >> ~/.zshrc +source ~/.zshrc ``` Then install Ruby with Mise: