pyrevitlabs/pyRevit

[Bug]: pyRevit crashes when Autodesk Forma addins are installed

rbt-w opened this issue · 12 comments

✈ Pre-Flight checks

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

🐞 Describe the bug

Encounter an error when attempting to load pyrevit and Autodesk Forma addins on the same machine. Uninstalling Forma allows pyRevit to open cleanly. Installing pyRevit first and Forma second allows Revit to open correctly, however, only for the first user to do so. if another user opens Revit on the same machine the error occurs and pyRevit no longer functions until both pyRevit and Forma are uninstalled, and pyRevit is reinstalled over the top.

⌨ Error/Debug Message

IronPython Traceback:
Traceback (most recent call last):
File "C:\Program Files\pyRevit-Master\bin\engines\pyRevitLoader.py", line 30, in <module>
File "C:\Program Files\py Revit-Master\pyrevitlib\pyrevitVoader\sessionmgr.py",line24, in <module»
File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\loader\sessioninfo.py", line 14, in «module>
File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\runtime\_init_py",line 502, in «module»
File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\runtimel_init_py",line344,in_get_runtime_asm
File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\runtime\_init_py",line295,in_generate_runtime_asm
AttributeError: Method not found: 'System.Collections.Immutable.ImmutableArray'1 <Byte»
System.Reflection.Metadata.MetadataReader.GetBlobContent(System.Reflection.Metadata.BlobHandle)'.
Script Executor Traceback:
System.MissinqMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray'1 <Byte»
System.Reflection.Metadata.MetadataReader.GetBlobContent(System.Reflection.Metadata.BlobHandle)'.
at Microsoft.Scripting.Runtime.LightExceptions.ThrowException(LightException lightEx)
at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value)
at Microsoft.Scripting.Interpreter.FuncCallinstruction'2.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter. Handle Exception (InterpretedFrame frame, Exception exception) at Microsoft.Scripting.Interpreter.Interpreter. Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run 1 [TO, TRet](TO argO) at IronPython.Compiler.Ast.CallExpression.InvokeOlnstruction.Run(InterpretedFrameframe) at Microsoft.Scripting.Interpreter.Interpreter. Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter. LightLambda.Run 1 [TO, TRet](TO argO) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[TO, T1,TRet](CallSite site, TO arg0, T1 arg1) at IronPython.Compiler.Ast.CallExpression.InvokeOlnstruction.Run(InterpretedFrameframe) at Microsoft.Scripting.Interoreter.Interpreter. Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run 1 [TO,TRet] (TO argO) at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options) at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path) at IronPython.Runtime.Importer.LoadFrom Disk(CodeContext context, String name, String fullName, String str) at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func'5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path) at IronPython.Runtime.Importer.ImportNestedModule(CodeContext context, PythonModule module, String( parts, Int32 current, List path) at IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object from, String name)
at IronPython.Modules.Builtin._import_(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level) at Microsoft Scriptina.Interpreter. FuncCallinstruction'5.Run(InteroretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter. Run(InterpretedFrame frame) at Microsoft.Scriptinq.Interpreter. LightLambda.Run1 [TO,TRet] (TO argO) at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options) at IronPython.Runtime.Importer. LoadModuleFromSource(CodeContext context, String name, String path) at IronPython.Runtime.Importer. LoadFromDisk(CodeContext context, String name, String fullName, String str) at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func'5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path) at Iron Pvthon. Runtime.Importer.ImportNestedModule(CodeContext context. PvthonModule module. Stringll parts, Int32 current. List path)

