gem install pgしてNo pg_configエラー
まず原因の切り分け。
確認事項
1-postgresはインストールされているか?
2-pathは通っているか?
インストールは次で確認。バージョンが表示されればインストールされているということ。
たまに起動していないこともあるので、そこもチェック
$ psql --version psql (PostgreSQL) 9.2.24
インストールはされているらしい。
pg_configへのパスを通さないといけない。
よってpg_configファイルを探す。そこがパスと思って良い。
find /usr -name pg_config | grep pg_config
findは検索コマンド
/usrはそれ以下の場所を探すの意味
-name pg_config
名前はpg_configでね。
grepは件察結果の中から pg_configだけを表示してくださいの意味。
パイプ | 縦棒 で区切ります。
パスを追加する
~/.bash_profile にパスがまとめて書いてある
$ vim ~/.bash_profile
PATH=$PATH:/usr/lib64/pgsql92/bin <-- コレ追加!!
次に、追加したパスをシステムに反映させるコマンド
ウインドウズのF5キーのようなもの
$ source ~/.bash_profile
パスが追加されているか確認
$echo $PATH
追加されていればOK
これで持ってbundle installを実行 すると
An error occurred while installing pg (1.1.3), and Bundler cannot continue. Make sure that `gem install pg -v '1.1.3'` succeeds before bundling.
大丈夫。先程はpathが通っていなかったので、言われたとおりにやってもだめだった。 今度は違うはず。
gem install pg -v '1.1.3'
Building native extensions. This could take a while... Successfully installed pg-1.1.3 Parsing documentation for pg-1.1.3 Installing ri documentation for pg-1.1.3 Done installing documentation for pg after 1 seconds 1 gem installed
成功!
Railはバージョンをしっかり固定しないと、いけない。
最新をインストールするとするとエラーになる。
現時点で成功したgem一覧を記載しておきます。
ほぼ、デプロイ用にポスグレを入れただけのもの。
2018.9
source 'https://rubygems.org' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.6' # Use sqlite3 as the database for Active Record gem 'sqlite3',group: [:development,:test] # Use Puma as the app server gem 'puma', '~> 3.7' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] # Adds support for Capybara system testing and selenium driver gem 'capybara', '~> 2.13' gem 'selenium-webdriver' end group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'bootstrap-sass', '3.3.1' gem 'sprockets' gem 'devise' gem "jquery-rails" gem 'faker' #add 2018.7.26 gem 'pry', '~> 0.11.3' gem 'will_paginate', '3.1.6' gem 'will_paginate-bootstrap', '1.0.1' group :production do gem 'pg' gem 'rails_12factor' end