Yay! You’re on Rails!

  1. create my 1st rails appliaction
    1
    rails new blog
    got stuck during bundle install running ctrl+c exit
  2. Change local gem source and run bundle install again
    1
    2
    3
    4
    5
    6
    7
    cd blog
    vim Gemfile
    source 'https://gems.ruby-china.com'
    #source 'https://rubygems.org'
    bundle install
    ...
    Bundle complete! 17 Gemfile dependencies, 75 gems now installed.
  3. Install Yarn and webpacker
    try rails server got webpacker missing error
    1
    /var/lib/gems/2.5.0/gems/webpacker-4.2.2/lib/webpacker/configuration.rb:95:in `rescue in load': Webpacker configuration file not found /home/ubuntu/rails-blog/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /home/ubuntu/rails-blog/config/webpacker.yml (RuntimeError)
    try rails webpacker:install got
    1
    Yarn not installed.
    • install Yarn
      1
      2
      3
      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 && sudo apt install yarn
    • install webpacker
      1
      2
      3
      rails webpacker:install
      ...
      Webpacker successfully installed
  4. Yay! You’re on Rails!
    1
    rails server

change gem and bundle source

1
2
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
bundle config mirror.https://rubygems.org https://gems.ruby-china.com

Reference from:

  1. Getting Started with Rails

  2. On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository.

  3. https://gems.ruby-china.com/
  4. https://bundler.io/v1.16/bundle_config.html