Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: preserve conda exit status in fish wrapper function#14752

Closed
holgerdell wants to merge 2 commits intoconda:mainfrom
holgerdell:main
Closed

fix: preserve conda exit status in fish wrapper function#14752
holgerdell wants to merge 2 commits intoconda:mainfrom
holgerdell:main

Conversation

@holgerdell
Copy link

@holgerdell holgerdell commented Apr 11, 2025

Fixes an issue where the conda fish wrapper function was incorrectly returning
exit status 4 after successful conda operations. This occurred because the
eval ($CONDA_EXE shell.fish reactivate) command fails with status 4 when
attempting to unset non-existent variables with set -e.

The fix captures the original conda command's exit status before reactivation
and explicitly returns it, ensuring the function returns the status of the
actual conda operation rather than the status of the environment reactivation.

This maintains the intended behavior where reactivation only occurs for
successful commands while properly preserving error codes for error handling.

Description

I noticed that the command conda update --all returns an incorrect exit code of 4 after using conda activate in the fish shell. The reason is that the fish function conda returns the exit code of eval ($CONDA_EXE shell.fish reactivate), which in turn is 4 if the variable undefined and then unset by set -e _CE_M in $CONDA_EXE shell.fish reactivate. This pull request fixes this issue.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • [ ] Add / update necessary tests?
  • [ ] Add / update outdated documentation?

@conda-bot
Copy link
Contributor

We require contributors to sign our Contributor License Agreement and we don't have one on file for @holgerdell.

In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature, merge the PR (conda/infrastructure#1146), and ping the bot to refresh the PR.

@holgerdell holgerdell force-pushed the main branch 2 times, most recently from da1d972 to 24d90e7 Compare April 11, 2025 11:27
@holgerdell holgerdell marked this pull request as ready for review April 12, 2025 06:36
@holgerdell holgerdell requested a review from a team as a code owner April 12, 2025 06:36
@dbast
Copy link
Member

dbast commented Apr 15, 2025

@conda-bot check

1 similar comment
@dbast
Copy link
Member

dbast commented Apr 15, 2025

@conda-bot check

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 15, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 15, 2025

CodSpeed Performance Report

Merging #14752 will not alter performance

Comparing holgerdell:main (5af01f2) with main (07a2d63)

Summary

✅ 21 untouched benchmarks

@github-project-automation github-project-automation bot moved this from 🆕 New to 🏗️ In Progress in 🔎 Review Apr 16, 2025
Fixes an issue where certain conda operations in fish (such as `conda update`) incorrectly returned an exit status of 4 instead of 0. This occurred because unsetting undefined variables with `set -e` in recent fish versions (e.g., 4.0.2) returns an exit status of 4. The fix simply ignores any error caused by the `set -e` command.
@holgerdell
Copy link
Author

@kenodegard I changed the pull request: Instead of editing conda.fish, I am proposing an edit to the set -e command that causes the exit status of 4. I believe this issue only occurs on recent versions of fish, I tested it on version 4.0.2.

@holgerdell
Copy link
Author

This is a duplicate of #14660.

@scott-5
Copy link

scott-5 commented Aug 14, 2025

The problem is solved and the pr can be closed. @holgerdell

@holgerdell holgerdell closed this Aug 14, 2025
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to 🏁 Done in 🔎 Review Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants

Comments