-1

我正在使用whiskey_disk 来处理部署。这不是whiskey_disk 问题,但它所做的是在完成从git 克隆到项目目标目录后运行部署后脚本。我试图部署的脚本是调用 abundle install并且看起来有点像这样:

#!/bin/bash

# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
  source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
  source "/usr/local/rvm/scripts/rvm"
else
  printf "ERROR: An RVM installation was not found.\n"
fi

export PATH=/home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/gems/ruby-2.0.0-p247@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin

echo "["`hostname`"] Installing the bundle..."
bundle install --binstubs --local --path ../shared/bundle --deployment --without development test console replication|grep -vi using

这失败了,并且无法找到bundleor rake,即使它在我的$PATH上面明确设置:

/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0) among 90 total gem(s) (Gem::LoadError)
    from /home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    from /home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /home/ec2-user/.rvm/gems/ruby-2.0.0-p247@global/bin/bundle:22:in `<main>'
    from /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
    from /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'rake' (>= 0) among 90 total gem(s) (Gem::LoadError)
    from /home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    from /home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /home/ec2-user/.rvm/gems/ruby-2.0.0-p247@global/bin/rake:22:in `<main>'
    from /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
    from /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'

以为我在脚本开头很好地初始化了上面的环境,并另外设置了我的 PATH ,你可以看到它在交互式 shell 中很好:

[ec2-user@ip-1 ~]$ which bundle
~/.rvm/gems/ruby-2.0.0-p247@global/bin/bundle
[ec2-user@ip-1 ~]$ which rake
~/.rvm/gems/ruby-2.0.0-p247@global/bin/rake

关于还有什么可能是问题的任何建议?

4

1 回答 1

2

RVM 通过更改 3 个环境变量(最小集)来工作,仅更改 是不够的PATH,您还需要更改GEM_HOMEGEM_PATH

最简单的方法是替换这一行:

export PATH=...

和:

rvm use 2.0.0

然后 RVM 进行环境加载,一切都应该正常工作。

于 2013-09-13T05:13:33.133 回答