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

Tox can't handle path that contains dash (" - ") in it #2430

Closed
MdFahimulIslam opened this issue Jun 1, 2022 · 3 comments
Closed

Tox can't handle path that contains dash (" - ") in it #2430

MdFahimulIslam opened this issue Jun 1, 2022 · 3 comments
Labels
bug:normal affects many people or has quite an impact needs:more-info

Comments

@MdFahimulIslam
Copy link

MdFahimulIslam commented Jun 1, 2022

Tox.ini

[tox]
minversion = 3.8.0
envlist = python3.8, python3.9, flake8, mypy
isolated_build = true

[testenv]
setenv =
    PYTHONPATH = {toxinidir}
deps =
    -r {toxinidir}{/}requirements_dev.txt
commands =
    pytest pytest --basetemp={envtmpdir} --cov-report term-missing`

Steps

Run "Tox "

Expectation

Should run without error

Error encountered

ERROR: usage: pytest.EXE [options] [file_or_dir] [file_or_dir] [...]
pytest.EXE: error: unrecognized arguments: - ReliSource Inc\15. UNARI\unari\.tox\python3.8\tmp
  inifile: D:\OneDrive - ReliSource Inc\15. UNARI\unari\pyproject.toml
  rootdir: D:\OneDrive - ReliSource Inc\15. UNARI\unari

ERROR: InvocationError for command 'D:\OneDrive - ReliSource Inc\15. UNARI\unari\.tox\python3.8\Scripts\pytest.EXE' pytest '--basetemp=D:\OneDrive' - ReliSource 'Inc\15.' 'UNARI\unari\.tox\python3.8\tmp' 
--cov-report term-missing (exited with code 4)`

Probable cause

Tox can't handle path that contains dash (" - ") in it

@MdFahimulIslam MdFahimulIslam added the bug:normal affects many people or has quite an impact label Jun 1, 2022
@jugmac00
Copy link
Member

jugmac00 commented Jun 2, 2022

As requested in the issue template, could you please add the output of tox -rvv?

@masenf
Copy link
Collaborator

masenf commented Jan 19, 2023

It's good practice to quote your substitutions like "{envtmpdir}" to avoid having them interpreted as multiple arguments (if they contain spaces).

See this example

[tox]
envlist = no,yes

[testenv]
allowlist_externals = /usr/bin/env

[testenv:no]
commands =
    /usr/bin/env bash -c 'mkdir -p {envtmpdir} && echo foo > {envtmpdir}{/}t'
    python -c 'from pathlib import Path; print(Path("{envtmpdir}{/}t").read_text())'

[testenv:yes]
commands =
    /usr/bin/env bash -c 'mkdir -p "{envtmpdir}" && echo foo > "{envtmpdir}{/}t"'
    python -c 'from pathlib import Path; print(Path("{envtmpdir}{/}t").read_text())'

This tox file works fine if the path it's in does not contain spaces, otherwise the no environment will fail due to splitting args on the space.

No spaces

no: commands[0]> /usr/bin/env bash -c 'mkdir -p /Users/masen/code/tox-dev/repro/repro-2430/.tox/no/tmp && echo foo > /Users/masen/code/tox-dev/repro/repro-2430/.tox/no/tmp/t'
no: commands[1]> python -c 'from pathlib import Path; print(Path("/Users/masen/code/tox-dev/repro/repro-2430/.tox/no/tmp/t").read_text())'
foo

no: OK ✔ in 0.15 seconds
yes: commands[0]> /usr/bin/env bash -c 'mkdir -p "/Users/masen/code/tox-dev/repro/repro-2430/.tox/yes/tmp" && echo foo > "/Users/masen/code/tox-dev/repro/repro-2430/.tox/yes/tmp/t"'
yes: commands[1]> python -c 'from pathlib import Path; print(Path("/Users/masen/code/tox-dev/repro/repro-2430/.tox/yes/tmp/t").read_text())'
foo

  no: OK (0.15=setup[0.12]+cmd[0.01,0.02] seconds)
  yes: OK (0.14=setup[0.10]+cmd[0.01,0.02] seconds)
  congratulations :) (0.31 seconds)

With spaces

no: commands[0]> /usr/bin/env bash -c 'mkdir -p /Users/masen/code/tox-dev/repro/repro - 2430/.tox/no/tmp && echo foo > /Users/masen/code/tox-dev/repro/repro - 2430/.tox/no/tmp/t'
bash: /Users/masen/code/tox-dev/repro/repro: Is a directory
no: exit 1 (0.01 seconds) /Users/masen/code/tox-dev/repro/repro - 2430> /usr/bin/env bash -c 'mkdir -p /Users/masen/code/tox-dev/repro/repro - 2430/.tox/no/tmp && echo foo > /Users/masen/code/tox-dev/repro/repro - 2430/.tox/no/tmp/t' pid=30520
no: FAIL ✖ in 0.13 seconds
yes: commands[0]> /usr/bin/env bash -c 'mkdir -p "/Users/masen/code/tox-dev/repro/repro - 2430/.tox/yes/tmp" && echo foo > "/Users/masen/code/tox-dev/repro/repro - 2430/.tox/yes/tmp/t"'
yes: commands[1]> python -c 'from pathlib import Path; print(Path("/Users/masen/code/tox-dev/repro/repro - 2430/.tox/yes/tmp/t").read_text())'
foo

  no: FAIL code 1 (0.13=setup[0.12]+cmd[0.01] seconds)
  yes: OK (0.14=setup[0.10]+cmd[0.01,0.02] seconds)
  evaluation failed :( (0.29 seconds)

Please try quoting the substitutions and kindly reopen this issue with your tox output if the problem persists.

@masenf masenf closed this as completed Jan 19, 2023
@masenf masenf closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2023
@masenf
Copy link
Collaborator

masenf commented Jan 19, 2023

For a more general solution to this problem, see #924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact needs:more-info
Projects
None yet
Development

No branches or pull requests

4 participants