DEV Community

Mingming Wang
Mingming Wang

Posted on • Updated on

Set up a clean Rails development environment

Recently I tried to setup Solidus (a Rails engine for e-commerce) and faced tons of issues, mostly not related to Solidus but Ruby, Rails and Node environments. The following is the note on how I finally resolved all the issues faced.

  1. If your brew is messed up or you have used brew to install Ruby or Node, consider reinstall brew.

  2. Use brew to install git, sqlite3 and imagemagick since they are Ruby/Node agnostic and wouldn't be affected by different Ruby or Node version.

  3. Use version manager to install Ruby and Node.

    This is because the latest version of Ruby or Nodes may not work for your scenario and you would then need to install a different version of them. Version managers make it much easier.

    For Ruby, I used RVM since I used it before. For Node I used NVM since it switched node packages according to the current Node being used as well.

    Important: at the time of this writing, latest Node version is not working well with my Rails setup and I have to downgrade it to Node 14. (Thanks to https://dev.to/andrzejkrzywda/fixing-the-node-sass-problem-in-rails-node-downgrade-helps-16lh)

  4. Use gem (from current Ruby version based on RVM) to install Rails (for current Ruby version). Don't use brew to install it which would be global.

    The Rails version installed will be according to the current gem based on the current Ruby version based on RVM.

  5. Use npm (from current Node version based on NVM) to install Yarn (for current Node version).

    Don't use brew to install it which would be global.This is because Yarn is a node package and I used NVM to manage my node and node package accordingly. So whenever I switch my node version, Yarn will be switched accordingly as well. This may save some compatibility issue.

Top comments (0)