简体   繁体   中英

How do I specify a package installation (for Yarn) within a CircleCI docker image?

I am using CircleCI to test a Rails app. I need to run have my images use a later version of Yarn (1.19 currently) than is available off the image we are using for our CI tests ( circleci/ruby:2.6-node-browsers ).

What is the configuration step/entry in config.yml to do this? I assume I have to run something in the build step that upgrades the Yarn version (which in the image is currently 1.17.) But I can't figure out what it is.

Starting with the Circle docs on Yarn , I tried installing Yarn through that curl command they have in their example (as of Oct '19), which goes:

run:
  name: install Yarn
  command: curl -o- -L https://yarnpkg.com/install.sh | bash

This did not work - yarn -v still returned 1.17.

I subsequently heard back from CircleCI support, and changed this to:

      - run: |
          curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
          echo "deb https://dl.yarnpkg.com/debian/ rc main" | sudo tee /etc/apt/sources.list.d/yarn.list
          sudo apt-get update && sudo apt-get install yarn
          sudo rm /usr/local/bin/yarn && sudo ln -s /usr/bin/yarn /usr/local/bin/yarn

and that worked. I am going to guess it's because the use of sudo sets the global path soft links correctly, and the local install did not. I could possibly have gotten here by resetting the PATH variable but I am pasting this here, because using the apt route seems the "better" solution to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM