esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Permission denied #2817

Open eximo84 opened 2 years ago

eximo84 commented 2 years ago

The problem

updating my ESP devices, now get Permission Denied after compile. Reading appears to be an issue with execute permissions on the file system? I mapped a new folder inside my SMB shared folder where the current configuration exists called "/cache" and gave all files and folders 777 permissions however still getting errors.

Which version of ESPHome has the issue?

2021.12.0

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

2021.11.4

What platform are you using?

ESP32

Board

nodemcu

Component causing the issue

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <WiFi> 1.0
|-- <FS> 1.0
|-- <Update> 1.0
|-- <ESPAsyncWebServer-esphome> 2.1.0
|   |-- <AsyncTCP-esphome> 1.2.2
|-- <DNSServer> 1.1.0
|-- <Wire> 1.0.1
|-- <ESPmDNS> 1.0
Compiling .pioenvs/esp32_dev_03/src/esphome/components/api/api_connection.cpp.o
sh: 1: xtensa-esp32-elf-g++: Permission denied
Compiling .pioenvs/esp32_dev_03/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/esp32_dev_03/src/esphome/components/api/api_pb2.cpp.o
sh: 1: xtensa-esp32-elf-g++: Permission denied
*** [.pioenvs/esp32_dev_03/src/esphome/components/api/api_connection.cpp.o] Error 126
*** [.pioenvs/esp32_dev_03/src/esphome/components/api/api_frame_helper.cpp.o] Error 126
sh: 1: xtensa-esp32-elf-g++: Permission denied
Compiling .pioenvs/esp32_dev_03/src/esphome/components/api/api_pb2_service.cpp.o
*** [.pioenvs/esp32_dev_03/src/esphome/components/api/api_pb2.cpp.o] Error 126
sh: 1: xtensa-esp32-elf-g++: Permission denied
*** [.pioenvs/esp32_dev_03/src/esphome/components/api/api_pb2_service.cpp.o] Error 126

Additional information

No response

LarkeMikko commented 2 years ago

I have had similar issue past 5 days (from december 17) and haven't found solution yet.. I have tried re installing, updating and upgrading pretty much everything related to esphome and platformio with no change.. I'm running esphome with debian if that information helps for finding solutions

coax commented 2 years ago

It's a cache folder issue, explained here: https://github.com/esphome/issues/issues/2594#issuecomment-949419636

horodchukanton commented 2 years ago

@coax Thanks! I've got my permissions problem fixed by adding the 'exec' option to the /etc/fstab entry for the drive that has the docker mount point on.

u20p17 commented 2 years ago

@coax Thanks! I've got my permissions problem fixed by adding the 'exec' option to the /etc/fstab entry for the drive that has the docker mount point on.

Hi, I have the same problem and tried your suggestion. I opened the terminal on unraid, then cd /etc and after that nano fstab... Here I added the exec option to my hard drive and saved it.

 GNU nano 5.3                                                                                fstab                                                                                          
/dev/disk/by-label/UNRAID  /boot         vfat      auto,rw,flush,noatime,nodiratime,dmask=77,fmask=177,shortname=mixed,exec  0  1
/boot/bzmodules            /lib/modules  squashfs  ro,defaults  0  2
/boot/bzfirmware           /lib/firmware squashfs  ro,defaults  0  2
tmpfs                      /dev/shm      tmpfs     defaults     0  0
hugetlbfs                  /hugetlbfs    hugetlbfs defaults     0  0

But the problem stayed there. Did I something wrong? (Unraid 6.9.2, ESPHome, 2022.02.06 in a docker)

Thanks!

ssieb commented 2 years ago

/boot is not the right filesystem. Also, your root filesystem, whatever it is, will already have execute permission or nothing would work at all. You need to find out where your container /config points to or add a mapping to the container for /cache that points to local storage.

u20p17 commented 1 year ago

@ssieb: My /config points to /mnt/user/appdata/ESPHome. What do I have to do in order to fix the problem?

Thanks!

horodchukanton commented 1 year ago

@u20p17 Your folder should have execution permission for the user which owns the ESPHome process (docker container in your case)

In my case the problem was in the mount attributes (I had noexec specified)

If that is not your case you should fix the specific folder permissions. Use ls -ld /mnt/user/appdata/ESPHome to check the permissions on the folder. Use ps aux | grep esphome to see the owner of the process. Adjust either the permissions with chown, chmod, or the process owner by specifying the --user attribute for the docker command.

u20p17 commented 1 year ago

@horodchukanton : I did the first two steps you wrote and this is the result: result

The user who should get permissions is called u20p17 - how would the command look like in this case? Thank you in advance!

horodchukanton commented 1 year ago

@u20p17 I'm sorry, but the commands were wrong ) The ls should have -ld to show permissions on the folder itself and the ps should have uax to show the owner of the process (already updated the commands in previous message).

To make u20p17 owner of the folder, simply call the chown -R u20p17:root /mnt/user/appdata/ESPHome

Also, you probably have the execution bit missing according to the file permissions. You can add it with chmod u+x /mnt/user/appdata/ESPHome

u20p17 commented 1 year ago

@horodchukanton : I now tried the updated commands, but to be honest I can not see who is the ower of the folder... result

I didn't try to make u20p17 the owner, because I do not want to destroy anything :P

horodchukanton commented 1 year ago

@u20p17 Can you show the mount options? mount | grep /mnt/user

u20p17 commented 1 year ago

@horodchukanton

image

horodchukanton commented 1 year ago

@u20p17 You should add the exec mount option

u20p17 commented 1 year ago

@horodchukanton : I put chmod u+x /mnt/user/appdata/ESPHome in the cmd and after that restartet unraid completely - same issue with esphome :(

horodchukanton commented 1 year ago

@u20p17 That's not what I meant. You're mounting the remote share without the exec option, and as the result the local OS does not allow you to execute files. You should add the ,exec option to your /etc/fstab line

u20p17 commented 1 year ago

@horodchukanton: if I open the etc/fstab I see the following:

image

What would I need to add there? Thanks again!

horodchukanton commented 1 year ago

@u20p17 Please refer to the SSHFS documentation on how to specify the permanent mount

u20p17 commented 1 year ago

@horodchukanton: I now tried to add the mount to the/etc/fstab. I added the following:

UUID=301d42ac-f4eb-4e55-8792-9ad57d1ef60f /mnt/user/appdata/ESPHome xfs defaults,exec 0 0

After saving the fstab I worte mount --all in the cmd and after that I tried to compile again with ESPHome... But the permission error is still there - why?

horodchukanton commented 1 year ago

@u20p17 Im sorry, but I am not able to help you with mounts, as I know too little about your configuration. Please look for help in specific Linux community.

u20p17 commented 1 year ago

I think I fixed the issue now. It's a bit strange, but what I did is the following: 1.) ls -ld /mnt/user/appdata/ESPHome Output: drwxrwxrwx 1 nobody users 90 Mar 3 2022 /mnt/user/appdata/ESPHome/ So it seemed that the every user/group should have read/write/execute rights on this folder. Nevertheless I did the following:

2.) chmod -R 777 /mnt/user/appdata/ESPHome I recursive changed the rights for all users/groups to read/wrtie/execute and now it is working again... Strange - but maybe it helps other people...

/mnt/user/appdata/ESPHome points to the /config folder of ESPHome...