{"id":19215197,"url":"https://github.com/mamba-org/setup-micromamba","last_synced_at":"2025-04-12T14:18:55.491Z","repository":{"id":156279446,"uuid":"595118157","full_name":"mamba-org/setup-micromamba","owner":"mamba-org","description":"GitHub Action to set up micromamba","archived":false,"fork":false,"pushed_at":"2024-10-07T07:58:08.000Z","size":3573,"stargazers_count":104,"open_issues_count":18,"forks_count":16,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-24T15:44:54.177Z","etag":null,"topics":["conda","github-actions","mamba","micromamba","packaging"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mamba-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T12:40:28.000Z","updated_at":"2024-10-24T02:38:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"70492331-9605-4ba8-8319-b4035f371430","html_url":"https://github.com/mamba-org/setup-micromamba","commit_stats":{"total_commits":140,"total_committers":8,"mean_commits":17.5,"dds":0.5214285714285714,"last_synced_commit":"e751044b66e0d9c3dba6dc11a5570116f612e775"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamba-org%2Fsetup-micromamba","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamba-org%2Fsetup-micromamba/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamba-org%2Fsetup-micromamba/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamba-org%2Fsetup-micromamba/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mamba-org","download_url":"https://codeload.github.com/mamba-org/setup-micromamba/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248578876,"owners_count":21127714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conda","github-actions","mamba","micromamba","packaging"],"created_at":"2024-11-09T14:12:58.975Z","updated_at":"2025-04-12T14:18:55.469Z","avatar_url":"https://github.com/mamba-org.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# setup-micromamba\n\n[![CI](https://github.com/mamba-org/setup-micromamba/actions/workflows/test.yml/badge.svg)](https://github.com/mamba-org/setup-micromamba/actions/workflows/test.yml)\n\nGitHub Action to set up the [micromamba](https://github.com/mamba-org/mamba#micromamba) package manager.\n\n## Usage\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    init-shell: \u003e-\n      bash\n      powershell\n    cache-environment: true\n    post-cleanup: 'all'\n- name: Import numpy in micromamba environment (bash)\n  run: python -c \"import numpy\"\n  shell: bash -el {0}\n- name: Import numpy in micromamba environment (pwsh)\n  run: python -c \"import numpy\"\n  shell: pwsh\n- name: Run custom command in micromamba environment\n  run: pytest --version\n  shell: micromamba-shell {0}\n```\n\n## Features\n\nTo see all available input arguments, see the [`action.yml`](action.yml) file.\n\n### Micromamba version\n\nYou can specify the version of micromamba to be installed using the `micromamba-version` input.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    # Any version from https://github.com/mamba-org/micromamba-releases\n    micromamba-version: '2.0.5-0'\n```\n\n### Environment creation\n\n`setup-micromamba` allows you to create micromamba environments from an environment file or from a list of packages.\nYou can use either `environment-file` or `create-args` arguments to specify an environment to be created.\nAn environment name (other than `base`) must also be specified either in the environment file or via `environment-name`.\nIf the environment is not fully specified then `setup-micromamba` will skip the environment creation and install only the `micromamba` executable.\n\nAfter the environment has been created, `setup-micromamba` will write `micromamba activate \u003cenv-name\u003e` into the rc file of all shells that are [initialized](#shell-initialization).\nThis will automatically activate the environment when the shell is started.\n\n#### Create environment from environment file\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n```\n\n#### Create environment from `conda-lock` file\n\nMicromamba supports the `conda-lock` [unified lockfile format](https://conda.github.io/conda-lock/output/#unified-lockfile), but this format does not specify an environment name.\nBecause `setup-micromamba` requires an environment name to be specified, config might look like this:\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: conda-lock.yml\n    environment-name: ci\n```\n\n\u003e [!NOTE]\n\u003e Beware that `micromamba` does not allow additional packages to be installed into a locked environment and will ignore additional specs added by `create-args`, see [mamba#1760](https://github.com/mamba-org/mamba/issues/1760).\n\n#### Create environment from environment specs\n\nYou can specify extra environment specs using the `create-args` input.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    # the create command looks like this:\n    # `micromamba create -n test-env python=3.10 numpy`\n    environment-name: test-env\n    create-args: \u003e-\n      python=3.10\n      numpy\n```\n\n#### Custom arguments\n\nYou can specify custom arguments for the `micromamba create` command using the `create-args` input. See `micromamba create --help` for more information.\n\n\u003e [!NOTE]\n\u003e This is the same argument as in the [previous example](#create-environment-from-environment-specs) but with different semantics.\n\u003e This is because internally, `setup-micromamba` uses the `micromamba create` command to create the environment from the environment file and there, extra specs are specified by adding them as extra arguments to the `micromamba create` command.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    create-args: -v\n```\n\n### Shell initialization\n\nIn order to be able to activate micromamba environments, you need to initialize your shell.\n`setup-micromamba` can create shell initialization scripts for different shells (by calling `micromamba shell init -s \u003cshell\u003e`).\nBy default, it will create shell initialization scripts for `bash`.\nIf you want to customize this, you can use the `init-shell` input.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    init-shell: bash\n```\n\nIn case you don't want to initialize your shell, you can set `init-shell` to `none`.\n\nYou can also specify multiple shells by separating them with a space (or using the `\u003e-` YAML block scalar)\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    init-shell: \u003e-\n      bash\n      powershell\n    # or\n    init-shell: bash powershell\n```\n\nPlease read [about login shells](#about-login-shells) for more information about the shell initialization.\n\n### Custom `micromamba-shell` wrapper\n\n`setup-micromamba` will allow you to run commands in the created micromamba environment with a custom shell wrapper. In this \u0026#8220;shell\u0026#8221;, the micromamba is activated and the commands are executed.\nWith this, you don't need to initialize your shell and activate the environment which may come in handy for self-hosted runners that persist between jobs.\nYou can set this behavior by specifying the `generate-run-shell` input (defaults to `true`).\n\n\u003e [!NOTE]\n\u003e Under the hood, this shell wrapper runs `micromamba run -r \u003croot-prefix-path\u003e -n \u003cenv-name\u003e \u003ccommand\u003e` with `\u003ccommand\u003e` being a file containing the part that you specify in the `run:` section of your workflow.\n\u003e See the [official documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#custom-shell) and [ADR 0277](https://github.com/actions/runner/blob/main/docs/adrs/0277-run-action-shell-options.md) for more information about how the `shell:` input works in GitHub Actions.\n\n\u003e [!WARNING]\n\u003e Only available on macOS and Linux.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    generate-run-shell: true\n    environment-file: environment.yml\n- run: |\n    pytest --version\n    pytest\n  shell: micromamba-shell {0}\n```\n\n### Custom `.condarc` file\n\nTo specify custom channels or other micromamba settings, you may want to use `.condarc` files to do this.\n\n`setup-micromamba` allows you to specify a custom `.condarc` file using either the `condarc-file` or the `condarc` input.\n\nWhen you specify `condarc-file`, `setup-micromamba` will use this file for all micromamba commands.\n\nWhen you specify `condarc`, `setup-micromamba` will create a `.condarc` next to the micromamba binary (to not mess with the `~/.condarc` that may be overwritten on self-hosted runners) and use this file for all micromamba commands.\nThe action will also set the `CONDARC` environment variable to point to this file.\n\nIf nothing is specified, `setup-micromamba` will create a `.condarc` next to the micromamba binary with `conda-forge` as the only channel.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    condarc-file: /path/to/.condarc\n```\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    condarc: |\n      channels:\n        - my-custom-channel\n        - conda-forge\n        - pytorch\n```\n\n### Caching\n\nIf you want to cache your micromamba environment or packages, you can do this by setting the `cache-environment` (or `cache-environment-key`) or `cache-downloads` (or `cache-downloads-key`) inputs.\n\nIf `cache-environment` is set to `true` and `cache-environment-key` is not specified, `setup-micromamba` will use the default cache key (`micromamba-environment`). Similar behavior applies to `cache-downloads` and `cache-downloads-key`.\n\n\u003e [!NOTE]\n\u003e Note that the specified cache key is only the prefix of the real cache key.\n\u003e `setup-micromamba` will append a hash of the environment file and the `custom-args` as well as the environment name and OS to the cache key.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    # only cache environment\n    cache-environment: true\n    cache-downloads: false\n```\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    # persist only for runs on this commit.\n    cache-environment-key: environment-${{ github.sha }}\n    cache-downloads-key: downloads-${{ github.sha }}\n```\n\n```yml\n- name: Get current date\n  id: date\n  run: echo \"date=$(date +%Y-%m-%d)\" \u003e\u003e \"${GITHUB_OUTPUT}\"\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    # persist on the same day.\n    cache-environment-key: environment-${{ steps.date.outputs.date }}\n    cache-downloads-key: downloads-${{ steps.date.outputs.date }}\n```\n\n\u003e See [Notes on caching](#notes-on-caching) for more information about caching.\n\n### Debugging\n\nThere are two types of debug logging that you can enable.\n\n#### Debug logging of the action\n\nThe first one is the debug logging of the action itself.\nThis can be enabled by running the action with the `ACTIONS_STEP_DEBUG` environment variable set to `true`.\n\n```yml\n- uses: mamba-org/setup-micromamba2v2\n  env:\n    ACTIONS_STEP_DEBUG: true\n```\n\nAlternatively, you can enable debug logging for the action by re-running the action in debug mode:\n\n![Re-run in debug mode](.github/assets/enable-debug-logging-light.png#gh-light-mode-only)\n![Re-run in debug mode](.github/assets/enable-debug-logging-dark.png#gh-dark-mode-only)\n\n\u003e For more information about debug logging in GitHub Actions, see [the official documentation](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging).\n\n#### Debug logging of micromamba\n\nThe second type is the debug logging of the micromamba executable.\nThis can be specified by setting the `log-level` input.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    # supports off, critical, error, warning, info, debug, trace\n    log-level: debug\n```\n\nIf nothing is specified, `setup-micromamba` will default to `warning` or `debug` depending on if [debug logging is enabled for the action](#debug-logging-of-the-action).\n\n### Self-hosted runners\n\nOn self-hosted runners, it may happen that some files are persisted between jobs.\nThis can lead to problems when the next job is run.\n\n#### Post-action cleanup\n\nTo avoid persistence between jobs, you can use the `post-cleanup` input to specify the post cleanup behavior of the action (i.e., what happens _after_ all your commands have been executed).\n\nThere is a total of 4 options:\n\n- `none`: No cleanup is performed.\n- `shell-init`: The shell initialization files are removed by executing `micromamba shell deinit -s \u003cshell\u003e`.\n- `environment`: Shell initialization files and the installed environment are removed.\n- `all`: Shell initialization files as well as the micromamba root folder and the binary are removed.\n\nIf nothing is specified, `setup-micromamba` will default to `shell-init`.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    post-cleanup: environment\n```\n\n#### Specify the path of the micromamba binary\n\nYou also might want to alter the default micromamba installation location to a temporary location. You can use `micromamba-binary-path: ${{ runner.temp }}/bin/micromamba` to do this.\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    # ${{ runner.temp }}\\Scripts\\micromamba.exe on Windows\n    micromamba-binary-path: ${{ runner.temp }}/bin/micromamba\n```\n\nYou can control the download behavior of micromamba with the options `download-micromamba` and `micromamba-binary-path`.\n\n| Micromamba on `$PATH` | `download-micromamba` | `micromamba-binary-path` | Behavior                        |\n|----------------|-----------------------|--------------------------|------------------------------------|\n| No             | unset                 | unset                    | Download to default location       |\n| No             | unset                 | set                      | Download to specified path         |\n| No             | false                 | unset                    | Error                              |\n| No             | false                 | set                      | Use binary (absolute path)         |\n| No             | true                  | unset                    | Download to default location       |\n| No             | true                  | set                      | Download to specified path         |\n| Yes            | unset                 | unset                    | Use binary (from PATH)             |\n| Yes            | unset                 | set                      | Download to specified path         |\n| Yes            | false                 | unset                    | Use binary (from PATH)             |\n| Yes            | false                 | set                      | Use binary (specified path)        |\n| Yes            | true                  | unset                    | Download to default location       |\n| Yes            | true                  | set                      | Download to specified path         |\n\n```yml\n- uses: mamba-org/setup-micromamba@v2\n  with:\n    environment-file: environment.yml\n    download-micromamba: false\n    # you don't need to specify this if micromamba is already on PATH\n    micromamba-binary-path: /usr/local/bin/micromamba\n    generate-run-shell: false # this would generate a file next to the micromamba binary\n```\n\n## More examples\n\nIf you want to see more examples, you can take a look at the [GitHub Workflows of this repository](.github/workflows/).\n\n## Notes on caching\n\n### Branches have separate caches\n\nDue to a [security limitation of GitHub Actions](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache)\nany caches created on a branch will not be available on the main/parent branch\nafter merging. This also applies to PRs.\n\nIn contrast, branches *can* use a cache created on the main/parent branch.\n\nSee also [this thread](https://github.com/mamba-org/provision-with-micromamba/issues/42#issuecomment-1062007161).\n\n### When to use download caching\n\nPlease see [this comment for now](https://github.com/mamba-org/provision-with-micromamba/pull/38#discussion_r808837618).\n\n### When to use environment caching\n\nPlease see [this comment for now](https://github.com/mamba-org/provision-with-micromamba/pull/38#discussion_r808837618).\n\n## About login shells...\n\nSome shells require special syntax (e.g. `bash -leo pipefail {0}`). You can set this up with the `defaults` option:\n\n```yaml\njobs:\n  myjob:\n    defaults:\n      run:\n        shell: bash -leo pipefail {0}\n\n# or top-level:\ndefaults:\n  run:\n    shell: bash -leo pipefail {0}\njobs:\n  ...\n```\n\nFind the reasons below (taken from [setup-miniconda](https://github.com/conda-incubator/setup-miniconda/blob/master/README.md#important)):\n\n- Bash shells do not use `~/.profile` or `~/.bashrc` so these shells need to be\n  explicitly declared as `shell: bash -leo pipefail {0}` on steps that need to be properly\n  activated (or use a default shell). This is because bash shells are executed\n  with `bash --noprofile --norc -eo pipefail {0}` thus ignoring updated on bash\n  profile files made by `micromamba shell init bash`.\n- Cmd shells do not run `Autorun` commands so these shells need to be\n  explicitly declared as `shell: cmd /C call {0}` on steps that need to be\n  properly activated (or use a default shell). This is because cmd shells are\n  executed with `%ComSpec% /D /E:ON /V:OFF /S /C \"CALL \"{0}\"\"` and the `/D` flag\n  disabled execution of `Command Processor/Autorun` Windows registry keys, which\n  is what `micromamba shell init cmd.exe` sets.\n\nFor further information, see\n[`jobs.\u003cjob_id\u003e.steps[*].shell`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell)\nand [this thread](https://github.com/orgs/community/discussions/25061).\n\n## Development\n\n1. Clone this repository.\n2. Run `pnpm install` inside the repository (if you don't have [`pnpm`](https://github.com/pnpm/pnpm) installed, you can install it with `npm install -g pnpm` or `brew install pnpm`).\n3. Run `pnpm run dev` for live transpilation of the TypeScript source code.\n4. To test the action, you can run [`act`](https://github.com/nektos/act) (inside docker) or [`test.sh`](test.sh) (on your local machine).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamba-org%2Fsetup-micromamba","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmamba-org%2Fsetup-micromamba","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamba-org%2Fsetup-micromamba/lists"}