Git issue with Visual Studio Code and Openhabian

  • Platform information:
    • Hardware: Raspberry Pi4
    • OS: Openhabian - newest build
    • Java Runtime Environment: Openhabian
    • openHAB version: 3.4.2
  • Issue of the topic:
    I’m a very experienced openhanded user, but encounter an issue where I have no clue when it started.
    I want to use Visual Studio Code on my Mac with its builtin git extension. To narrow down my issues I’ve tried the following steps (which already fail, so that’s why they also fail with Visual Studio Code).
    ** Using a Mac I am accessing the $OPENHAB_CONF directory on my Openhabian Installation on a Raspi4 using the SMB drive provided by the Standard Openhabian Setup.
    ** I use the git version 2.40.1 on my Mac installed via Homebrew
  1. when cd into the directory mounted on my Mac after establishing the SMB connection (actually /Volumes/openhab-conf) I issue:
    git init
    works, it says Initialized empty Git repository in /Volumes/openhab-conf/.git/
    ** git add .

I get the following errors:
error: unable to write file .git/objects/39/ac7ea9e042de7265bd7d279f1f813f7407b413: Input/output error
error: items/netatmo.items: failed to insert into database
error: unable to index file ‘items/netatmo.items’
fatal: adding files failed
** I can write files in that directory e.g. using cat > .git/objects/39/test
it doesn’t depend on if I connect to that SMB share using root or the openhabian user.

Thanks for any help in advance, but that drives me mad.

Your Mac uses Linux style file ownership and permissions. SMB uses Windows style ownership and permissions. Consequently Samba does some “magic” to make the two compatible. One of the things it does is it flattens the ownership of the files in the share. So you are going through a double translation from Linux/Unix style to Windows style and back to Unix style.

So it lets you create the files and folders in the first place because the permissions on the folder allow that. But it created the files with a different owner, the openhab user on the SMB share machine and given the permissions you can’t change them because you Mac user isn’t the openhab user.

So what is the ownership of those files? It’s likely user openhab. Since that user doesn’t exist on your Mac it probably shows up as just a number. What do you see when you run the command ls -l in that folder? Who owns those .git folder and the files in that folder? I’m willing to bet it will not show you Mac account and instead show a number or some other user that happens to have the same UID as the openhab user on your remote machine.

I’m just guessing this is what’s happening given the information available.

First - thank you very much for your support. That sounds reasonable.
When I look on my Mac it shows the files show as

drwx------ 1 markus staff 16K May 15 11:28 .git

On the openhabian rpi4 the git was created using root

drwxr-xr-x   3 openhab    openhab 4.0K 26. Dec 2021  automation/
drwxrwxr-x   6 root       root    4.0K 15. May 11:28 .git/

as I used the root user login for the SMB share. It didn’t work when using openhabian to access the SMB share either. Only these two users have access to the SMB share.