Bundler安装失败,具有saltstack gem状态

时间:2015-07-06 10:32:01

标签: ruby gem bundler salt-stack

我正在尝试安装bundler但由于以下错误而失败。

      ID: install_bundler
Function: gem.installed
    Name: bundler
  Result: False
 Comment: An exception occurred in this state: Traceback (most recent call last):
            File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1563, in call
              **cdata['kwargs'])
            File "/usr/lib/python2.7/dist-packages/salt/states/gem.py", line 81, in installed
              gems = __salt__['gem.list'](name, ruby, gem_bin=gem_bin, runas=user)
            File "/usr/lib/python2.7/dist-packages/salt/modules/gem.py", line 206, in list_
              runas=runas)
            File "/usr/lib/python2.7/dist-packages/salt/modules/gem.py", line 28, in _gem
              return __salt__['rbenv.do_with_ruby'](ruby, cmdline, runas=runas)
            File "/usr/lib/python2.7/dist-packages/salt/modules/rbenv.py", line 369, in do_with_ruby
              return do(cmd, runas=runas)
            File "/usr/lib/python2.7/dist-packages/salt/modules/rbenv.py", line 343, in do
              env=environ
            File "/usr/lib/python2.7/dist-packages/salt/modules/cmdmod.py", line 1014, in run_all
              use_vt=use_vt)
            File "/usr/lib/python2.7/dist-packages/salt/modules/cmdmod.py", line 391, in _run
              .format(cmd, kwargs, exc)
          CommandExecutionError: Unable to run command ['RBENV_VERSION=2.1.2', 'gem', 'list', 'bundler'] with the context {'with_communicate': True, 'shell': False, 'env': {'UPSTART_INSTANCE': '', 'UPSTART_JOB': 'salt-minion', 'LC_ALL': 'C', 'PATH': '/usr/local/rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin', 'PWD': '/', 'TERM': 'linux'}, 'stdout': -1, 'close_fds': True, 'stdin': None, 'stderr': -1, 'cwd': '/root'}, reason: [Errno 2] No such file or directory
 Started: 10:19:55.195415
Duration: 91.662 ms
 Changes:

这是我的rbenv.ssl文件

rbenv:
  pkg.latest:
    - refresh: True

rbenv-deps:
  pkg.installed:
    - names:
      - bash
      - git
      - openssl
      - libssl-dev
      - make
      - curl
      - autoconf
      - bison
      - build-essential
      - libssl-dev
      - libyaml-dev
      - libreadline6-dev
      - zlib1g-dev
      - libncurses5-dev

ruby-2.1.0:
  rbenv.absent:
    - require:
      - pkg: rbenv-deps

ruby-2.1.2:
  rbenv.installed:
    - default: True
    - require:
      - pkg: rbenv-deps

app-deps:
  pkg.installed:
    - names:
      - libxml2-dev # required by nokogiri
      - libxslt1-dev # required by nokogiri
      - g++ # required by eventmachine
      - libmysqlclient-dev # required by mysql
      - libexpat1-dev # required by xmlparser

install_bundler:
    gem.installed:
      - name: bundler
      - ruby: 2.1.2

/etc/profile.d/rbenv.sh:
  file:
    - managed
    - user: root
    - group: root
    - mode: 755
    - source: salt://rbenv/files/profile/rbenv.sh
    - require:
      - pkg: rbenv

我不知道自己做错了什么。我尝试通过黑客安装它,它可以工作。

'RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 rbenv exec gem install bundler':
  cmd.run:
    - unless: 'RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 rbenv exec gem list | grep bundler'

如果有人比运行使用saltstack安装bundler的命令更清楚,那将会很棒。

4 个答案:

答案 0 :(得分:0)

我不完全确定出现了什么问题但是你的install_bundler状态肯定需要ruby-2.1.2。

看起来运行状态的任何环境在其CLASSPATH中都没有gem命令。

答案 1 :(得分:0)

我是上述票证的作者(NW0428)..我也找不到比这更好的解决方案(效果很好):

bundler:
  cmd.run:
    - name: RBENV_VERSION=2.1.2 gem install bundler
    - unless: RBENV_VERSION=2.1.2 gem list bundler -i

答案 2 :(得分:0)

我只需从gem.install删除ruby版本,一切正常。

install_bundler:
    gem.installed:
      - name: bundler

答案 3 :(得分:0)

当状态尝试使用错误的finalurl.replace(/and/g, '&').replace(/eq/g, '='); 命令时,我们收到此错误。安装了系统级的Ubuntu Ruby程序包,并且它首先在gem中找到了/usr/bin/gem,因此gem安装因PATH失败了

卸载Ubuntu Ruby软件包已为我们解决了;然后状态找到了应有的用户级You don't have write permissions for the /var/lib/gems/[...] directory.命令,并且gem安装进入了正确的位置。