Ruby on rails 4 Capistrano与Bundler,rbenv未能安装pg gem

Ruby on rails 4 Capistrano与Bundler,rbenv未能安装pg gem,ruby-on-rails-4,bundler,rbenv,capistrano3,pg,Ruby On Rails 4,Bundler,Rbenv,Capistrano3,Pg,我相当肯定这是一个路径问题,但我已竭尽全力试图解决它。希望其中一个巫师能帮上忙。以下是一些相关信息: System: Ubuntu 16.04 LTS running on Cloud Environment Manager: Chef 12.21.3 rbenv version 0.4.0 installed via Chef ruby_rbenv cookbook bundler version: 1.15.1 installed via ruby_rbenv LWRP sy

我相当肯定这是一个路径问题,但我已竭尽全力试图解决它。希望其中一个巫师能帮上忙。以下是一些相关信息:

 System: Ubuntu 16.04 LTS running on Cloud
 Environment Manager: Chef 12.21.3

 rbenv version    0.4.0 installed via Chef ruby_rbenv cookbook
 bundler version: 1.15.1 installed via ruby_rbenv LWRP systemwide
 libpq-dev:       INSTALLED
 ruby-build:      INSTALLED
 PostGreSQL-9.5:  INSTALLED
 Alterations to .bashrc?             NO
 Alterations to PATH in capistrano?  NO

 Thus far I have been able to do everything through set directives in capistrano
现在是有趣的事情

Gemfile 卡普里 相关部署信息 问题 MKMF.log 珠宝店 怪诞 我真的被难倒了。我已经尝试配置这台机器两天了,但却一无所获


非常感谢您的帮助。

您可以从服务器控制台尝试此命令:

sudo apt-get install libpq-dev build-essential postgresql-server-dev-9.5
然后试着去做

gem install pg
解决方案
这个问题与Chef部署rbenv和安装bundler以及执行ruby build的正确安装有关。通过手动配置VM并启动部署过程,问题得以解决

