Search code examples
pythonanacondacondagithub-cli

How to install gh CLI library using conda's environment.yml?


According to the gh instructions, we can install the gh cli via conda using: conda install gh --channel conda-forge. I wonder if there is way to include it in the environment.yml file? So that I can auto install the packages while setting up the conda environment.

name: conda_env
channels:
  - defaults
dependencies:
  - python>=3.8
  - pip>=20.1.1

I don't know where to add gh in the environment.yml file. Clearly, it is not a pip package.


Solution

  • Add conda-forge to the channels and gh to the dependencies:

    environment.yaml

    name: conda_env
    channels:
      - conda-forge
      - defaults
    dependencies:
      - python>=3.8
      - pip>=20.1.1
      - gh
    

    Note it is recommended when using Conda Forge to give it priority over defaults (hence, the order). Otherwise, one risks encountering channel mixing issues. Likely not an issue here, since gh is a standalone binary, but worth being aware of.