139

I recently installed Python 3.7 and at the end of the setup, there is the option to "Disable path length limit". I don't know whether or not I should do this.

What are the pros and cons of doing this? Just from the sound of it you should always disable it.

zcoop98
  • 2,590
  • 1
  • 18
  • 31
Qwerty Qwerts
  • 1,521
  • 2
  • 9
  • 13

4 Answers4

96

I recommend selecting that option and thereby removing the path length limit. It will potentially save you time in future on debugging an avoidable issue.

Here is an anecdote of how I came to know about it:

During the compilation of my program (C# code on a Windows machine), I started getting the following error:

error MSB3541: Files has invalid value "long\path\filename". The specified path,
  file name, or both are too long. The fully qualified file name must be less than
  260 characters, and the directory name must be less than 248 characters.

This error was not allowing me to build my project and the only apparent solution to this issue was to shorten my path/file names. Turns out that this bug is a built-in limitation in NTFS (Window's File System): Why does the 260 character path length limit exist in Windows?

After a couple of decades with the limitation built into the NTFS file system, it has finally been fixed (Unix based system did not have it) in Windows 10 (https://learn.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation), but it is not enabled automatically, and needs registry (or group policy) settings to do this. The Python option allows you to disable it for Python libraries, saving you a lot of headache.

Do note that enabling this option will,

a) break compatibility of your programs on systems using older versions of Windows 10 and lower, when using long file/directory names and paths.

b) break programs on Windows 10 machines not having this option enabled, when using long file/directory names and paths.

Ryan Lundy
  • 204,559
  • 37
  • 180
  • 211
khan
  • 2,070
  • 1
  • 17
  • 14
  • 13
    It's not exactly clear to me which option you are recommending. Should I enable the option to "disable path length limit", or should I NOT disable the limit and keep the limit active? – Justin Sep 03 '19 at 19:58
  • 13
    the question asked for pros and cons. I should be careful giving recommendations before knowing the environment the code will be used in. In Production, better be on the safe side and keep it disabled for cross platform compatibility. You can always shorten long paths in your code if you ever hit the path length problem. @Justin I hope it makes my answer clearer. – khan Sep 12 '19 at 18:18
  • Also confused by the answer as the OP asked about the python installer, but only briefly mentions python. The main reason I'm installing python is for AWS CLI installers on a new PC. I'm mostly just looking to see if it's terribly important for AWS CLI's – Zack Sep 16 '19 at 18:50
  • 2
    FWIW, the capacity to remove the max limit has been around (on an 'opt-in' basis) since 2016. If you've ever hit a problem because of the max limit before (as khan did), you know it can be a really nasty situation. For most users, I would suggest it is time to move towards the future and opt-in to get rid of the max limit. – Cato Minor Nov 03 '19 at 05:43
  • 10
    The question talked about *disabling* the limit on file length. Your answer led with "*enabling* it" (and your comment mentions "keep it disabled"), but it seems that by "it" you mean "the setting to disable the limit"/"the revoking of platform compatibility", not "the limit on file length". That's where Justin's confusion was coming from. – Mark S. Dec 01 '19 at 19:39
  • I installed Python with conda. How do I fix this? Why is everything involving python such a crapshoot that requires rocket science knowledge? This is so frustrating. – Arrow_Raider May 23 '21 at 16:40
10

to answer both of your questions:

Should you disable this?

The quick answer is that it doesn't matter that much, since this only matters when working with paths longer than 260 characters, not something most people do.

What are the pros and cons of disabling the path length limit?

Pros

  • you won't get an error when working with filepaths longer than 260 characters, so there's less worry about the path length
  • it can make debugging easier

Cons

  • disabling it has no negative technical side effects
  • if you work in a team, it might introduce bugs where code works on your machine, but not on their machine. because you have the path-limit disabled, but they don't.
  • disabling it can have negative human behaviour side effects. Enabling long paths could promote bad naming-behaviour in your team regarding pathnames and folderstructure. A limit forces people to shorten their paths.

E.g. I've worked in teams with paths like this, and allowing them longer names would have resulted in less readable filepaths:

c:/project_name/unity/files/assets/UI/UI_2.0/levelname/season2_levelname/release_season2_levelname_ui_2/PROJECT_S2_MENU_UI/PROJECT_S2_hover_button_shadow_ui/PROJECT_S2_hover_button_shadow_ui_blue/PROJECT_S2_hover_button_shadow_ui_blue.asset

Explanation

To understand the pros and cons, it helps to understand what the path length limit is.

windows path length

You probably already know that a Windows path is a string, that represents where to find a file or folder.

e.g. C:\Program Files\7-Zip

longer folder or file names result in a longer string.

e.g. C:\Program Files\Microsoft Update Health Tools

more folders inside other folders also result in a longer string

e.g. C:\Program Files\Microsoft Update Health Tools\Logs

file path length errors

If you have a lot of folders inside each other, with long names, you might run into an error when trying to use this path in your code.

This is because Windows has a path length limit. An update in windows 10 allows you to disable this limitation. but it doesn't do so by default.

Disabling this limitation allows your computer to use longer paths without errors.

Why does this happen?

The old windows API promised that if you wrote your application correctly, it'd continue to work in the future.

If Windows were to allow filenames longer than 260 characters then your existing application (which used the windows API correctly) would fail.

Microsoft did create a way to use the full 32,768 path names; but they had to create a new API contract to do it. This is the update on windows 10.

read more on why

Hannes
  • 111
  • 1
  • 5
3

I am keeping this simple and straight forward

The "Disable path length limit" option refers to the maximum length of the file paths that Windows can handle. Disabling this limit can allow for longer file paths, which can be useful if you are working with files that have very long names or are stored in deeply nested directories. However, it can also cause compatibility issues with some programs, particularly older ones that may not designed to support long file paths.

In general, it's usually not necessary to disable the path length limit unless you have a specific need for it. If you're not sure whether you need it or not, it's probably best to leave it enabled.

Jamiu S.
  • 5,257
  • 5
  • 12
  • 34
2

Generally, it's not a good idea to disable it, especially if you have programs that could potentially break upon disabling it.
I have a lot of older programs, and potentially forgetting that I disabled it, and the fact that re-enabling it (being that finding out how to) and the fact that doing that could potentially break any program that uses long file paths in its scripts, makes having it off unhelpful, and moreover possibly a waste of time and debugging.

But to defend its existence, in certain environments it can be helpful, especially in environments where making subfolders upon subfolders is key. Particularly, this is helpful when making a game with a lot of assets. But again, there are many ways to shorten subfolders (and files), and doing that makes it generally easier to type out the path if you aren't copy-and-pasting everywhere. (For example, C:\my_game\assts\01\plyr\walk_01.png is easier to type than C:\my_epic_game_featuring_my_awesome_character\assets\…)

If you have a virtual machine or just another OS to try this on where you do not have to worry about specific programs breaking upon disabling the path limit, it'd probably be useful to have this off, but for everything else, just be wary of it's probability to make more bugs than to fix.

Omega
  • 29
  • 1
  • 6