-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pode imports modules fail if modules use RequiredModules dependency (Pode.Web) #1046
Comments
The commits above should fix the module loading order for modules that use RequiredModules. For the loading of Pode when it's saved to non-PSModulePath directory, this was more interesting. Pode is actually loaded as the very first module in the runspaces, but it's done so via When Pode starts importing the other module's into it's runspaces, Pode.Web will then force re-import the Pode module if it's found at one of the paths from PSModulePath (as you found). What I've done is to check if the Pode module being used is not from one of the PSModulePaths, and if the "version" is "0.0". If this is the case, a second forced import is done before all other modules for Pode, to import the correct psd1 so the version matches. It's not eloquent by any means 😂 and should only affect anyone loading Pode from a non-PSModulePath location. I did try dynamically updating PSModulePath but for some reason it just didn't want to work for me - it kept failing on "cannot find version". The way implemented is arguably a little better, as it will import the module from the originally specified location, and not the first path in PSModulePath that has a Pode module in it. |
It works with psd1 https://github.com/ili101/Pode/commits/Issue-1046 |
Interesting, when I tried I got an "invalid file error" rather than a "function not found". I'll try again later, must've been doing something stupid. If it loads psd1 files then, I wonder if we could have a second |
Hi @ili101, I tried again and loading via psd1 worked! I must've been doing something daft before. I tried with a second What I've done in the above commit is add the new |
Pode by default loads all modules automatically. If modules psd1 files are using RequiredModules, and the modules loaded in the session are not in the PSModulePath, depending on the "random" load order they may fail with error:
Unlike 2 external modules that will error depending on the import order, in particular Pode.Web\0.8.2 errors consistently in this situation (as Pode itself is excluded from the auto import or imported last?).
Steps To Reproduce
Platform
The text was updated successfully, but these errors were encountered: