Skip to content

fix: allow variable expansion#1552

Merged
Hofer-Julian merged 2 commits intoconda:mainfrom
fecet:patch/shell
Jul 24, 2025
Merged

fix: allow variable expansion#1552
Hofer-Julian merged 2 commits intoconda:mainfrom
fecet:patch/shell

Conversation

@fecet
Copy link
Copy Markdown
Contributor

@fecet fecet commented Jul 23, 2025

Fix: Allow Variable Expansion in Bash Activation Scripts

Summary

This PR fixes an issue where environment variable values containing references like ${CONDA_PREFIX} were not being expanded correctly in bash activation scripts per prefix-dev/pixi#4122

Problem

In #1392, environment variable values with $ symbols were quoted using single quotes. While this quoting ensures correctness for many shell values, it prevents variable expansion in bash:

export PATH='${CONDA_PREFIX}/bin:$PATH'  # Variables not expanded

This breaks expected behavior for users relying on dynamic paths such as ${CONDA_PREFIX}/bin.

Fix

Values containing variable references are now quoted using double quotes instead of single quotes in bash activation scripts. This preserves correct expansion while still protecting the value from word splitting or globbing.

export PATH="${CONDA_PREFIX}/bin:$PATH"  # Variables are expanded

Impact

  • Restores compatibility with tools relying on environment variable expansion (e.g., pixi)
  • Affects only bash quoting behavior; other shells remain unchanged

Let me know if you'd like to include a test case or changelog entry as well.

@lucascolley
Copy link
Copy Markdown
Contributor

Ahh, I wonder whether this explains something I was seeing with nushell and zsh also?? scipy/scipy#23361 (comment)

@fecet
Copy link
Copy Markdown
Contributor Author

fecet commented Jul 24, 2025

Copy link
Copy Markdown
Collaborator

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, I tried to think of a more general approach, but it's just a bit of a messy situation and your solution is a good one :)

Pushed a commit to make the shlex error case a bit nicer

@Hofer-Julian Hofer-Julian enabled auto-merge (squash) July 24, 2025 15:15
@Hofer-Julian Hofer-Julian merged commit 1a08bc0 into conda:main Jul 24, 2025
18 checks passed
@baszalmstra baszalmstra mentioned this pull request Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants