Skip to content

Commit

Permalink
Merge pull request #1812 from fabianegli/better-conda-channel-priorit…
Browse files Browse the repository at this point in the history
…y-mismatch-message

generalized code, better error message and link update
  • Loading branch information
fabianegli committed Sep 8, 2022
2 parents 148d9e2 + 6db8862 commit 153300d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Template

- Add `actions/upload-artifact` step to the awstest workflows, to expose the debug log file
- Bioconda incompatible conda channel setups now result in more informative error messages ([#1812](https://github.com/nf-core/tools/pull/1812))

### Linting

Expand Down
21 changes: 14 additions & 7 deletions nf_core/pipeline-template/lib/Utils.groovy
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ class Utils {
}

// Check that all channels are present
def required_channels = ['conda-forge', 'bioconda', 'defaults']
def conda_check_failed = !required_channels.every { ch -> ch in channels }
// This channel list is ordered by required channel priority.
def required_channels_in_order = ['conda-forge', 'bioconda', 'defaults']
def channels_missing = ((required_channels_in_order as Set) - (channels as Set)) as Boolean

// Check that they are in the right order
conda_check_failed |= !(channels.indexOf('conda-forge') < channels.indexOf('bioconda'))
conda_check_failed |= !(channels.indexOf('bioconda') < channels.indexOf('defaults'))
def channel_priority_violation = false
def n = required_channels_in_order.size()
for (int i = 0; i < n - 1; i++) {
channel_priority_violation |= !(channels.indexOf(required_channels_in_order[i]) < channels.indexOf(required_channels_in_order[i+1]))
}

if (conda_check_failed) {
if (channels_missing | channel_priority_violation) {
log.warn "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" There is a problem with your Conda configuration!\n\n" +
" You will need to set-up the conda-forge and bioconda channels correctly.\n" +
" Please refer to https://bioconda.github.io/user/install.html#set-up-channels\n" +
" NB: The order of the channels matters!\n" +
" Please refer to https://bioconda.github.io/\n" +
" The observed channel order is \n" +
" ${channels}\n" +
" but the following channel order is required:\n" +
" ${required_channels_in_order}\n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
}
}
Expand Down

0 comments on commit 153300d

Please sign in to comment.