Skip to content

chore: Emit an error for ZSH in micromamba - #262

Open
Makkareal wants to merge 1 commit into
Ericsson:mainfrom
Makkareal:micromamba_zsh_fix
Open

Makkareal wants to merge 1 commit into
Ericsson:mainfrom
Makkareal:micromamba_zsh_fix

Conversation

@Makkareal

@Makkareal Makkareal commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Why:
When using ZSH source source .ci/micromamba/init.sh did not work, because it did not find the location of the script.

What:
Added a check to see if the source file and thus its location could be found, otherwise asks the user to source from bash.

Addresses:
None

@Szelethus
Szelethus requested review from Szelethus and furtib July 8, 2026 12:04
@Szelethus Szelethus added the bug Something isn't working label Jul 8, 2026

@furtib furtib left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, welcome to the project!

There are multiple bash script files using this or similar methods for obtaining the location of the script (e.g., .ci/micromamba/run_test.sh, .ci/micromamba/uninstall.sh); those should be updated too.
If possible, I suggest avoiding the ZSH-specific execution path and using something that works universally. (The solution I used in run_test.sh seems to work in ZSH too, please check that! -- does not work with sourcing)

I'm slightly concerned about the impact of ZSH support inside basel.

Since we are not explicitly supporting ZSH, I relabeled this as an enhancement, not a bug.

Comment thread .ci/micromamba/init.sh Outdated

@furtib furtib Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line does not work in ZSH; see the following example script:

furtib@emypc ~ % cat test.sh 
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    echo "ERROR: This script must be 'sourced':"
    echo "       source ${0}"
    exit 1
fi


furtib@mypc ~ % ./test.sh
./test.sh: 1: Bad substitution

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added shebang, so the script always runs in bash when not sourced.

Unfortunately, I could not find a universal way of getting the correct path. If the support of ZSH is a concern, then perhaps it would be better to simply check if the script is sourced from bash and exit with an instruction if it is not.

I will update the other scripts with whichever solution is preferred.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a great alternative solution. Lets pursue that.

@furtib furtib added enhancement New feature or request and removed bug Something isn't working labels Jul 11, 2026

@Szelethus Szelethus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In hindsight, I also think it'd be wiser to only support bash.

Comment thread .ci/micromamba/init.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a great alternative solution. Lets pursue that.

@Szelethus Szelethus left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to emit an error if the detected bash is zsh. After that, its ready to merge.

edit: Please edit the summary accordingly.

@Szelethus Szelethus changed the title Added ZSH support for micromamba Emit an error for ZSH in micromamba Oct 26, 2026
@Makkareal Makkareal closed this Oct 28, 2026
Check whether BASH_SOURCE[0] is empty, and emit an error
asking to source from bash when it is.
@Makkareal Makkareal reopened this Oct 28, 2026

@Szelethus Szelethus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to fix the lint CI job, otherwise LGTM

@Makkareal Makkareal changed the title Emit an error for ZSH in micromamba chore: Emit an error for ZSH in micromamba Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants