首页 > 解决方案 > CircleCI 2.0 - 退出代码 127,找不到捆绑命令

问题描述

我正在尝试让 Rails 应用程序在 Circle CI 上运行。使用以下配置,我似乎根本无法工作。当我 ssh 进入时,我什至无法运行sudo.

这是错误输出:

install dependencies
$ #!/bin/bash -eo pipefail
bundler install --jobs=4 --retry=3 --path vendor/bundle
/bin/bash: bundler: command not found
Exited with code 127

我注意到除了目录assets/下什么都没有vendor

这是我的配置文件:

version: 2
jobs:
  build:
    working_directory: ~/repo
    docker:
      - image: circleci/postgres:9.6-alpine-postgis-ram

      - image: circleci/ruby:2.3
        environment:
          PGHOST: 127.0.0.1
          PGUSER: staging
          RAILS_ENV: test

      - image: circleci/postgres:10.5
        environment:
          POSTGRES_USER: staging
          POSTGRES_DB: test
          POSTGRES_PASSWORD: ""

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "Gemfile.lock" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: install dependencies
          command: |
            bundle install --jobs=4 --retry=3 --path vendor/bundle

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # Database setup
      - run: bundle exec rake db:create
      - run: bundle exec rake db:schema:load

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec --format progress \
                            --format RspecJunitFormatter \
                            --out /tmp/test-results/rspec.xml \
                            --format progress \
                            $TEST_FILES

      # collect reports
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results
          destination: test-results

感谢所有帮助,谢谢!

标签: ruby-on-railsrubycircleci

解决方案


您的命令正在 postgres 容器上运行,因为它首先列出。如果您先制作 ruby​​ 容器,那么您将可以访问 bundle。然后当你 SSH 时,你将在 ruby​​ 容器内。

https://circleci.com/docs/2.0/configuration-reference/#docker--machine--macosexecutor

文件中列出的第一个映像定义了将运行所有步骤的主容器映像。


推荐阅读