pyRevit icon indicating copy to clipboard operation
pyRevit copied to clipboard

[Bug]: CLI, Path does not point to a valid clone

Open jmcouffin opened this issue 11 months ago • 19 comments

✈ Pre-Flight checks

  • [x] I don't have SentinelOne antivirus installed (see above for the solution)
  • [x] I have searched in the issues (open and closed) but couldn't find a similar issue
  • [x] I have searched in the pyRevit Forum for similar issues
  • [x] I already followed the installation troubleshooting guide thoroughly
  • [x] I am using the latest pyRevit Version

🐞 Describe the bug

local dev environment with latest WIP CLI installed I tried to add my local clone @sanzoghenzo your expertise here 👀

⌨ Error/Debug Message

PS C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi> pyrevit clones add dev "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" --debug
<clone_name> = dev
clones = True
add = True
<clone_path> = C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi
Debug: Checking for all: wiki 
Debug: Missing: wiki 
Debug: Checking for all: blog 
Debug: Missing: blog 
Debug: Checking for all: docs 
Debug: Missing: docs 
Debug: Checking for all: source 
Debug: Missing: source 
Debug: Checking for all: youtube 
Debug: Missing: youtube 
Debug: Checking for all: support 
Debug: Missing: support 
Debug: Checking for all: env 
Debug: Missing: env 
Debug: Checking for all: update 
Debug: Missing: update 
Debug: Checking for all: clone 
Debug: Missing: clone 
Debug: Checking for all: clones 
Debug: Checking for all: info 
Debug: Missing: info 
Debug: Checking for all: open 
Debug: Missing: open 
Debug: Checking for all: add 
Debug: Checking for all: this 
Debug: Missing: this 
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" 
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" 
Debug: Registering clone "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" 
Debug: Searching for valid clones above: C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi 
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" 
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" 
Debug: Checking pyRevit clone validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" 
Debug: Checking clone validity by directory structure... 
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib" 
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib" 
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit" 
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit" 
Debug: Checking pyRevit path "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit" 
Debug: Clone directory structure is valid. 
Debug: Checking clone validity by git repo... 
Debug: Verifying repo validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" 
Debug: Invalid pyRevit clone. | The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. 
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev"
Debug: Checking pyRevit clone validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev"
Debug: Checking clone validity by directory structure...
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\pyrevitlib"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\pyrevitlib"
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\pyrevitlib\pyrevit"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\Users\Local Admin\Documents\GitHub\pyr-dev\pyrevitlib\pyrevit"
Debug: Invalid pyRevit clone. | Path "C:\Users\Local Admin\Documents\GitHub\pyr-dev" is not a valid git pyRevit clone.
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub"
Debug: Checking pyRevit clone validity "C:\Users\Local Admin\Documents\GitHub"
Debug: Checking clone validity by directory structure...
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyrevitlib"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyrevitlib"
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyrevitlib\pyrevit"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\Users\Local Admin\Documents\GitHub\pyrevitlib\pyrevit"
Debug: Invalid pyRevit clone. | Path "C:\Users\Local Admin\Documents\GitHub" is not a valid git pyRevit clone.       
Debug: Normalizing "C:\Users\Local Admin\Documents"
Debug: Normalized as "C:\Users\Local Admin\Documents"
Debug: Checking pyRevit clone validity "C:\Users\Local Admin\Documents"
Debug: Checking clone validity by directory structure...
Debug: Normalizing "C:\Users\Local Admin\Documents\pyrevitlib"
Debug: Normalized as "C:\Users\Local Admin\Documents\pyrevitlib"
Debug: Normalizing "C:\Users\Local Admin\Documents\pyrevitlib\pyrevit"
Debug: Normalized as "C:\Users\Local Admin\Documents\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\Users\Local Admin\Documents\pyrevitlib\pyrevit"
Debug: Invalid pyRevit clone. | Path "C:\Users\Local Admin\Documents" is not a valid git pyRevit clone.
Debug: Normalizing "C:\Users\Local Admin"
Debug: Normalized as "C:\Users\Local Admin"
Debug: Checking pyRevit clone validity "C:\Users\Local Admin"
Debug: Checking clone validity by directory structure...
Debug: Normalizing "C:\Users\Local Admin\pyrevitlib"
Debug: Normalized as "C:\Users\Local Admin\pyrevitlib"
Debug: Normalizing "C:\Users\Local Admin\pyrevitlib\pyrevit"
Debug: Normalized as "C:\Users\Local Admin\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\Users\Local Admin\pyrevitlib\pyrevit"
Debug: Invalid pyRevit clone. | Path "C:\Users\Local Admin" is not a valid git pyRevit clone.
Debug: Normalizing "C:\Users"
Debug: Normalized as "C:\Users"
Debug: Checking pyRevit clone validity "C:\Users"
Debug: Checking clone validity by directory structure... 
Debug: Normalizing "C:\Users\pyrevitlib"
Debug: Normalized as "C:\Users\pyrevitlib"
Debug: Normalizing "C:\Users\pyrevitlib\pyrevit"
Debug: Normalized as "C:\Users\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\Users\pyrevitlib\pyrevit"
Debug: Invalid pyRevit clone. | Path "C:\Users" is not a valid git pyRevit clone.
Debug: Normalizing "C:\"
Debug: Normalized as "C:"
Debug: Checking pyRevit clone validity "C:"
Debug: Checking clone validity by directory structure...
Debug: Normalizing "C:\pyrevitlib"
Debug: Normalized as "C:\pyrevitlib"
Debug: Normalizing "C:\pyrevitlib\pyrevit"
Debug: Normalized as "C:\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\pyrevitlib\pyrevit"
Debug: Invalid pyRevit clone. | Path "C:" is not a valid git pyRevit clone.
Error: Path does not point to a valid clone "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" (pyRevitLabs.Common.PyRevitException)
   at pyRevitLabs.PyRevit.PyRevitClone..ctor(String clonePath, String name)
   at pyRevitLabs.PyRevit.PyRevitClones.RegisterClone(String cloneName, String repoPath, Boolean forceUpdate)        
   at pyRevitCLI.PyRevitCLICloneCmds.RegisterClone(String cloneName, String clonePath, Boolean force)
   at pyRevitCLI.PyRevitCLI.ProcessArguments()
   at pyRevitCLI.PyRevitCLI.Main(String[] args)
PS C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi>

♻️ To Reproduce

git clone, cd in folder run pyrevit clones add dev "C:\..."

⏲️ Expected behavior

clone created in pyrevit-config.ini

🖥️ Hardware and Software Setup (please complete the following information)

-

Additional context

No response

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

  • removed the %appdata%/pyrevit folder
  • uninstalled WIP CLI
  • installed WIP CLI

C:\Users\Local Admin>pyrevit env --debug env = True Debug: Checking for all: wiki Debug: Missing: wiki Debug: Checking for all: blog Debug: Missing: blog Debug: Checking for all: docs Debug: Missing: docs Debug: Checking for all: source Debug: Missing: source Debug: Checking for all: youtube Debug: Missing: youtube Debug: Checking for all: support Debug: Missing: support Debug: Checking for all: env ==> Registered Clones (full git repos) Debug: Seeding config file "C:\ProgramData\pyRevit\pyRevit_config.ini" to "C:\Users\Local Admin\AppData\Roaming\pyRevit\pyRevit_config.ini" Error: Failed configuring config file from template at C:\ProgramData\pyRevit\pyRevit_config.ini | Could not find a part of the path 'C:\Users\Local Admin\AppData\Roaming\pyRevit\pyRevit_config.ini'. (pyRevitLabs.Common.PyRevitException) at pyRevitLabs.PyRevit.PyRevitConfigs.SetupConfig(String templateConfigFilePath) at pyRevitLabs.PyRevit.PyRevitConfigs.GetConfigFile() at pyRevitLabs.PyRevit.PyRevitClones.GetRegisteredClones() at pyRevitCLI.PyRevitCLICloneCmds.PrintClones() at pyRevitCLI.PyRevitCLIAppCmds.MakeEnvReport(Boolean json) at pyRevitCLI.PyRevitCLI.ProcessArguments() at pyRevitCLI.PyRevitCLI.Main(String[] args)

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

The seed file in %programdata%/pyrevit/pyrevit-config.ini contains this after first run:

[environment]
clones = {"master":"C:\\Users\\Jean-MarcCouffin\\AppData\\Roaming\\pyRevit-Master"}

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

  • It did not manage to create the pyrevit-config file and pyrevit-master folder in appdata
  • I am admin on my computer

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

all of the above with pyRevit_CLI_5.0.0.25031_signed.exe

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

Debug: Verifying repo validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" Debug: Invalid pyRevit clone. | The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

