Skip to content

Conversation

@lmondada
Copy link
Collaborator

Description

Support sourcing the scripts/cudaq_set_env.sh from non-bash shells by falling back to $0 if BASH_SOURCE[0] is not defined.

Closes #3476

@lmondada lmondada requested a review from bettinaheim November 10, 2025 10:57
github-actions bot pushed a commit that referenced this pull request Nov 10, 2025
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 10, 2025
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 11, 2025
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@lmondada lmondada requested review from 1tnguyen and removed request for bettinaheim November 11, 2025 15:29
@lmondada
Copy link
Collaborator Author

I don't understand what/why CI is failing... any ideas?

@sacpis
Copy link
Collaborator

sacpis commented Nov 11, 2025

I don't understand what/why CI is failing... any ideas?

Seems like rerun will pass.

@1tnguyen 1tnguyen requested a review from sacpis November 14, 2025 19:42
@mitchdz
Copy link
Collaborator

mitchdz commented Nov 20, 2025

This fixes #2194

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 20, 2025
# Prefix all paths such that running this script manually for a local installation
# ensures that the local installation takes precedence over a system-wide installation.
export CUDA_QUANTUM_PATH=`dirname "$(readlink -f "${BASH_SOURCE[0]}")"`
export CUDA_QUANTUM_PATH=`dirname "$(readlink -f "${BASH_SOURCE[0]:-$0}")"`
Copy link
Collaborator

@sacpis sacpis Nov 20, 2025

Choose a reason for hiding this comment

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

I do see Bad Substitution error when I run this in zsh

./scripts/cudaq_set_env.sh: 1: Bad substitution

So I tried the following code and it works both in bash and zsh

if [ -n "${BASH_VERSION-}" ]; then
        script_path="${BASH_SOURCE[0]}"
elif [ -n "${ZSH_VERSION-}" ]; then
        script_path="${(%):-%N}"
else
        script_path="$0"
fi

export CUDA_QUANTUM_PATH="$(dirname -- "$script_path")"

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.

setenv.sh only works in bash

3 participants