千石

千石の云上小窝

Talk is cheap, show me the code
bilibili
github
email

Solution to the problem of "This environment variable is too large, this dialog box allows the value to be set to a maximum of 2047 characters" when editing environment variables in Windows.

Background#

One day I was configuring ffmpeg and encountered an error message saying "This environment variable is too large. This dialog allows setting the value to a maximum of 2047 characters."

image

Finding a Solution#

After researching, I found that this error occurs when editing system environment variables and the length of a specific variable exceeds the maximum character limit allowed by Windows. This usually happens when modifying the PATH variable because over time, installed programs may continuously add new paths to the PATH variable, causing it to become excessively large.

There are two solutions:

  1. Manually edit and delete the environment variables causing the issue. However, I am feeling lazy and manual editing can lead to unknown problems, so I gave up on this option.

If you want to implement this solution, you can consider:

  • Splitting the PATH variable into multiple smaller parts.
  • Creating new environment variables and moving some paths from PATH to these new variables.
  • Using these new variables in PATH, such as %NEW_VAR%, to reduce the overall length of PATH.
  1. Use a specialized environment variable editing tool.
    There are many free environment variable editing tools available online. These tools are relatively professional and easy to manage in the long run. In this article, I chose this solution.

Solution Process#

After researching, I chose the software "Rapid Environment Editor". It is a free environment variable editing tool with a user-friendly interface that makes it easier to manage environment variables, including the PATH variable. It allows viewing, editing, and cleaning environment variables, and also supports undo and redo operations.
For more detailed information about this software, you can visit the official website: https://www.rapidee.com/

Open the software download page and click on the installation file to download: https://www.rapidee.com/en/download

image

Afterwards, open the installation file and complete the installation process. Those familiar with installing software should be familiar with this process, so I won't go into detail here.

Open the software with administrator privileges and you will see the following interface:

image

The interface is user-friendly and the operations are convenient. If you want to expand and view a specific variable, you can click on the '+' icon next to the variable name:

image

Taking adding PATH as an example, right-click on PATH:

image

Click on Add value and simultaneously press F7. Select the directory you want to add to the environment variable and click OK:

image

You can see that the directory has been successfully added to the environment variable:

image

You can also verify it by checking the Windows environment variable page:

image

You can also verify it by opening a new terminal:

image

End of article.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.