Aaaannndddd... we're back to square one :sweat: https://github.com/pyrevitlabs/pyRevit/pull/2384#issuecomment-2340964968

For the configuration file, from what I see it is a totally separate issue. Could it be that the seed file in ProgramData (not AppData) was already there?

sanzoghenzo avatar Feb 01 '25 11:02 sanzoghenzo

using the admin installer, pyrevit env works clones add dev does not

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

note: initial cloning for my local dev was initiated through github desktop

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

the msi installer works better:

  • pyrevit env OK
  • pyrevit clones add dev "C:\ ..." OK
  • pyrevit env again:
C:\Users\Local Admin>pyrevit env
==> Registered Clones (full git repos)
Error: Error reading deployment arguments from "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" | Could not find file 'C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\.pyrevitargs'.
Run with "--debug" option to see debug messages
C:\Users\Local Admin>pyrevit env --debug
env = True
Debug: Checking for all: wiki
Debug: Missing: wiki
Debug: Checking for all: blog
Debug: Missing: blog
Debug: Checking for all: docs
Debug: Missing: docs
Debug: Checking for all: source
Debug: Missing: source
Debug: Checking for all: youtube
Debug: Missing: youtube
Debug: Checking for all: support
Debug: Missing: support
Debug: Checking for all: env
==> Registered Clones (full git repos)
Debug: Try getting config as dict "environment:clones"
Debug: Try getting config "environment:clones"
Debug: Config "environment:clones" = "{"dev":"C:\\Users\\Local Admin\\Documents\\GitHub\\pyr-dev\\dev-samedi"}"
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Searching for valid clones above: C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Checking pyRevit clone validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Checking clone validity by directory structure...
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib"
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit"
Debug: Clone directory structure is valid.
Debug: Checking clone validity by git repo...
Debug: Verifying repo validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Valid pyRevit clone "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Valid clone found at: C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Checking pyRevit clone validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Checking clone validity by directory structure...
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib"
Debug: Normalizing "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit"
Debug: Normalized as "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit"
Debug: Checking pyRevit path "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\pyrevitlib\pyrevit"
Debug: Clone directory structure is valid.
Debug: Checking clone validity by git repo...
Debug: Verifying repo validity "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Valid pyRevit clone "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Verified clone "dev=C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi"
Debug: Reading image clone parmeters from "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\.pyrevitargs"
Error: Error reading deployment arguments from "C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi" | Could not find file 'C:\Users\Local Admin\Documents\GitHub\pyr-dev\dev-samedi\.pyrevitargs'. (pyRevitLabs.Common.PyRevitException)
   at pyRevitLabs.PyRevit.PyRevitClone.ReadDeploymentArgs(String clonePath)
   at pyRevitLabs.PyRevit.PyRevitClone.GetCurrentDeployment(String clonePath)
   at pyRevitLabs.PyRevit.PyRevitClone.get_Deployment()
   at pyRevitLabs.PyRevit.PyRevitClone.ToString()
   at System.IO.TextWriter.WriteLine(Object value)
   at System.IO.TextWriter.SyncTextWriter.WriteLine(Object value)
   at System.Console.WriteLine(Object value)
   at Colorful.Console.WriteLine(Object value)
   at pyRevitCLI.PyRevitCLICloneCmds.PrintClones()
   at pyRevitCLI.PyRevitCLIAppCmds.MakeEnvReport(Boolean json)
   at pyRevitCLI.PyRevitCLI.ProcessArguments()
   at pyRevitCLI.PyRevitCLI.Main(String[] args)

which makes sense as I did not run the build commands and args copy yet

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

after build commands, everything looks fine.

  • Should be toss .exe for the CLI 🤣 ?
  • I will push back the compiled dlls to the develop branch eventually, so that the clone commands work again.

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

And I just wanted to test the IPY342 PR...

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

running revit after build:

Image in 2025 ☝ while in 2024... all good

I know what to do...

  • clone repo
  • rebuild...

Never getting tired of this...

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

We definitely need to reevaluate the Installers / CLI / workflows for dev... This is so messy...

jmcouffin avatar Feb 01 '25 11:02 jmcouffin

I know what to do...

  • clone repo
  • rebuild...

and after re cloning, rebuilding, re everything all was well. (using the CLI msi... ) The exe is still broken

jmcouffin avatar Feb 01 '25 12:02 jmcouffin

