Update Exception

Hi to all users,

I recently have an issue with the update button, where I have a message about an exception coming from overwriting rights on a server location

I tried to delete a folder from windows explorer and reinstall an extension from pyRevit Extensions window and that worked, so I have writing rights on the server location, so is there any recent changes in lateste versions of pyRevit ?

I tried with 4.8.15 and 4.8.17 WIP and it didn’t work, I also check with a colleague that has pyRevit 4.8.14 and It worked well for her to update packages (at least no error message)

IronPython Traceback:
Traceback (most recent call last):
 File "C:\Program Files\pyRevit-Master\extensions\pyRevitCore.extension\pyRevit.tab\pyRevit.panel\Update.smartbutton\script.py", line 32, in <module>
 File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\versionmgr\updater.py", line 218, in update_pyrevit
 File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\versionmgr\updater.py", line 72, in get_thirdparty_ext_repos
 File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\coreutils\git.py", line 155, in get_repo
Exception: repository path '*REPLACED PATH*' is not owned by current user

Script Executor Traceback:
LibGit2Sharp.LibGit2SharpException: repository path '*REPLACED PATH*' is not owned by current user
 à Microsoft.Scripting.Interpreter.NewInstruction.Run(InterpretedFrame frame)
 à Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
 à Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
 à get_repo$3994(Closure , PythonFunction , Object )
 à get_thirdparty_ext_repos$4017(Closure , PythonFunction )
 à update_pyrevit$4009(Closure , PythonFunction )
 à System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
 à Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
 à Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
 à Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
 à IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
 à PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)

this is caused by installing the repo as admin (because script is elevated).

For users with git installed you can run this in terminal
git config --global --add safe.directory *

if users do not have git installed, I run this function in my install powershell script.

function Set-Permissions {
    try {
        $username = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
        if ([string]::IsNullOrWhiteSpace($username)) {
            Write-Error "Failed to obtain the username."
            exit
        }
        $folderPaths = @("your_extension_path", "your_extension_path\.git")
        $newOwner = New-Object System.Security.Principal.NTAccount($username)
        function Set-OwnerRecursively {
            param (
                [String]$path,
                [System.Security.Principal.NTAccount]$owner
            )
            $acl = Get-Acl $path
            $acl.SetOwner($owner)
            Set-Acl -Path $path -AclObject $acl

            Get-ChildItem -Path $path -Recurse -Directory | ForEach-Object {
                Set-OwnerRecursively -path $_.FullName -owner $owner
            }
        }
        foreach ($folderPath in $folderPaths) {
            Set-OwnerRecursively -path $folderPath -owner $newOwner
        }
    }
    catch {
        Write-Error $_.Exception.Message
    }
}

reference:
https://github.blog/2022-04-12-git-security-vulnerability-announced/
and
https://git-scm.com/docs/git-config/2.35.2#Documentation/git-config.txt-safedirectory

edit: just noticed you mention “server location”. Is this a shared folder that all users point to for the ribbon? the powershell function will not work for this, but the first should. we clone our ribbon onto users C drive, so the function is just setting the folder ACL permissions to that users own account.

Yes, all the users have the same “extension folder” on a server, this way, I manage to make updates for everyone in the office…

It seems that this worked :
git config --global --add safe.directory *

Even if the command didn’t send back any infos

Thank you, I’m going to investigate how could I change the extension folder’sharing another way, without make it too difficult for me to maintain our own tools

This issue is caused by a recent (2022) git change. Basically git won’t work with a repo that you do not own, and if its a shared repo accessed by multiple people, then anybody other than the person that cloned that repo will not be able to access it unless you add to the safe.directory using that command. downside is it requires git to be installed.

our extension is git pull’d onto each users local C drive each time Revit is fired up or update button is pushed. could easily use that server extension as a local git repo that each user pulls to their own computer. then you can use that powershell command once and be fine after that. Allows you to use the ribbon even if not connected to network or VPN. It wouldn’t update until VPN connected, but would still be useable.

1 Like