# 运行环境

# Bundler工具

Rails使用了一套叫做Bundler的工具可以幫助我們檢查及安裝這個Rails應用程式所有依存的套件

# 每次有修改Gemfile這個檔案,都需要重新執行bundle
$ bundle install | $ bundle

# to see where a bundled gem is installed
$ bundle show [gemname]

# Gemfile

# 强制安装到开发环境,防止冲突
group :development do
  gem 'sqlite3', '1.3.7'
end

# 仅安装到生产环境
group :production do
  gem 'pg', '0.15.1'
end

# 安装1.30以上最新版本(跨版本升级)
gem 'uglifier', '>=1.3.0'

# 安装补丁版升级
gem 'coffee-rails', '~> 4.0.0'

# 不会在生产环境中部署
$ bundle install --without production

#结论,最好都指定固定版本,减少环境问题

# 卸载Gem
 gem uninstall gem_name

# Git

# 强制回滚到上个未提交版本
git checkout -f

# -a 将所有改动,包括重命名都添加进来
git commit -a -m "Improve the README file"

# 遇到问题

  1. invalid byte sequence in US-ASCII (ArgumentError)
    #Gemfile 中添加
    if RUBY_VERSION =~ /2.3/ # assuming you're running Ruby ~1.9
      Encoding.default_external = Encoding::UTF_8
      Encoding.default_internal = Encoding::UTF_8
    end
    
Last Updated: 5/14/2022, 11:38:45 AM