我正在寻找一种方法来安装rvm,安装特定的ruby版本(使用rvm)并将此安装的ruby版本设置为默认值。在我安装rvm之前,我必须安装gcc和其他一些非常基本的软件包。到目前为止我尝试过的:
1)使用net / ssh
2)使用capistrano
在ssh输出中插入换行符,以便每次都在新行中打印一个进度条,进行一些处理。这是我可以忍受的东西。
与rmv相同的问题,我可以安装rvm,但我无法设置默认值:例如rvm --default use 1.9.2
。没有错误消息,但是当我稍后登录时,没有设置默认值,ruby -v
显示旧系统ruby。
3)使用capistrano和rvm-capistrano
* executing "sudo -p 'sudo password: ' yum install --assumeyes git gcc-c++ autoconf automake make patch zlib-devel libtool bzip2-devel" servers: ["ec2-54-247-142-214.eu-west-1.compute.amazonaws.com"] [ec2-54-247-142-214.eu-west-1.compute.amazonaws.com] executing command ** [out :: ec2-54-247-142-214.eu-west-1.compute.amazonaws.com] bash: /home/ec2-user/.rvm/bin/rvm-shell: No such file or directory command finished in 2094ms failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'default' -c 'sudo -p '\\''sudo password: '\\'' yum install --assumeyes git gcc-c++ autoconf automake make patch zlib-devel libtool bzip2-devel'" on ec2-54-247-142-214.eu-west-1.compute.amazonaws.com rake aborted!
这里是我发出安装rvm / ruby的命令:
run 'curl -L https://get.rvm.io | bash -s stable'
run 'rvm install ruby-1.9.2-p320'
run 'echo "[[ -s \"\$HOME/.rvm/scripts/rvm\" ]] && source \"\$HOME/.rvm/scripts/rvm\"" >> .bashrc'
run 'rvm --default use ruby-1.9.2-p320'
run 'which ruby && ruby -v'
这里是作为对rvm --default use 1.9.2
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal settings to allow shell login.
Please visit https://rvm.io/workflow/screen/ for example.
4.1)使用capistrano和rvm-capistrano并进行一些黑客攻击
更新:在RVM聊天的mpapis的帮助下,我现在能够提出这个有效的解决方案: 要求“rvm / capistrano”
role :server, ENV[ 'base_image_setup_server' ] if ENV[ 'base_image_setup_server' ]
default_run_options[:pty] = true
default_run_options[:shell] = :bash
set :rvm_ruby_string, 'ruby-1.9.2-p320'
set :rvm_type, :user
def rvm_bin
'$HOME/.rvm/bin/rvm'
end
namespace :images do
task :install_basics do
run "#{sudo} yum install --assumeyes git gcc-c++ autoconf automake make patch zlib-devel libtool bzip2-devel"
run "#{sudo} yum update --assumeyes"
end
task :install_ruby do
rvm.install_rvm
rvm.install_ruby
run "#{rvm_bin} alias create default #{rvm_ruby_string}"
run 'echo "source ~/.rvm/environments/default" >> $HOME/.bashrc'
run 'which ruby && ruby -v'
end
...
desc 'build the base-image'
task :base_image do
install_basics
install_ruby
install_boost
install_rake_and_rack
install_sioux
test_sioux
end
主要不同的是,RVM 不用作函数,但程序直接使用。
亲切的问候, 托斯滕答案 0 :(得分:2)
检查RVM网站是否有Capistrano集成https://rvm.io/integration/capistrano
安装RVM和Ruby有任务:
after 'deploy:setup', 'ubuntu:install'
after 'deploy:setup', 'rvm:install_rvm' # do it only with deploy setup
before 'deploy', 'rvm:install_ruby' # do it on every deploy
namespace :ubuntu do
desc "setup ubuntu system"
task :install do
run "apt-get install -y make ...", :shell => "sh"
...
end
end
你运行标准:
cap deploy:setup
cap deploy:cold
另外,您可能希望查看我的示例rails应用程序,了解简单且有效的部署脚本:https://github.com/mpapis/ad以及我的博客文章:http://niczsoft.com/2012/03/fast-deployment-using-capistrano-rvm-and-more/