Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spack -d env doesn't run in debug mode #44101

Open
3 tasks done
wdconinc opened this issue May 9, 2024 · 3 comments
Open
3 tasks done

spack -d env doesn't run in debug mode #44101

wdconinc opened this issue May 9, 2024 · 3 comments
Labels
bug Something isn't working impact-low
Milestone

Comments

@wdconinc
Copy link
Contributor

wdconinc commented May 9, 2024

Steps to reproduce

spack -d env status
$SPACK_ROOT/bin/spack -d env status

Error message

14:24:07 wdconinc@menelaos ~/git/spack (develop *$%>) $ spack -d env status
==> In environment default
14:24:10 wdconinc@menelaos ~/git/spack (develop *$%>) $ $SPACK_ROOT/bin/spack -d env status
==> [2024-05-09-14:24:12.191609] Reading config from file /home/wdconinc/git/spack/etc/spack/defaults/config.yaml
==> [2024-05-09-14:24:12.207718] Reading config from file /home/wdconinc/git/spack/etc/spack/config.yaml
==> [2024-05-09-14:24:12.208865] Reading config from file /home/wdconinc/.spack/config.yaml
==> [2024-05-09-14:24:12.234951] Reading config from file /home/wdconinc/git/spack/var/spack/environments/default/spack.yaml
==> [2024-05-09-14:24:12.389596] Reading config from file /home/wdconinc/git/spack/etc/spack/upstreams.yaml
==> [2024-05-09-14:24:12.391397] Using environment 'default'
==> [2024-05-09-14:24:12.410985] Imported env from built-in commands
==> [2024-05-09-14:24:12.414143] Imported env from built-in commands
==> [2024-05-09-14:24:12.414386] In environment default
==> [2024-05-09-14:24:12.414528] Reading config from file /home/wdconinc/git/spack/etc/spack/defaults/repos.yaml
==> [2024-05-09-14:24:12.415922] Reading config from file /home/wdconinc/.spack/repos.yaml
==> [2024-05-09-14:24:12.491968] Reading config from file /home/wdconinc/git/spack/etc/spack/defaults/packages.yaml
==> [2024-05-09-14:24:12.515129] Reading config from file /home/wdconinc/git/spack/etc/spack/defaults/linux/packages.yaml
==> [2024-05-09-14:24:12.517247] Reading config from file /home/wdconinc/git/spack/etc/spack/packages.yaml
==> [2024-05-09-14:24:12.521589] DATABASE LOCK TIMEOUT: 60s
==> [2024-05-09-14:24:12.521635] PACKAGE LOCK TIMEOUT: No timeout
==> [2024-05-09-14:24:12.602191] catch2 in view "default"
==> [2024-05-09-14:24:12.605387] clhep in view "default"
==> [2024-05-09-14:24:12.618272] cmake in view "default"
==> [2024-05-09-14:24:12.620056] cppcoro in view "default"
==> [2024-05-09-14:24:12.658105] eigen in view "default"
==> [2024-05-09-14:24:12.659739] embree in view "default"
==> [2024-05-09-14:24:12.663640] fastjet in view "default"
==> [2024-05-09-14:24:12.666156] fmt in view "default"
==> [2024-05-09-14:24:12.716531] heppdt in view "default"
==> [2024-05-09-14:24:12.718700] intel-oneapi-mkl in view "default"
==> [2024-05-09-14:24:12.720016] intel-oneapi-tbb in view "default"
==> [2024-05-09-14:24:12.753185] lcio in view "default"
==> [2024-05-09-14:24:12.770284] nano in view "default"
==> [2024-05-09-14:24:12.771998] ncurses in view "default"
==> [2024-05-09-14:24:12.773677] nlohmann-json in view "default"
==> [2024-05-09-14:24:12.774655] nopayloadclient in view "default"
==> [2024-05-09-14:24:12.784587] openssl in view "default"
==> [2024-05-09-14:24:12.785425] osg-ca-certs in view "default"
==> [2024-05-09-14:24:12.787631] pandorasdk in view "default"
==> [2024-05-09-14:24:12.788261] phonebook-cli in view "default"
==> [2024-05-09-14:24:13.021286] spdlog in view "default"
==> [2024-05-09-14:24:13.031255] timemory in view "default"
==> [2024-05-09-14:24:13.032595] veccore in view "default"
==> [2024-05-09-14:24:13.041660] vecmem in view "default"

Information on your system

  • Spack: 0.22.0.dev0 (bd7029c68a6dcde049fb9aa2cc052887fcb34881)
  • Python: 3.12.3
  • Platform: linux-ubuntu24.04-skylake
  • Concretizer: clingo

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output
@wdconinc wdconinc added bug Something isn't working triage The issue needs to be prioritized labels May 9, 2024
@wdconinc
Copy link
Contributor Author

wdconinc commented May 9, 2024

Seems caused by

command spack env $_sp_arg "$@"

Instead of just passing the subcommand to spack env it should inject the -d option again.

@alalazo alalazo added this to the v0.22.1 milestone May 14, 2024
@alalazo alalazo added impact-low and removed triage The issue needs to be prioritized labels May 21, 2024
@haampie
Copy link
Member

haampie commented May 22, 2024

There are more, similar issues, like

spack -e . cd -i zlib-ng

doesn't work, for multiple reasons:

  1. Spack takes . as a positional argument instead of cd, and
  2. even if that would work, it then fails to pass the -e . flag to spack location. And
  3. even if that would work, it loses track of whitespace in arguments, so: spack -e "/path to/env" cd -i zlib-ng would turn incorrectly into ["spack", "-e", "/path", "to/env", "cd", "-i", "zlib-ng"].

@haampie
Copy link
Member

haampie commented May 22, 2024

Something along the lines of

#!/bin/sh

spack() {
i=1
flags=""
args=""
command_idx=0
while [ $i -le $# ]; do
    if [ $command_idx -gt 0 ]; then
        args="$args "'"'\$"$i"'"'
        i=$((i + 1))
        continue
    fi

    eval "arg=\$$i"
    case "$arg" in
        --color|--lines|--sorted-profile|-C|--config-scope|-D|--env-dir|-c|--config|-e|--env)
            flags="$flags "'"'\$"$i"'" "'\$"$((i + 1))"'"'; i=$((i + 2)) ;;
        --*)
            flags="$flags "'"'\$"$i"'"'; i=$((i + 1)) ;;
        -*C|-*D|-*c|-*e)
            flags="$flags "'"'\$"$i"'" "'\$"$((i + 1))"'"'; i=$((i + 2)) ;;
        -*)
            flags="$flags "'"'\$"$i"'"'; i=$((i + 1)) ;;
        env)
            command_idx=$i
            command="$arg"
            eval "subcommand=\$$((i + 1))"
            i=$((i + 2)) ;;
        *)
            command_idx=$i
            command="$arg"
            i=$((i + 1)) ;;
    esac
done

case "$command" in
    cd)
        eval "cd \"\$(command spack $flags location $args)\""
        return
        ;;
    env)
        case "$subcommand" in
            activate|deactivate)
                eval "out=\"\$(command spack $flags env $subcommand $args --sh)\""
                eval "$out"
                return
                ;;
        esac
        ;;
esac

command spack "$@"
}

fixes most issues. For example, it turns

spack -v -e my_env cd pkg

into

cd "$(spack "$1" "$2" "$3" location "$5")"

through eval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working impact-low
Projects
Status: Todo
Development

No branches or pull requests

3 participants