cuda-quantum icon indicating copy to clipboard operation
cuda-quantum copied to clipboard

The quick start installation guide does not work for zsh (and likely other shells)

Open mitchdz opened this issue 1 year ago • 0 comments

Required prerequisites

  • [x] Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • [x] Make sure you've read the documentation. Your issue may be addressed there.
  • [x] Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • [x] If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

The quick start installation guide says to install and use cuda-quantum like so:

sudo -E bash install_cuda_quantum.$(uname -m) --accept
. /etc/profile

This can cause issues if you are not using bash, as once install_cuda_quantum.$(uname -m) finishes running, you are returned to the calling shell. In my case, I am using zsh. The issues occurs because /opt/nvidia/cudaq/set_env.sh uses ${BASH_SOURCE[0]} which doesn't work well when using zsh.

Steps to reproduce the bug

Run a shell other than bash (such as zsh) and then attempt to source the environment file.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$ cat /etc/profile | tail -n 2
CUDAQ_INSTALL_PATH="/opt/nvidia/cudaq"
. "${CUDAQ_INSTALL_PATH}/set_env.sh"
$ . /etc/profile
$ echo $PATH
./bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Expected behavior

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$ cat /etc/profile | tail -n 2
CUDAQ_INSTALL_PATH="/opt/nvidia/cudaq"
. "${CUDAQ_INSTALL_PATH}/set_env.sh"
$ . /etc/profile
$ echo $PATH
/opt/nvidia/cudaq/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

  • CUDA Quantum version: any
  • Python version: any
  • C++ compiler: any
  • Operating system: Ubuntu 22.04

Suggestions

For me, I fixed it by instead using

export CUDA_QUANTUM_PATH=`dirname "$(readlink -f "$0")"`

in my /opt/nvidia/cudaq/set_env.sh

Which works well for zsh, but not for bash.

mitchdz avatar Sep 06 '24 03:09 mitchdz