Skip to content

[feature/bug] PATH can get overfilled on windows very easly #18627

@Marc-Pierre-Barbier

Description

@Marc-Pierre-Barbier

What is your suggestion?

Hi,

On Windows, apps such as nvcc will begin to break if the PATH environment variable is overfilled.

A stock, not using Conan, developer command prompt on my system is using 2695 characters in the PATH. Visual Studio has a nasty tendency to add even more. The theoretical limit is VERY, VERY blurry. In somewhere between 2048 and 32000, cmd.exe no longer inherit variable after 8191 for instance (https://superuser.com/questions/1070272/why-does-windows-have-a-limit-on-environment-variables-at-all), and I believe that NVCC breaks around 4000.

I noticed on a very large conan project, the windows PATH variable can get filled enough to break nvcc. (on our project we are at 3074 chars)

I believe we can do a few things to mitigate the issue:

  1. make the PATH variable we define during the generation of conanbuild.sh an ordered set, where a prepend_path will always be preferred to an apprend_path.

This will ensure there is no redundant variable coming directly from conan itself. For example, I had cpython in both tool_requires and requires with the env_var=True option set, this meant that in my PATH there was this string 'C:\Users\mbarbier.conan2\p\cpyth42b953d7b1f8c\p\bin' three times. Contributing to 156

  1. (im not a fan of this fix) Do what conan1 did with the C:/conan directory making all paths significantly shorter, this would only reduce by 6 + the length of the username characters

  2. (im not a fan of this fix) Use short form paths where ever possible

I already sent a message to Microsoft suggesting them to use short form paths to reduce by 400 character the size of the environment, And to nvidia requesting them to increase the limit to the 32000 supported by windows. But knowing these two companies, I don't expect older versions of cuda to ever be updated with a fix and I fully expect microsoft to ignore my email.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions