2012-10-08 52 views
2

我想在deploy.rb添加一個配置參數,以便pg寶石建立正確:束配置無法找到的Gemfile

before "bundle:install" do 
    run "ls -l #{fetch(:latest_release)}/Gemfile" 
    run "bundle config --local --gemfile=#{fetch(:latest_release)}/Gemfile build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config" 
end 

在輸出中,診斷代碼添加清楚地表明存在非空的Gemfile的:

* executing `bundle:install' 
    triggering before callbacks for `bundle:install' 
    * executing "ls -l /apps/my_app/releases/20121008195429/Gemfile" 
    servers: ["my_server.com"] 
    [my_server.com] executing command 
** [out :: my_server.com] -rw-r--r-- 1 webapp webapp 1291 Oct 5 22:34 /apps/my_app/releases/20121008195429/Gemfile 
    command finished in 157ms 
    * executing "bundle config --local --gemfile=/apps/my_app/releases/20121008195429/Gemfile build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config" 
    servers: ["my_server.com"] 
    [my_server.com] executing command 
** [out :: my_server.com] Could not locate Gemfile 

我得到同樣的結果,如果我用--global--local。如果我刪除global/local標誌,我得到一個不同的錯誤:

** [out :: my_server.com] Invalid scope --gemfile=/apps/my_app/releases/20121008194937/Gemfile given. Please use --local or --global. 

似乎有是一個全局配置或上下文是混亂的情況。我怎樣才能讓bundle config看到我的Gemfile?有一個更好的方法嗎?

回答

10

相反在bundle install命令中使用的--gemfile標誌,在bundle config標誌僅識別名稱的Gemfile的

# man bundle-config 
... 
gemfile (BUNDLE_GEMFILE) 
The name of the file that bundler should use as the Gemfile. This location of this file 
also sets the root of the project, which is used to resolve relative paths in the Gemfile, 
among other things. By default, bundler will search up from the current working directory 
until it finds a Gemfile. 

我通過cd'ing到該目錄的第一固定的問題:

run "cd #{fetch(:latest_release)} && bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config" 

更多信息: http://gembundler.com/man/bundle-install.1.html & http://gembundler.com/man/bundle-config.1.html

+0

每當有一個bundle配置問題,總是pg-config是罪魁禍首。爲什麼?!! –