conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.24k stars 980 forks source link

[question] /bin/sh: 1: /root/.conan2/p/b/xxx/b/src/configure: Permission denied #14345

Closed BrainLyh closed 1 month ago

BrainLyh commented 1 year ago

What is your question?

Hi,Can i control the permission about the file in /root/.conan2/... when i run conan create conanfile.py --version=1.0.1 --build=missing?

This is the error output:

-------- Installing package ffmpeg/5.1.3 (37 of 37) --------
ffmpeg/5.1.3: Building from source
ffmpeg/5.1.3: Package ffmpeg/5.1.3:c495e5045744b639a36c3a6326ab19f1b14d16bc
ffmpeg/5.1.3: Copying sources to build folder
ffmpeg/5.1.3: Building your package in /root/.conan2/p/b/ffmpe7541d15a0b2fb/b
ffmpeg/5.1.3: Calling generate()
ffmpeg/5.1.3: Generators folder: /root/.conan2/p/b/ffmpe7541d15a0b2fb/b/build-release/conan
ffmpeg/5.1.3: Generating aggregated env files
ffmpeg/5.1.3: Generated aggregated env files: ['conanbuild.sh']
ffmpeg/5.1.3: Calling build()
ffmpeg/5.1.3: apply_conandata_patches(): No patches defined in conandata
ffmpeg/5.1.3: Calling:
 > "/root/.conan2/p/b/ffmpe7541d15a0b2fb/b/src/configure" --disable-shared --enable-static --prefix=/ '--bindir=${prefix}/bin' '--libdir=${prefix}/lib' --pkg-config-flags=--static --disable-doc --disable-cross-compile --enable-asm --disable-shared --enable-static --enable-pic --enable-avdevice --enable-avcodec --enable-avformat --enable-swresample --enable-swscale --enable-postproc --enable-avfilter --enable-bzlib --enable-zlib --enable-lzma --enable-iconv --enable-libopenjpeg --enable-libopenh264 --enable-libvorbis --enable-libopus --disable-libzmq --disable-sdl2 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libfdk-aac --enable-libwebp --enable-openssl --enable-alsa --enable-libpulse --enable-vaapi --enable-vdpau --enable-libxcb --enable-libxcb-shm --enable-libxcb-shape --enable-libxcb-xfixes --disable-appkit --disable-avfoundation --disable-coreimage --disable-audiotoolbox --disable-videotoolbox --disable-securetransport --disable-cuda --disable-cuvid --enable-nonfree --enable-gpl --enable-vulkan --arch=x86_64 --cc=gcc --cxx=g++ '--extra-cflags=-m64 -fPIC -O3' --extra-ldflags=-m64 
ffmpeg/5.1.3: RUN: "/root/.conan2/p/b/ffmpe7541d15a0b2fb/b/src/configure" --disable-shared --enable-static --prefix=/ '--bindir=${prefix}/bin' '--libdir=${prefix}/lib' --pkg-config-flags=--static --disable-doc --disable-cross-compile --enable-asm --disable-shared --enable-static --enable-pic --enable-avdevice --enable-avcodec --enable-avformat --enable-swresample --enable-swscale --enable-postproc --enable-avfilter --enable-bzlib --enable-zlib --enable-lzma --enable-iconv --enable-libopenjpeg --enable-libopenh264 --enable-libvorbis --enable-libopus --disable-libzmq --disable-sdl2 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libfdk-aac --enable-libwebp --enable-openssl --enable-alsa --enable-libpulse --enable-vaapi --enable-vdpau --enable-libxcb --enable-libxcb-shm --enable-libxcb-shape --enable-libxcb-xfixes --disable-appkit --disable-avfoundation --disable-coreimage --disable-audiotoolbox --disable-videotoolbox --disable-securetransport --disable-cuda --disable-cuvid --enable-nonfree --enable-gpl --enable-vulkan --arch=x86_64 --cc=gcc --cxx=g++ '--extra-cflags=-m64 -fPIC -O3' --extra-ldflags=-m64 
/bin/sh: 1: /root/.conan2/p/b/ffmpe7541d15a0b2fb/b/src/configure: Permission denied

ffmpeg/5.1.3: ERROR: 
Package 'c495e5045744b639a36c3a6326ab19f1b14d16bc' build failed
ffmpeg/5.1.3: WARN: Build folder /root/.conan2/p/b/ffmpe7541d15a0b2fb/b/build-release
*********************************************************
Recipe 'ffmpeg/5.1.3' cannot build its binary
It is possible that this recipe is not Conan 2.0 ready
If the recipe comes from ConanCenter check: https://conan.io/cci-v2.html
If it is your recipe, check if it is updated to 2.0
*********************************************************

ERROR: ffmpeg/5.1.3: Error in build() method, line 675
        autotools.configure()
        ConanException: Error 126 while executing

root@1f980fa2a4a6:~/.conan2/p/b/ffmpe7541d15a0b2fb/b/src# ls -la
total 712
drwxr-xr-x 17 root root   4096 Jul 21 17:16 .
drwxr-xr-x  4 root root   4096 Jul 21 17:16 ..
-rw-r--r--  1 root root  74753 Jul 21 17:16 Changelog
drwxr-xr-x 11 root root   4096 Jul 21 17:16 compat
-rw-r--r--  1 root root 269320 Jul 21 17:16 configure

I not sure whether i'm right if changed global.conf:

tools.system.package_manager:mode = install
tools.system.package_manager:sudo = True

but set tools.system.package_manager:sudo = True,will meet error in my docker env.

Have you read the CONTRIBUTING guide?

memsharded commented 1 year ago

Hi @BrainLyh

this is not related at all with the tools.system.package_manager, that is for the system_requirements() method calling some system package manager like apt or yum, so those confs will not help.

Here what is failing is the regular build() method calling ./configure autotools script. In theory, it is possible to do things like chmod if necessary in recipes, but ConanCenter recipe is already expected to work, this shouldn't be necessary in most cases, but if you manage to do some changes in the conan-center-index recipe and conan create it, that would be very useful information, and could be contributed back to the recipe in that case.

It seems to be failing due to permissions, it is likely that running as root in /root/.conan2 is the cause. Not sure if running Conan under sudo would fix it, but that doesn't sound like a good approach. I think I would try with other user, or checking some general permissions in the docker.

BrainLyh commented 1 year ago

Hi @memsharded

i trying to change the floder premission during build. It works,but not sure is a good approach.

@@ +142 @@ /conan_src/conans/client/installer.py

import subprocess 
...
    with chdir(base_build):
            conanfile.output.info('Building your package in %s' % base_build)
            conanfile.output.info("Chmoding generated folders")
            cmd_list = ['chmod','-R','755',base_build]
            subprocess.run(cmd_list, check=True)
memsharded commented 1 year ago

No, patching Conan source code and modifying /conan_src/conans/client/installer.py should be a very extreme exception, and should be avoided as much as possible, and it would be very discouraged for something like this, as changing all permissions for all files in all built packages can have unintended consequences and produce other problems in other packages.

If anything, I'd recommend forking the ffmpeg recipe only, and creating a package from the modified recipe, or if it makes sense, fixing the recipe upstream in the conan-center-index repo.

Still, it is possible that there might be other solution elsewhere, if it is only failing for you and not other Conan users so far, it must be something in the setup/docker/system or something like that.

fdgStilla commented 9 months ago

Hi @memsharded, I have the same issue with the icu package, I guess this issue can be reproduced with any recipe using the configure script in the target repo, which is a lot of recipe from conan center.

I managed find the original issue in python and reproduced it with conan: https://github.com/python/cpython/issues/108254. Obviously we don't want to change the owner of the files so that's too bad it prevent us from having the correct execution rights on the extracted files, but it seems that there is no way to avoid the chown using tarfile.extract.

What do you think is the correct way of fixing this?

memsharded commented 9 months ago

Hi @memsharded, I have the same issue with the icu package, I guess this issue can be reproduced with any recipe using the configure script in the target repo, which is a lot of recipe from conan center.

No, not really we are both building these recipes in ConanCenter without issues as well as many thousands of users, so this doesn't seem to be a mainstream problem easy to reproduce.

The best would be to provide fully reproducible case, including the docker image to reproduce. I'd suggest using conanio images, but most likely they will not fail, so I guess it would be using other docker configuration?

memsharded commented 1 month ago

Closing as stale. If you have any fully reproducible case, like with the above recommended docker images, please re-open or create a new ticket to check them. Thanks for the feedback!