dev@app-1:~$sudo apt get安装构建基本阅读包列表。。。已完成构建依赖关系树以读取状态信息。。。Done build essential已是最新版本12.1ubuntu2。0已升级,0已新安装,0已删除,3未升级。此问题与缺少包无关。如果您注意到标题为“怪异”的部分,gem可以安装。这个问题与Capistrano/Rbenv/BundlerI有关。我刚刚将Capistrano的典型配置文件与您的文件进行了比较,发现有一点不同:在Capfile中,我指定了Rbenv版本-set:Rbenv_ruby,'2.3.4'。我没有设置这个行:bundle\u path,->{shared\u path.join'bundle}设置这个变量会导致部署失败。我们使用.ruby版本来控制应用程序的ruby版本,并设置:rbenv_type,:user。您正在使用:system TYPE这是因为rbenv是在系统级别而不是用户级别配置的。
set :rbenv_type, :system
set :bundle_flags, "--deployment --quiet --binstubs --shebang ruby-local-exec"
set :bundle_path, -> { shared_path.join('bundle') }
set :linked_files, %w{config/database.yml}
# Even in staging, we're testing against the production settings... that's the point.
set :rails_env, :production

# clean up old assets after each deploy,
# set this to the number of versions to keep
set :keep_assets, 2

# Rails handles this through its framework migrations.
set :migration_role, :app

# Defaults to the primary :db server
# However, by setting it up like this, the role handling the migration is the one that runs
# the rake db:migrate command.
set :migration_servers, -> { primary(fetch(:migration_role)) }

set :conditionally_migrate, true

set :assets_roles, [:web]

# Defaults to 'assets'
# This should match config.assets.prefix in your rails config/application.rb
# ... but we don't have that configuration option set. A lot of reading I did pointed
# to the inclusion of this command, but I am going to leave it out on the premise that
# we do not have the config.assets.prefix set for a good reason. If this changes,
# then uncomment the following line:
# set :assets_prefix, 'prepackaged-assets'

# If you need to touch public/images, public/javascripts, and public/stylesheets on each deploy
#set :normalize_asset_timestamps, %w{public/images public/javascripts public/stylesheets}
 01  /usr/local/rbenv/bin/rbenv exec bundle install --path <OMITTED>/shared/bundle --without development test --deployment --quiet --binstubs --shebang ruby-local-exec
 ** DEPLOY FAILED
 ** Refer to log/capistrano.log for details. Here are the last (more than 20) lines:
 /usr/local/rbenv/bin/rbenv exec bundle install --path <OMITTED>/shared/bundle --without development test --deployment --quiet --binstubs --shebang ruby-local-exec
 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

 current directory:
 <OMITTED>/shared/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
 /usr/local/rbenv/versions/2.3.4/bin/ruby -r ./siteconf20170711-55875-b7vll7.rb
 extconf.rb --with-pg_config=/usr/bin/pg_config
 Using config values from /usr/bin/pg_config
 sh: 1: /usr/bin/pg_config: not found
 sh: 1: /usr/bin/pg_config: not found
 checking for libpq-fe.h... no
 Can't find the 'libpq-fe.h header
 *** extconf.rb failed ***
<SNIP>

extconf failed, exit code 1

Gem files will remain installed in
<OMITTED>/shared/bundle/ruby/2.3.0/gems/pg-0.18.4 for inspection.
Results logged to
<OMITTED>/shared/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/gem_make.out

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.

In Gemfile:
  pg
Relevant:
find_executable: checking for pg_config... -------------------- yes

--------------------

find_header: checking for libpq-fe.h... -------------------- yes
< The rest of this is too large to put here. It is available on request>
cat ./shared/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/gem_make.out
current directory: <OMITTED>/shared/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
/usr/local/rbenv/versions/2.3.4/bin/ruby -r ./siteconf20170707-35742-1cvk2th.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for rb_str_modify_expand()... yes
checking for rb_hash_dup()... yes
checking for PGRES_COPY_BOTH in libpq-fe.h... yes
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... yes
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for ruby/st.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  <OMITTED>/shared/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/mkmf.log

current directory: <OMITTED>/shared/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
make "DESTDIR=" clean

current directory: <OMITTED>/shared/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
make "DESTDIR="
compiling pg_type_map_by_mri_type.c
compiling pg_coder.c
compiling pg_type_map_by_column.c
compiling pg_result.c
compiling pg_type_map_in_ruby.c
compiling pg_errors.c
compiling pg.c
compiling util.c
compiling pg_type_map_by_class.c
compiling pg_copy_coder.c
compiling pg_type_map.c
compiling pg_text_encoder.c
compiling pg_binary_encoder.c
compiling pg_connection.c
pg_connection.c: In function ‘wait_socket_readable’:
pg_connection.c:2394:3: warning: implicit declaration of function ‘gettimeofday’ [-Wimplicit-function-declaration]
   gettimeofday(&currtime, NULL);
   ^
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_oid.c
compiling gvl_wrappers.c
compiling pg_text_decoder.c
compiling pg_binary_decoder.c
linking shared-object pg_ext.so

current directory: <OMITTED>/shared/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
make "DESTDIR=" install
/usr/bin/install -c -m 0755 pg_ext.so ./.gem.20170707-35742-11dgneo
dev@app-1:<OMITTED>/releases/20170711040154$ bundle install
The git source `git://github.com/activeadmin/activeadmin.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using sass 3.4.22
Using thor 0.19.1
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using formtastic_i18n 0.6.0
Using mime-types 2.99.1
Using arel 6.0.3
Using concurrent-ruby 1.0.1
Using bundler 1.15.1
Using tilt 2.0.2
Using multi_json 1.12.1
Using bcrypt 3.1.11
Using addressable 2.4.0
Using orm_adapter 0.5.0
Using multipart-post 2.0.0
Using hashie 3.4.6
Using geocoder 1.3.3
Using redis 3.2.2
Using newrelic_rpm 3.15.1.316
Using jwt 1.5.1
Using multi_xml 0.5.5
Using pg 0.18.4
Using puma 3.4.0
Using phantomjs 2.1.1.0
Using cliver 0.3.2
Using websocket-extensions 0.1.2
Using rack-ssl-enforcer 0.2.9
Using raphael-rails 2.1.2
Using connection_pool 2.2.0
Using unf_ext 0.0.7.2
Using netrc 0.11.0
Using switch_user 1.2.1
Using simple_oauth 0.3.1
Using net-ssh 3.1.1
Using fast-stemmer 1.0.2
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.5
Using rdoc 4.2.2
Using tzinfo 1.2.2
Using bourbon 4.2.6
Using coffee-script 2.4.1
Using uglifier 3.0.0
Using nokogiri 1.6.7.2
Using rack-test 0.6.3
Using warden 1.2.6
Using mail 2.6.4
Using sprockets 3.6.0
Using airbrake 4.3.6
Using bcrypt-ruby 3.1.5
Using faraday 0.9.2
Using message_bus 1.1.1
Using redis-namespace 1.5.2
Using websocket-driver 0.6.3
Using sidekiq 4.1.1
Using unf 0.1.4
Using rails_12factor 0.0.3
Using sdoc 0.4.1
Using activesupport 4.2.6
Using loofah 2.0.3
Using xpath 2.0.0
Using faraday_middleware 0.10.0
Using forecast_io 2.0.1
Using oauth2 1.1.0
Using domain_name 0.5.20160310
Using arbre 1.0.3
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.6
Using activemodel 4.2.6
Using activesupport-json_encoder 1.1.0
Using jbuilder 2.4.1
Using rails-html-sanitizer 1.0.3
Using capybara 2.7.0
Using yelp 2.1.2
Using http-cookie 1.0.2
Using rails-dom-testing 1.0.7
Using activejob 4.2.6
Using activerecord 4.2.6
Using poltergeist 1.9.0
Using rest-client 1.8.0
Using actionview 4.2.6
Using polyamorous 1.3.0
Using stripe 1.42.0
Using actionpack 4.2.6
Using railties 4.2.6
Using formtastic 3.1.4
Using has_scope 0.6.0
Using kaminari 0.16.3
Using actionmailer 4.2.6
Using sprockets-rails 3.0.4
Using ransack 1.7.0
Using heroku_rails_deflate 1.0.3
Using coffee-rails 4.1.1
Using responders 2.1.2
Using jquery-rails 4.1.1
Using jquery-ui-rails 5.0.5
Using morrisjs-rails 0.5.1
Using rails 4.2.6
Using sass-rails 5.0.4
Using inherited_resources 1.6.0
Using devise 3.5.6
Using angular_rails_csrf 1.0.4
Using activeadmin 1.0.0.pre2 from git://github.com/activeadmin/activeadmin.git (at master@d84f819)
Bundle complete! 60 Gemfile dependencies, 111 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into <OMITTED>/shared/bundle.
sudo apt-get install libpq-dev build-essential postgresql-server-dev-9.5
gem install pg