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

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

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

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Ruby

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

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

解決済

2回答

856閲覧

rails new でエラーが発生する件

big_sky

総合スコア23

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Ruby

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

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

0クリップ

投稿2020/03/03 04:25

railsの書籍を購入し早速進めていたのですが、rails newするとことで本では載っていないエラーが発生して困っています。
まだrubyの勉強を初めてばかりということもあってすぐに解決することができません。
何か助言を頂けると幸いです。
ディレクトリは、/home/vagrant/workspace/ruby_appで、
ruby_app配下にアプリを作成しようとしています。

環境
・centos7
・vagrant
・rbenv 2.6.2
・Rails 5.1.7
・psql (PostgreSQL) 11.7
・Bundler version 2.1.4
・gem 3.0.3

[vagrant@localhost ruby_app]$ rails new scaffold_app -d postgresql create create README.md create Rakefile create config.ru create .gitignore create Gemfile run git init from "." /home/vagrant/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/actions.rb:266: warning: Insecure world writable dir /home/vagrant/.rbenv in PATH, mode 040777 Initialized empty Git repository in /home/vagrant/workspace/ruby_app/scaffold_app/.git/ create app create app/assets/config/manifest.js create app/assets/javascripts/application.js create app/assets/javascripts/cable.js create app/assets/stylesheets/application.css create app/channels/application_cable/channel.rb create app/channels/application_cable/connection.rb create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/jobs/application_job.rb create app/mailers/application_mailer.rb create app/models/application_record.rb create app/views/layouts/application.html.erb create app/views/layouts/mailer.html.erb create app/views/layouts/mailer.text.erb create app/assets/images/.keep create app/assets/javascripts/channels create app/assets/javascripts/channels/.keep create app/controllers/concerns/.keep create app/models/concerns/.keep create bin create bin/bundle create bin/rails create bin/rake create bin/setup create bin/update create bin/yarn create config create config/routes.rb create config/application.rb create config/environment.rb create config/secrets.yml create config/cable.yml create config/puma.rb create config/spring.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/application_controller_renderer.rb create config/initializers/assets.rb create config/initializers/backtrace_silencers.rb create config/initializers/cookies_serializer.rb create config/initializers/cors.rb create config/initializers/filter_parameter_logging.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/new_framework_defaults_5_1.rb create config/initializers/wrap_parameters.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create lib create lib/tasks create lib/tasks/.keep create lib/assets create lib/assets/.keep create log create log/.keep create public create public/404.html create public/422.html create public/500.html create public/apple-touch-icon-precomposed.png create public/apple-touch-icon.png create public/favicon.ico create public/robots.txt create test/fixtures create test/fixtures/.keep create test/fixtures/files create test/fixtures/files/.keep create test/controllers create test/controllers/.keep create test/mailers create test/mailers/.keep create test/models create test/models/.keep create test/helpers create test/helpers/.keep create test/integration create test/integration/.keep create test/test_helper.rb create test/system create test/system/.keep create test/application_system_test_case.rb create tmp create tmp/.keep create tmp/cache create tmp/cache/assets create vendor create vendor/.keep create package.json remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_5_1.rb run bundle install [DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env` (called at /home/vagrant/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/railties-5.1.7/lib/rails/generators/app_base.rb:385) The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Fetching gem metadata from https://rubygems.org/............ Fetching gem metadata from https://rubygems.org/. Resolving dependencies.... Using rake 13.0.1 Using concurrent-ruby 1.1.6 Using i18n 1.8.2 Using minitest 5.14.0 Using thread_safe 0.3.6 Using tzinfo 1.2.6 Using activesupport 5.1.7 Using builder 3.2.4 Using erubi 1.9.0 Using mini_portile2 2.4.0 Using nokogiri 1.10.9 Using rails-dom-testing 2.0.3 Using crass 1.0.6 Using loofah 2.4.0 Using rails-html-sanitizer 1.3.0 Using actionview 5.1.7 Using rack 2.2.2 Using rack-test 1.1.0 Using actionpack 5.1.7 Using nio4r 2.5.2 Using websocket-extensions 0.1.4 Using websocket-driver 0.6.5 Using actioncable 5.1.7 Using globalid 0.4.2 Using activejob 5.1.7 Using mini_mime 1.0.2 Using mail 2.7.1 Using actionmailer 5.1.7 Using activemodel 5.1.7 Using arel 8.0.0 Using activerecord 5.1.7 Using public_suffix 4.0.3 Using addressable 2.7.0 Using bindex 0.8.1 Using bundler 2.1.4 Using byebug 11.1.1 Using regexp_parser 1.7.0 Using xpath 3.2.0 Using capybara 3.31.0 Using childprocess 3.0.0 Using coffee-script-source 1.12.2 Using execjs 2.7.0 Using coffee-script 2.4.1 Using method_source 0.9.2 Using thor 1.0.1 Using railties 5.1.7 Using coffee-rails 4.2.2 Using ffi 1.12.2 Using jbuilder 2.10.0 Using rb-fsevent 0.10.3 Using rb-inotify 0.10.1 Using ruby_dep 1.5.0 Using listen 3.1.5 Fetching pg 1.2.2 Installing pg 1.2.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/vagrant/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/pg-1.2.2/ext /home/vagrant/.rbenv/versions/2.6.2/bin/ruby -I /home/vagrant/.rbenv/versions/2.6.2/lib/ruby/2.6.0 -r ./siteconf20200303-12061-1x7ev5z.rb extconf.rb checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/vagrant/.rbenv/versions/2.6.2/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/vagrant/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/pg-1.2.2/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/vagrant/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/pg-1.2.2 for inspection. Results logged to /home/vagrant/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/pg-1.2.2/gem_make.out An error occurred while installing pg (1.2.2), and Bundler cannot continue. Make sure that `gem install pg -v '1.2.2' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: pg run bundle exec spring binstub --all bundler: command not found: spring Install missing gem executables with `bundle install`

---やってみたこと---
言われた通りに、gem install pg -v '1.2.2'
をすると、>と出てきて、何か打たないといけない感じになり、それ以降何をしればいいのか分かりませんでした。
bundle installをすると、Could not locate Gemfile
と表示されました。ですがそれ以降の操作がわかりませんでした。

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

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

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

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

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

guest

回答2

0

No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** extconf.rb failed ***

Postgresqlの開発用ヘッダファイル(libpq-fe.h)が無い結果、一連の処理が
失敗しているようです。
必要なパッケージ(OSの)が不足しているのでしょう。

CentOSはあまり詳しくないのでググってみましたら、

libpq-fe.h が見つけられない。
https://qiita.com/s_osa/items/9b72643c9f7185736395

「libpq-fe.h が見つけられない。」の解決法でも上手く行かない場合
https://qiita.com/s-yank/items/035938249ba3b158b865

などの記事が見つかりました。
参考にしてみてはいかがでしょう。

投稿2020/03/03 05:20

technocore

総合スコア7200

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

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

0

ベストアンサー

No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
「ビルドに失敗したら --with-pg-config=/path/to/pg_configつけて試せ」
っていわれてるのでとりあえず試してみましょう

Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details
「よくわからんけど多分必要なライブラリかヘッダーがねえわ。mkmf.logで詳細を見てくれ」
って言われてるのでmkmf.logを検索して中を見てみましょう。Errorが出てるところを見ると、どのライブラリがなくて失敗した!!みたいなことが書いてあるので(書いてあることが多いので)、そのライブラリをinstallしてから再度試しましょう

投稿2020/03/03 04:33

sansansandodo

総合スコア248

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

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

big_sky

2020/03/03 05:14

--with-pg-config=/path/to/pg_config ->pg_configのパスって何だろう、調べてたら, sudo yum -y install postgresql-devel が必要みたいでした。 無事アプリ作成できました。 調べるきっかけを作ってくださりありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問