質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

1回答

8219閲覧

Ruby のpg gemについてのエラー

Moto_hero

総合スコア7

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

1クリップ

投稿2016/03/03 15:08

編集2022/01/12 10:55

RubyでHeroku を使う準備ができたので、今度はローカル開発環境で Rails アプリケーションを作って、Heroku に送る準備をしていました。

$ new memo -d postgresql

すると下記のエラーが出てきまして、対応に困っております。どのようん対処したらいいでしょうか?¥

Installing pg 0.18.4 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/[username]/.rbenv/versions/2.1.3/bin/ruby extconf.rb --with-pg-config=/usr/pgsql-9.4/bin/pg_config

Using config values from /usr/pgsql-9.4/bin/pg_config
extconf.rb:29: warning: Insecure world writable dir /usr/local/Cellar in PATH, mode 040777
sh: /usr/pgsql-9.4/bin/pg_config: No such file or directory
sh: /usr/pgsql-9.4/bin/pg_config: No such file or directory
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***

extconf failed, exit code 1

An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.4' succeeds before bundling.
run bundle exec spring binstub --all
/Users/[username]/.rvm/gems/ruby-2.1.1/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /usr/local/Cellar in PATH, mode 040777

/Users/[username]/.rvm/gems/ruby-2.1.1/gems/bundler-1.11.2/lib/bundler/resolver.rb:354:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'pg' in any of the gem sources listed in your Gemfile or available on this machine. (Bundler::GemNotFound)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

依存するpgをインストール中にエラーが起きています。
gem install pg -v '0.18.4'はしましたか?

若干気になるのは
**sh: /usr/pgsql-9.4/bin/pg_config: No such file or directory **
のエラーです。
通常/usrディレクトリ下にpgsql-9.4というディレクトリは作りません(なのでfileがないのはある意味当然)。直近の原因は,

/Users/[username]/.rbenv/versions/2.1.3/bin/ruby extconf.rb --with-pg-config=/usr/pgsql-9.4/bin/pg_config

のエラーログ中,--with-pg-config=でくだんのディレクトリを指定していることです。が,このような指定はどの時点で出てきたのかが不明です。

とりあえず,単体で先にpgをインストールしてから,再度トライしてみてください。

投稿2016/03/06 00:33

NCC1701

総合スコア1680

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Moto_hero

2016/03/06 15:09

以上の操作を行うと、$rails new memo2 -d postgresql は完了したっぽいです。 Bundle complete! 10 Gemfile dependencies, 44 gems now installed. Use `bundle show [gemname]` to see where a bundled gem is installed. run bundle exec spring binstub --all /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /usr/local/Cellar in PATH, mode 040777 /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /usr/local/Cellar in PATH, mode 040777 * bin/rake: spring inserted * bin/rails: spring inserted その後、rails sでサーバーを起動しましたが、下記のエラーが出来きて" http://192.168.78.90:3000" はサーバーが応答せず何も表示されませんでした。 motohiro:desktop programeen$ cd memo2 motohiro:memo2 programeen$ vi Gemfile motohiro:memo2 programeen$ rails s /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /usr/local/Cellar in PATH, mode 040777 /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /usr/local/Cellar in PATH, mode 040777 => Booting WEBrick => Rails 4.1.1 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server [2016-03-06 22:54:49] INFO WEBrick 1.3.1 [2016-03-06 22:54:49] INFO ruby 2.1.2 (2014-05-08) [x86_64-darwin15.0] [2016-03-06 22:54:49] INFO WEBrick::HTTPServer#start: pid=26695 port=3000 ここで、localhost:3000で表示させてみると、画面には ” PG::ConnectionBad could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? ”と言うエラーが、 そしてterminalに戻ってみると、下記の表示でした。 Started GET "/" for 127.0.0.1 at 2016-03-07 00:07:24 +0900 PG::ConnectionBad (could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? ): activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `initialize' activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `new' activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `connect' activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize' activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new' activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout' /Users/takayanagimotohiro/.rbenv/versions/2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection' /Users/takayanagimotohiro/.rbenv/versions/2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection' activerecord (4.1.1) lib/active_record/connection_handling.rb:113:in `retrieve_connection' activerecord (4.1.1) lib/active_record/connection_handling.rb:87:in `connection' activerecord (4.1.1) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings' activerecord (4.1.1) lib/active_record/query_cache.rb:43:in `rescue in call' activerecord (4.1.1) lib/active_record/query_cache.rb:32:in `call' activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call' activerecord (4.1.1) lib/active_record/migration.rb:380:in `call' actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks' actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call' actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app' railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.1.1) lib/rails/rack/logger.rb:20:in `call' actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.5.5) lib/rack/methodoverride.rb:21:in `call' rack (1.5.5) lib/rack/runtime.rb:17:in `call' activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call' rack (1.5.5) lib/rack/lock.rb:17:in `call' actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call' rack (1.5.5) lib/rack/sendfile.rb:112:in `call' railties (4.1.1) lib/rails/engine.rb:514:in `call' railties (4.1.1) lib/rails/application.rb:144:in `call' rack (1.5.5) lib/rack/lock.rb:17:in `call' rack (1.5.5) lib/rack/content_length.rb:14:in `call' rack (1.5.5) lib/rack/handler/webrick.rb:60:in `service' /Users/takayanagimotohiro/.rbenv/versions/2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service' /Users/takayanagimotohiro/.rbenv/versions/2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run' /Users/takayanagimotohiro/.rbenv/versions/2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread' Rendered /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.8ms) Rendered /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.9ms) Rendered /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.5ms) Rendered /Users/takayanagimotohiro/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (32.5ms)
NCC1701

2016/03/09 04:02

エラーログで指示されたことはやりましたか? Use `bundle show [gemname]` to see where a bundled gem is installed. run bundle exec spring binstub --all それと PG::ConnectionBad (could not connect to server: No such file or directory に関しては,類似の質問が出てます。 https://teratail.com/questions/27068 以上を参考にエラーを潰してみてください。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問