macbookPro 2019にRubyとRuby on Railsをバージョン管理できるようインストールしてみた
touch ~/.bash_profile
これでbash_profileをまず作成します。
rbenv、Rubyのインストール
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
mkdir -p ~/.rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git
~/.rbenv/plugins/ruby-build
source ~/.bash_profile
Homebrewをインストールします。
2019年9月時点でのURL
ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew doctor
Your system is ready to brew.
$ brew update
Already up-to-date.
OpenSSLをインストール
公式から最新版は2.6.4であることを確認。
https://www.ruby-lang.org/ja/downloads/
$ brew install openssl
$brew install readline
$brew install libiconv
$brew install rbenv ruby-buildRUBY_CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline) --with-openssl-dir=$(brew --prefix openssl) --with-iconv-dir=$(brew --prefix libiconv)" rbenv install 2.6.4
rubyの最新版をインストール
$ rbenv versions
Versionを確認。
$ rbenv global 2.6.4
インストールしたRubyを有効化
SSL証明書のインポート
$ruby -ropenssl -e "p OpenSSL::X509::DEFAULT_CERT_FILE"
"/private/etc/ssl/cert.pem"
パスの確認をする。
sudo curl "https://curl.haxx.se/ca/cacert.pem" -o /private/etc/ssl/cert.pem
Password:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 218k 100 218k 0 0 124k 0 0:00:01 0:00:01 --:--:-- 124k
証明書のダウンロード。
Bundlerのインストール
$rbenv exec gem install bundler
bundlerをインストール
$ rbenv rehash
Railsをローカルにインストールする
$ cat << EOS > Gemfile
source "http://rubygems.org"
gem "rails" ←バージョンを指定していないため、最新版が導入される。
EOS
$ bundle install --path vendor/bundle
$ bundle exec rails new example --skip-bundle
Ruby環境にインストールされてしまうのを防ぐ設定 --skip-bundle
$ rm -f Gemfile
$ rm -f Gemfile.lock
$ rm -rf .bundle
$ rm -rf vendor/bundle
railsをローカルインストールするために使ったbundlerの環境と、ローカルのrailsを削除する。
$ cd プロジェクト名
$ bundle install --path vendor/bundle
------------------------
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.
Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.
解決策は、
config/environments/production.rb
config.i18n.fallbacks = true
となっているところを
config.i18n.fallbacks = [I18n.default_locale]
とする。
もう一点のエラー
For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
Post-install message from chromedriver-helper:
+--------------------------------------------------------------------+
| |
| NOTICE: chromedriver-helper is deprecated after 2019-03-31. |
| |
| Please update to use the 'webdrivers' gem instead. |
| See https://github.com/flavorjones/chromedriver-helper/issues/83 |
| |
+--------------------------------------------------------------------+
Post-install message from sass:
Ruby Sass has reached end-of-life and should no longer be used.
* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
primary implementation: https://sass-lang.com/install
* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
sassc gem: https://github.com/sass/sassc-ruby#readme
* For more details, please refer to the Sass blog:
https://sass-lang.com/blog/posts/7828841
下記を参考に書き換えれば問題なさそう。
- gem 'chromedriver-helper'
+ gem 'webdrivers'
https://qiita.com/jnchito/items/f9c3be449fd164176efa
$ echo '/vendor/bundle' >> .gitignore
$ bundle exec rails server
=> Booting Puma
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.3.7-p456), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
目的が達成。
参考記事:https://qiita.com/takutoki/items/021b804b9957fe65e093
https://qiita.com/_daisuke/items/d3b2477d15ed2611a058
https://qiita./emadurandal/items/e43c4896be1df60caef0