microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.9k stars 6.32k forks source link

[icu] Build error (windows): File name too long #22976

Open jaydenkim opened 2 years ago

jaydenkim commented 2 years ago

Host Environment

To Reproduce Steps to reproduce the behavior: ./vcpkg install xxxx

Failure logs

mkdir: cannot create directory '/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/packages/icu_x64-windows/C/Users/xxx/Documents/projectx/external/PreBuildProj': File exists
mkdir: cannot create directory '/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/packages/icu_x64-windows/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg': File exists
mkdir: cannot create directory '/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/packages/icu_x64-windows/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/installed': File exists
mkdir: cannot create directory '/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/packages/icu_x64-windows/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/installed/x64-windows': File exists
mkdir: cannot create directory '/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/packages/icu_x64-windows/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/installed/x64-windows/debug': File exists
ln: failed to create symbolic link 'current' -> '69.1': File name too long
ln: failed to create symbolic link 'Makefile.inc' -> 'current/Makefile.inc': File name too long
ln: failed to create symbolic link 'pkgdata.inc' -> 'current/pkgdata.inc': File name too long
make: *** [Makefile:197: install-icu] Error 1
make: *** Waiting for unfinished jobs....
ln: failed to create symbolic link 'current' -> '69.1': File name too long
ln: failed to create symbolic link 'Makefile.inc' -> 'current/Makefile.inc': File name too long
ln: failed to create symbolic link 'pkgdata.inc' -> 'current/pkgdata.inc': File name too long
make[1]: *** [Makefile:197: install-icu] Error 1
make: *** [Makefile:153: install-recursive] Error 2
JackBoosY commented 2 years ago
File name too long

Please clone vcpkg in a shorter path such as d:\ and try again.

PhoebeHui commented 2 years ago

@jaydenkim, does this still be a problem for you?

JackBoosY commented 2 years ago

We hope your question was answered to your satisfaction; if it wasn't, you can reopen with more info.

hyt589 commented 1 year ago
File name too long

Please clone vcpkg in a shorter path such as d:\ and try again.

I am facing the same issue on a ci agent, changing to a shorter path is not possible as it is determined by the ci server. Is there any other way to work around this issue?

JackBoosY commented 1 year ago

@hyt589 ./vcpkg install ... --x-buildtrees-root=<SHORTER_PATH>

hyt589 commented 1 year ago

@hyt589 ./vcpkg install ... --x-buildtrees-root=<SHORTER_PATH>

Thanks for the quick reply! Our project is set up in manifest mode because we need to pin some dependency versions, and as I understand it running vcpkg install is not possible in this mode.

JackBoosY commented 1 year ago

@hyt589 ./vcpkg install ... --x-buildtrees-root=<SHORTER_PATH>

Thanks for the quick reply! Our project is set up in manifest mode because we need to pin some dependency versions, and as I understand it running vcpkg install is not possible in this mode.

cmake.exe ... -DVCPKG_INSTALL_OPTIONS="--x-buildtrees-root=<SHORTER_PATH>"

hyt589 commented 1 year ago

@hyt589 ./vcpkg install ... --x-buildtrees-root=<SHORTER_PATH>

Thanks for the quick reply! Our project is set up in manifest mode because we need to pin some dependency versions, and as I understand it running vcpkg install is not possible in this mode.

cmake.exe ... -DVCPKG_INSTALL_OPTIONS="--x-buildtrees-root=<SHORTER_PATH>"

I tried that, and it successfully changed the buildtree root path, but it seems the installation path is still too long. I also tried adding --x-install-root to VCPKG_INSTALL_OPTIONS, but it seems vcpkg doesn't accept more than 1 options?

JackBoosY commented 1 year ago

I tried that, and it successfully changed the buildtree root path, but it seems the installation path is still too long.

So the best way is unlock the path length limit on Windows using Windows register.

I also tried adding --x-install-root to VCPKG_INSTALL_OPTIONS, but it seems vcpkg doesn't accept more than 1 options?

VCPKG_INSTALL_OPTIONS, so I don't think that this option can't pass multiple options.

hyt589 commented 1 year ago

