clize icon indicating copy to clipboard operation
clize copied to clipboard

[Bug] ValueError: path is on mount 'C:', start on mount 'D:'

Open Kristinita opened this issue 7 years ago • 3 comments

1. Summary

My CLI program successful work for disk C, but not for disk D.

Possibly, it Clize bug, not bug in my program.

2. Settings

2.1. Environment

  • Windows 10 Enterprise LTSB 64-bit EN,
  • Python 3.6.4,
  • clize 4.0.3,
  • logbook 1.1.0.

2.2. Project

https://github.com/Kristinita/SashaPythonTest

my simple program check, contains <body> in .txt files in folder or no.

It that I want in #35.

2.3. Folders

I have 2 folders with similar content:

  • SashaPythonTestOnDiskC — on disk C,
  • SashaPythonTestOnDiskD — on disk D.

Content of SashaPythonTestOnDiskC and SashaPythonTestOnDiskD folders:

C:\SashaPythonTestOnDiskC>tree /f
C:.
    BodyExists.txt
    NoBody.txt

BodyExists.txt file:

<body>

NoBody.txt file:

No

3. Steps to reproduce

I install my project:

setup.py install

I run command sashatest in console.

4. Expected behavior

For C:\SashaPythonTestOnDiskC:

C:\SashaPythonTestOnDiskC>sashatest --help
Usage: ..\Python36\Scripts\sashatest [OPTIONS]

Change log levels via command line.

User select, which logging messages to see. See about 6 log levels here: https://logbook.readthedocs.io/en/stable/quickstart.html

Options:
  --logbook-level, --ll=STR   user select logging level (default: NOTICE)

Other actions:
  -h, --help                  Show the help
  --version                   Show version.
  -v                          Alternative show version.

C:\SashaPythonTestOnDiskC>sashatest
[2018-01-20 17:44:13.035785] ERROR: eric_body logbook: File NoBody.txt not contain <body>.
[2018-01-20 17:44:13.036806] ERROR: eric_body logbook: Not all files contains <body>. Please, correct your files.
[2018-01-20 17:44:13.036806] ERROR: run_tests logbook: Failure!

C:\SashaPythonTestOnDiskC>sashatest --ll=DEBUG
[2018-01-20 17:52:41.227187] DEBUG: eric_body logbook: BodyExists.txt contains <body>
[2018-01-20 17:52:41.228178] ERROR: eric_body logbook: File NoBody.txt not contain <body>.
[2018-01-20 17:52:41.228178] ERROR: eric_body logbook: Not all files contains <body>. Please, correct your files.
[2018-01-20 17:52:41.228178] ERROR: run_tests logbook: Failure!

5. Actual behavior

For D:\SashaPythonTestOnDiskD:

D:\SashaPythonTestOnDiskD>sashatest
Traceback (most recent call last):
  File "C:\Python36\Scripts\sashatest-script.py", line 11, in <module>
    load_entry_point('sashatest==0.0.1', 'console_scripts', 'sashatest')()
  File "C:\Python36\lib\site-packages\sashatest-0.0.1-py3.6.egg\sashatest\__main__.py", line 18, in main
    run(clize_log_level, alt=[version, v], exit=False)
  File "C:\Python36\lib\site-packages\sigtools\modifiers.py", line 158, in __call__
    return self.func(*args, **kwargs)
  File "C:\Python36\lib\site-packages\clize\runner.py", line 353, in run
    args = fix_argv(sys.argv, sys.path, module)
  File "C:\Python36\lib\site-packages\clize\runner.py", line 284, in fix_argv
    name = get_executable(argv[0], argv[0])
  File "C:\Python36\lib\site-packages\clize\runner.py", line 303, in get_executable
    rel = os.path.relpath(path)
  File "C:\Python36\lib\ntpath.py", line 585, in relpath
    path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'

Thanks.

Kristinita avatar Jan 20 '18 18:01 Kristinita

@epsy , the problem is relevant in March 2018.

Thanks.

Kristinita avatar Mar 10 '18 05:03 Kristinita

@epsy , the problem is relevant in April 2018.

Thanks.

Kristinita avatar Apr 18 '18 17:04 Kristinita

Having the same Windows issue. I'm using a setup.py entry-point (installed in my conda environment on C:, available in my PATH envvar), which is executed from a folder on the D: drive.

The problem is in runner.py:303, which is invoking rel = os.path.relpath(path). Executing relpath when the current directory is on D: but path starts with C: will raise the exception.

I fixed the issue by patching my runner.py file, changing line 303 to this:

try:
    rel = os.path.relpath(path)
except ValueError:
    return basename

I think there may also be some other Windows-specific bugs, e.g. the if which(basename) == path: check in line 301 might fail for windows executables, where .EXE and .BAT are added to the executable. But that wasn't relevant in my case.

scholer avatar Nov 25 '18 21:11 scholer