I'm lost, too much information in so many different tries 😅 From what I understand:

  • the first error is probably due to a missing libgit2sharp dll in the CLI installer, even though this was taken care by this commit

  • I don't know what's the expected behavior of pyrevit env if there is no clone specified beforehand, but I believe it is doing too much - why does it seeds the configuration file? it should only report the current situation...

  • .pyrevitargs.... I still don't understand what it is/what's the scope. But as of now this is expected, a clone should have its own .pyrevitargs file

  • I'm in favor of keeping only the MSI for the CLI installer (and then have a single installer for everything as per #2519 )

  • I will push back the compiled dlls to the develop branch eventually, so that the clone commands work again.

    you already know how I feel about this, but go ahead if you want 😉

  • We definitely need to reevaluate the Installers / CLI / workflows for dev... This is so messy... dotnet development is mostly messy 🤣

    With a normal Revit plugin you usually manually create an .addin file that points to the dll in the msbuild/dotnet build output folder, and run revit from inside visual studio, so you don't have to mess at all with the installed version. We could achieve this after the porting... if it will ever happen 😅

sanzoghenzo avatar Feb 01 '25 15:02 sanzoghenzo

  • I will push back the compiled dlls to the develop branch eventually, so that the clone commands work again.

You overdid it 🤣

  • No need to add the dlls of dev/libs, they are copied to the bin folder
  • There are many unneeded dlls in the various subfolders Image Image and so on...

The problem is that we have a ton of binay blobs in the git history, in fact my local .git folder is 1.90GB in size!!! This translates in slow download times when cloning either via git or pyrevit clone...

sanzoghenzo avatar Feb 09 '25 08:02 sanzoghenzo

  • There are many unneeded dlls in the various subfolders

Have I missed something? @sanzoghenzo https://github.com/pyrevitlabs/pyRevit/commit/d500f24bbe3f0121f9da6249feaaa1ad5e6d5fc6

jmcouffin avatar Feb 11 '25 10:02 jmcouffin

The right person to ask is @dosymep

However it doesn't matter, these files are already in the git history, removing them now doesn't affect the size of the .git folder :worried:

sanzoghenzo avatar Feb 11 '25 11:02 sanzoghenzo

@jmcouffin @sanzoghenzo I think I spot the issue.

Current pyRevit CLI 5.0.1.25051 adds LibGit2Sharp during the build, but does not add native libgit2 library that it depends on. Calling any of LibGit2Sharp methods throws an exception in LibGit2Sharp.Core.NativeMethods. If pyrevit cli could show the error it would look something like this:

System.DllNotFoundException: Unable to load DLL 'git2-3f4182d' or one of its dependencies: The specified module could not be found. (0x8007007E)

The number after 'git2-<...>' depends on LibGit2Sharp version. I used 0.31 for testing and it was 3f4182d. Looking at pyRevit CLI\bin folder I could not find it there. By simply copying git2-3f4182d.dll I solved the issue and cloning works again.

I don't know how to fix the build, but hope it gives you some hint. Also refer to this topic: https://stackoverflow.com/a/59929513/25081696

Thanks @dosymep for help.

nodatasheet avatar Mar 09 '25 10:03 nodatasheet

@jmcouffin @sanzoghenzo I think I spot the issue.

Current pyRevit CLI 5.0.1.25051 adds LibGit2Sharp during the build, but does not add native libgit2 library that it depends on. Calling any of LibGit2Sharp methods throws an exception in LibGit2Sharp.Core.NativeMethods. If pyrevit cli could show the error it would look something like this:

System.DllNotFoundException: Unable to load DLL 'git2-3f4182d' or one of its dependencies: The specified module could not be found. (0x8007007E)

The number after 'git2-<...>' depends on LibGit2Sharp version. I used 0.31 for testing and it was 3f4182d. Looking at pyRevit CLI\bin folder I could not find it there. By simply copying git2-3f4182d.dll I solved the issue and cloning works again.

I don't know how to fix the build, but hope it gives you some hint. Also refer to this topic: https://stackoverflow.com/a/59929513/25081696

Thanks @dosymep for help.

Sorry for not being clearer, but this is exactly what we already found back then and solved for pyrevit, that's what I mentioned here:

  • the first error is probably due to a missing libgit2sharp dll in the CLI installer, even though this was taken care by this commit

I thought that the fix was enough for both pyrevit and the CLI, but clearly we missed something... @dosymep can you please take a look a this?

sanzoghenzo avatar Mar 09 '25 10:03 sanzoghenzo