新手问题 mina + rbenv 部署问题

cysh · 2015年05月18日 · 最后由 etnl 回复于 2015年05月19日 · 3397 次阅读

好像是 Ruby 环境出了点问题,mina deploy 到 bundle 的时候,会报错,提示安装 rake 10.4.2 服务器上默认 ruby version 是 2.1.3,gem list 中 rake version 默认是 10.4.2 项目下添加了.ruby-version 为什么会有环境问题…?到底是哪里出了问题…求指点迷津……

贴一下 config/deploy.rb

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'  # for rbenv support. (http://rbenv.org)

set :domain, 'my_ip'
set :deploy_to, '/home/user/apps/project'
set :repository, 'git@my_git_address.git'
set :branch, 'dev'
set :rbenv_path, '/home/user/.rbenv'

# For system-wide RVM install.
#   set :rvm_path, '/usr/local/rvm/bin/rvm'

# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/settings.yml']

# Optional settings:
   set :user, 'deploy_user'    # Username in the server to SSH to.
   set :port, '22'     # SSH port number.

task :environment do
  queue %{export RBENV_ROOT=#{rbenv_path}}
  invoke :'rbenv:load'
end

task :setup => :environment do
  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]

  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]

  queue! %[touch "#{deploy_to}/#{shared_path}/config/settings.yml"]
  queue  %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/settings.yml'."]
end

desc "Deploys the current version to the server."
task :deploy => :environment do
  to :before_hook do
    # Put things to run locally before ssh
  end
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    to :launch do
      queue "touch tmp/restart.txt"
    end
  end
end

我错了。。该问题是 gem 源花式抽风造成的,最后的解决办法是淘宝源和 rubygems 来回切换了十多回总算把 bundle 跑完了…但还是很疑惑 mina deploy 过程为什么要重新 install list 中已经存在的 gem。。目前 mina 还在抽风中,各种不明 failed…唉,结贴

task :environment do
  # If you're using rbenv, use this to load the rbenv environment.
  # Be sure to commit your .rbenv-version to your repository.
  # invoke :'rbenv:load'

  # For those using RVM, use this to load an RVM version@gemset.
  # invoke :'rvm:use[ruby-2.2.2]'
end

deploy 环境下找不到 rake 命令

#2 楼 @liwei78 #1 楼 @ruby_sky 两位好,主题里加了我的配置。

gem list | grep rake
>rake (10.4.2, 10.1.0)

@liwei78 deploy user 登陆以后能找到 rake 哦…

#3 楼 @cysh 把错误信息贴出来。

#4 楼 @ruby_sky

$ mina deploy
-----> Loading rbenv        
-----> Creating a temporary build path        
-----> Fetching new git commits        
-----> Using git branch 'dev'        
       Cloning into '.'...
       done.
-----> Using this git commit        

       cysh (873d7c3): 
       > 修改ruby version 

-----> Symlinking shared paths        
-----> Installing gem dependencies using Bundler        
       Fetching gem metadata from https://rubygems.org/........... 
       Fetching version metadata from https://rubygems.org/... 
       Fetching dependency metadata from https://rubygems.org/.. 

       Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/r       Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/rake-10.4.2.gem)
       An error occurred while installing rake (10.4.2), and Bundler cannot continue. 
       Make sure that `gem install rake -v '10.4.2'` succeeds before bundling. 
 !     ERROR: Deploy failed.   
-----> Cleaning up build        
       Unlinking current 
       OK 

 !     Command failed.
       Failed with status 19

把 Gemfile 的 source 换成 https://ruby.taobao.org

#6 楼 @ruby_sky 大哥!真是 gem 源的毛病,两个源来回切换了十好几回终于把 bundle 跑完了…… 我真想一掌拍死自己…好好的 Capistrano 不用,换什么 mina…&%¥@¥…

#7 楼 @cysh 这个跟 mina 有什么关系?你要怪 GFW。

#8 楼 @ruby_sky 。。。我只是觉得自己花了一下午做了件特别撒比的事情

#8 楼 @ruby_sky 总之…谢谢啦。。

bundle package

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册