- 在ruby 2.2.1 和 rails 4.2.2 以及 capistrano 3.4.0 环境中 需要进行如下配置
在web_app/config/deploy/production.rb文件中 加入
set :default_env, { "LD_LIBRARY_PATH" => "/opt/oracle/instantclient_12_1" , "ORACLE_HOME" => '/opt/oracle/instantclient_12_1' , "NLS_LANG" => 'AMERICAN_AMERICA.UTF8' }
- 在 capistrano 2版本中 要进行如下处理
1.由于使用了 orcale的adapter
安装 ruby-oci8 -v '2.1.5'` 的时候会出现
** [out :: 192.168.10.188] /home/dev/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
** [out :: 192.168.10.188] checking for load library path...
** [out :: 192.168.10.188] LD_LIBRARY_PATH is not set.
** [out :: 192.168.10.188] checking ld.so.conf... no
** [out :: 192.168.10.188] checking for cc... ok
** [out :: 192.168.10.188] checking for gcc... yes
** [out :: 192.168.10.188] checking for LP64... yes
** [out :: 192.168.10.188] checking for sys/types.h... yes
** [out :: 192.168.10.188] checking for ruby header... ok
** [out :: 192.168.10.188] *** extconf.rb failed ***
** [out :: 192.168.10.188] Could not create Makefile due to some reason, probably lack of necessary
** [out :: 192.168.10.188] libraries and/or headers. Check the mkmf.log file for more details. You may
** [out :: 192.168.10.188] need configuration options.
** [out :: 192.168.10.188]
** [out :: 192.168.10.188] Provided configuration options:
** [out :: 192.168.10.188] --with-opt-dir
** [out :: 192.168.10.188] --without-opt-dir
** [out :: 192.168.10.188] --with-opt-include
** [out :: 192.168.10.188] --without-opt-include=${opt-dir}/include
** [out :: 192.168.10.188] --with-opt-lib
** [out :: 192.168.10.188] --without-opt-lib=${opt-dir}/lib
** [out :: 192.168.10.188] --with-make-prog
** [out :: 192.168.10.188] --without-make-prog
** [out :: 192.168.10.188] --srcdir=.
** [out :: 192.168.10.188] --curdir
** [out :: 192.168.10.188] --ruby=/home/dev/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
** [out :: 192.168.10.188] --with-instant-client
** [out :: 192.168.10.188] --without-instant-client
** [out :: 192.168.10.188] /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:889:in `get_home': RuntimeError (RuntimeError)
** [out :: 192.168.10.188] from /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:705:in `initialize'
** [out :: 192.168.10.188] from /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
** [out :: 192.168.10.188] from /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get'
** [out :: 192.168.10.188] from extconf.rb:18:in `<main>'
** [out :: 192.168.10.188] ---------------------------------------------------
** [out :: 192.168.10.188] Error Message:
** [out :: 192.168.10.188] Set the environment variable ORACLE_HOME if Oracle Full Client.
** [out :: 192.168.10.188] Append the path of Oracle client libraries to LD_LIBRARY_PATH if Oracle Instant Client.
** [out :: 192.168.10.188]
** [out :: 192.168.10.188] Backtrace:
** [out :: 192.168.10.188] /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:889:in `get_home'
** [out :: 192.168.10.188] /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:705:in `initialize'
** [out :: 192.168.10.188] /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
** [out :: 192.168.10.188] /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get'
** [out :: 192.168.10.188] extconf.rb:18:in `<main>'
** [out :: 192.168.10.188] ---------------------------------------------------
** [out :: 192.168.10.188] See:
** [out :: 192.168.10.188] * http://ruby-oci8.rubyforge.org/en/HowToInstall.html
** [out :: 192.168.10.188] * http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html
** [out :: 192.168.10.188]
** [out :: 192.168.10.188]
** [out :: 192.168.10.188]
** [out :: 192.168.10.188] Gem files will remain installed in /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5 for inspection.
** [out :: 192.168.10.188] Results logged to /home/dev/SysMaintain/shared/bundle/ruby/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/gem_make.out
** [out :: 192.168.10.188] An error occurred while installing ruby-oci8 (2.1.5), and Bundler cannot
** [out :: 192.168.10.188] continue.
** [out :: 192.168.10.188] Make sure that `gem install ruby-oci8 -v '2.1.5'` succeeds before bundling.
错误,
解决办法 :
在 config/deploy.rb 中 设置环境变量
# -*- encoding : utf-8 -*-
require "rvm/capistrano"
require "bundler/capistrano"
default_environment["LD_LIBRARY_PATH"] = "/opt/oracle/instantclient_12_1"
default_environment["ORACLE_HOME"]= '/opt/oracle/instantclient_12_1'
default_environment["NLS_LANG"] = 'AMERICAN_AMERICA.UTF8'
set :application, "SysMaintain"