So the best way is unlock the path length limit on Windows using Windows register.

I tried the registry with no luck, for some reason it just won't allow long paths.

VCPKG_INSTALL_OPTIONS, so I don't think that this option can't pass multiple options.

The issue was I already defined VCPKG_INSTALLED_DIR in cmake, which caused vcpkg to complain --x-install-root was defined twice. I solved the issue by overriding VCPKG_INSTALLED_DIR.

Thanks for your help.

rtchade commented 11 months ago

I'm hitting this same issue. Although the symptom is that the path is too long, the root cause of such a long path is that the root path is repeated in the install path for this package.

You can see this in the OP's error log if you look closely at the path mkdir tries to create:

mkdir: cannot create directory '/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/packages/icu_x64-windows/C/Users/xxx/Documents/projectx/external/PreBuildProj': File exists

The ln calls first cd into this repeated directory and try to link, and that's when it fails. I think the fix here is to stop this path repetition from happening. Other packages do not seem to have this behavior and install to my x-packages-root directory as I'd expect.

Is this intentional behavior, or is there something I should be doing to prevent this?

Here you can see that in my install directory, the installed icu package includes the entire root path again as a subdirectory. I'd expect this folder to not exist and for the files it contains to just live inside the parent folder.

image

JackBoosY commented 11 months ago

I'm hitting this same issue. Although the symptom is that the path is too long, the root cause of such a long path is that the root path is repeated in the install path for this package.

You can see this in the OP's error log if you look closely at the path mkdir tries to create:

mkdir: cannot create directory '/C/Users/xxx/Documents/projectx/external/PreBuildProj/vcpkg/packages/icu_x64-windows/C/Users/xxx/Documents/projectx/external/PreBuildProj': File exists

The ln calls first cd into this repeated directory and try to link, and that's when it fails. I think the fix here is to stop this path repetition from happening. Other packages do not seem to have this behavior and install to my x-packages-root directory as I'd expect.

Is this intentional behavior, or is there something I should be doing to prevent this?

Here you can see that in my install directory, the installed icu package includes the entire root path again as a subdirectory. I'd expect this folder to not exist and for the files it contains to just live inside the parent folder.

image

Does your OS account contain empty space ?

rtchade commented 11 months ago

Does your OS account contain empty space ?

No

>whoami
cengler-m16\cengl

The path also doesn't include spaces and isn't using my user folders, except to invoke vcpkg which I'm storing in %TEMP%.

rtchade commented 11 months ago

If it helps my invocation looks like:

    :: Runs in manifest mode to install `msdfgen`
    %TEMP%\vcpkg-Win64\vcpkg.exe install ^
        --overlay-ports=.\overlay-ports ^
        --overlay-triplets=.\overlay-triplets ^
        --x-manifest-root=.\Win64\x64-windows-static-md-v142 ^
        --x-packages-root=.\Win64\x64-windows-static-md-v142 ^
        --triplet=x64-windows-static-md-v142

My manifest looks like this:

{
  "name": "msdf",
  "version-string": "1.0.0",
  "dependencies": [
    "msdfgen"
  ]
}

My overlay-ports directory is currently empty, but I do have some overlay-triplets. The x64-windows-static-md-v142 one looks like this:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_PLATFORM_TOOLSET v142)
set(VCPKG_BUILD_TYPE release)

I'm using tag 2023.08.09 when I clone vcpkg.

Edit: If I do this instead, it doesn't duplicate the path in the install location:

    pushd %TEMP%\vcpkg-Win64

    :: Runs in classic mode to install `msdfgen`
    vcpkg.exe install msdfgen ^
        --overlay-ports=C:\xxx\overlay-ports ^
        --overlay-triplets=C:\xxx\overlay-triplets ^
        --triplet=x64-windows-static-md-v142

    popd

Right now as a workaround I'm trying to write a script that installs in the %TEMP% vcpkg folder directly using the above and then copying the resulting libraries into my project.

JackBoosY commented 11 months ago

@Cheney-W Please investigate this.

dg0yt commented 2 months ago

Please change the issue title to:

[icu] Build error (windows): File name too long