at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options) at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path) at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str) at IronPython.Runtime.Importer.ImportFromPathHookCodeContext context, String name, String fullName, List path, Func'5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path) at IronPython.Runtime.Importer.ImportNestedModule(CodeContext context, PythonModule module, String i] parts, Int32 current, List path) at IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object from, String name)
at IronPython.Modules.Builtin._import_(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at IronPython.Runtime.Importer.ImportLightThrow(CodeContextcontext, String fullName, PythonTuple from, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallinstruction'5.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter. Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run1 [TO,TRet](TO arg0) at Iron Python.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at Iron Python.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options) at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path) at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str) at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func'5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path) at IronPython.Runtime.Importer.ImportNestedModule(CodeContext context, PythonModule module, String i] parts, Int32 current, List path) at IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object from, String name)
at IronPython.Modules.Builtin._import_(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallinstruction'5.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run1 [TO, TRet](TO argO) at IronPython.Compiler.RuntimeScriptCode.Invoke Target(Scope scope)
at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options) at Iron Python.Runtime.Importer. LoadModuleFromSource(CodeContext context, String name, String path) at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str) at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func'5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path) at Iron Python.Runtime.Importer.ImportNestedModule(CodeContext context, PythonModule module, String[I parts, Int32 current, List path) at IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object from, String name)
at IronPython.Modules.Builtin._import_(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallinstruction 7.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run7 [TO,T1,T2,T3,T4,T5,T6,TRet] (TO arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallinstruction'5.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[TO,T1,TRet](TO arg0, T1 arg1) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContextctx) at Microsoft.Scripting.Hosting.ScriptSource. Execute(ScriptScope scope)
at PyRevitLoader.ScriptExecutor. ExecuteScript(String sourcePath, IEnumerable'1 sysPaths, String logFilePath, IDictionary'2 variables)

♻️ To Reproduce

  1. Install Revit 23/24
  2. Install Autodesk Forma
  3. Install pyRevit
  4. Open Revit (pyRevit crashes when attempting to open)

⏲️ Expected behavior

pyRevit and Autodesk Forma addins should be able to be loaded together.

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

==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
master | Deploy: "basepublic" | Branch: "master" | Version: "4.8.15.24089+0912" | Path: "C:\Program Files\pyRevit-Master"
==> Attachments
master | Product: "24.2" | Engine: DEFAULT (2711) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "23.1.3" | Engine: DEFAULT (2711) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "Autodesk Revit 2021" | Engine: DEFAULT (2711) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
==> Installed Extensions
==> Default Extension Search Path
C:\Users\robert.willis\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
==> Extension Sources - Default
https://github.com/eirannejad/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
==> Installed Revits
24.2 | Version: 24.2.0.63 | Build: 20231029_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2024\"
23.1.3 | Version: 23.1.30.97 | Build: 20230828_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2023\"
Autodesk Revit 2021 | Version: 21.1.21.45 | Build: 20201116_1100(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021\"
==> Running Revit Instances
PID: 16092 | 23.1.3 | Version: 23.1.30.97 | Build: 20230828_1515(x64) | Language: 0 | Path: "C:\Program Files\Autodesk\Revit 2023"
==> User Environment
Microsoft Windows 10 [Version 10.0.22631]
Executing User: *domain*\*user*
Active User:
Admin Access: No
%APPDATA%: "C:\Users\*user*\AppData\Roaming"
Latest Installed .Net Framework: 4.8
No .Net Target Packs are installed.
No .Ne-Core Target Packs are installed.
pyRevit CLI v4.8.15.24089+0912.f079f5fd51756b988a06d005d4f4cd2961f36e63

Additional context

This is on a VDI session on a Windows 11 23H2 machine. While there is a potential workaround of installing pyRevit first and then Forma later this only works for the user that installed the apps. Anyone else who joins the machine still encounters the error. Once the error has occurred there is no way to remediate the existing pyRevit install - you need to fully uninstall pyRevit and Forma and then reinstall pyRevit to restore functionality.

Thanks for reporting.
Could you try renaming the pyrevit.addin file to something like 0_pyrevit.addin ?
and try again the 1st person logged, then the second one.
Sub optimal, I know, but usually fixes this kind of loading sequence issue

Thanks - this works. Also noted that a few other addins are named with prepended underscores at install time likely for the same reason. We will make sure pyRevit is read in alphabetically first in our deployments moving forward.

Thanks - this works. Also noted that a few other addins are named with prepended underscores at install time likely for the same reason. We will make sure pyRevit is read in alphabetically first in our deployments moving forward.

@rbt-w, @jmcouffin we are experiencing the same issue. How are you renaming the addin file? We are using the pyRevit for Teams CLI installer for deployments. Can the CLI do this? Or in PowerShell?

Also, after renaming the addin file manually, we are getting the error dynamically compiling pyRevit runtime, similar to #1948. We do not have the IT resources in our organization to perform suggested fixes on all machines, and users do not have rights to perform them either. Would you advice to use a lower version of pyRevit, untill these compilation errors are fixed?

PowerShell

That's what I would do.

Would you advice to use a lower version of pyRevit, untill these compilation errors are fixed?

It is not so much a question of version of pyrevit. But rather a question of loading sequence of DLLs, Dll hell and shared dependencies.

So, IMHO, no, I don't think this would help. And the latest wip versions got lots of fixes you may need like the infamous LoadComponent error fixed from the rpw module.

Will these compilation errors be ever fixed? Well, maybe, but that requires loads of work: with solution like implementing ALC, or strong named assemblies for all dependencies, ...

But I may be wrong on some of these points.

@sanzoghenzo care to pitch in with your thoughts on this?

It is not so much a question of version of pyrevit. But rather a question of loading sequence of DLLs, Dll hell and shared dependencies.

Thanks @jmcouffin. I cloned 4.8.15 this morning and have had both above error from this post and the error dynamically compiling pyRevit runtime, while last couple months I had no issues with 4.8.13.

I am trying to test 4.8.13 or 4.8.14 again, but I can't seem to get clone from archive working. Any idea?
I tried both the Notion guide & this suggestion:

pyrevit clone dev --dest="C:\ProgramData\pyRevit" --image="\\global\systems\Software\PyRevit Config\Releases\pyRevit-4.8.13.23182-2215.zip" --debug

gives the following error:

Debug: Staging package to "C:\Users\GUUS~1.GOO\AppData\Local\Temp\pyRevit-4.8.13.23182-2215"
Error: Error unpacking "\\global\systems\Software\PyRevit Config\Releases\pyRevit-4.8.13.23182-2215.zip" | Could not find a part of the path 'C:\Users\Guus.Gooskens\AppData\Local\Temp\pyRevit-4.8.13.23182-2215\pyRevit-4.8.13.23182-2215\extensions\pyRevitTools.extension\pyRevit.tab\Analysis.panel\Tools.stack\Inspect.pulldown\ListElementsOfSelectedLevel.pushbutton\ListElementsOfSelectedLevel_script.py'. (pyRevitLabs.Common.PyRevitException)
   at pyRevitLabs.PyRevit.PyRevitClones.DeployFromImage(String cloneName, String deploymentName, String branchName, String imagePath, String destPath)
   at pyRevitCLI.PyRevitCLI.ProcessArguments()
   at pyRevitCLI.PyRevitCLI.Main(String[] args)

@sanzoghenzo care to pitch in with your thoughts on this?

Not much more to say, except that we can try something I proposed on the forum but went under the radar: using ILRepack to package our assemblies and the dependencies in a single dll, so that we are self contained (except for the revit api, of course).

I still have to test it, the prerequisite is to have all the code precompiled, so it is something we can do only with pyRevit 5.

Not much more to say, except that we can try something I proposed on the forum but went under the radar: using ILRepack to package our assemblies and the dependencies in a single dll, so that we are self contained (except for the revit api, of course).

@sanzoghenzo link seems broken, can you please share again?

link seems broken

it is not, I just tried it @guusgooskens

Ok thanks for checking @jmcouffin. Could it be private?
image

Ok thanks for checking @jmcouffin. Could it be private?

It was, good catch. fixed
In the contributors section.
@guusgooskens care to 'become' a contributor?

@jmcouffin sure thing! Happy to help where I can.