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

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

Open
Kristinita opened this issue Jan 20, 2018 · 3 comments
Open

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

Kristinita opened this issue Jan 20, 2018 · 3 comments
Assignees

Comments

@Kristinita
Copy link

Kristinita commented Jan 20, 2018

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
Copy link
Author

@epsy , the problem is relevant in March 2018.

Thanks.

@Kristinita
Copy link
Author

@epsy , the problem is relevant in April 2018.

Thanks.

@scholer
Copy link
Contributor

scholer commented Nov 25, 2018

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 added a commit to scholer/clize that referenced this issue Nov 26, 2018
…ath) raises a ValueError when the path of the executable is on a different drive than the current directory, Returning basedir as executable name seems appropriate in this case.
epsy pushed a commit that referenced this issue Nov 28, 2018
… raises a ValueError when the path of the executable is on a different drive than the current directory, Returning basedir as executable name seems appropriate in this case.
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

No branches or pull requests

3 participants