NuGet failed to install

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: NuGet failed to install

Post by brittneyr »

Based off of the issues running commands in console, I believe the issues are related to the PackageManagement and PowerShellGet modules on your machine. ModuleManager uses these as well. This could all be related to OneDrive, but I cannot confirm.

Are you able to import the PowerShellGet or PackageManagement module in a PowerShell console?
Brittney
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: NuGet failed to install

Post by Alexander Riedel »

I am going to jump in here saying something that might be unpopular :D
OneDrive is one of the first things I disable on a new machine, because is seems to never work. That is just my experience and opinion, so YMMV.
I would try to turn it off and see what happens.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
SynacorSID
Posts: 9
Last visit: Thu Jan 05, 2023 9:23 am
Has voted: 1 time

Re: NuGet failed to install

Post by SynacorSID »

Your unpopular opinion is well appreciated. Unfortunately it is a corporate solution. If it is onedrive causing this problem that could be problematic. It's Onedrive for business and part of our M365 E3 license. It's a good thought. I'll try it.
User avatar
SynacorSID
Posts: 9
Last visit: Thu Jan 05, 2023 9:23 am
Has voted: 1 time

Re: NuGet failed to install

Post by SynacorSID »

Removing Onedrive didn't help at all. It's status quo. I'm confused as to what's going on and it's making me angry. I did not have any of these problems in 2020. NONE ... out of no where nuget gets involved and messes up my job.

I tried manually registering the repository.
2021-06-11_15-23-12.png
2021-06-11_15-23-12.png (31.31 KiB) Viewed 14023 times

This image encapsulates my anger right now.
2021-06-11_16-14-45.png
2021-06-11_16-14-45.png (206.96 KiB) Viewed 14023 times
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: NuGet failed to install

Post by brittneyr »

I don't believe the fault lies directly with NuGet or ModuleManager. The issue appears to be with the PowerShellGet and PackageManagement module and when ModuleManager attempts to load/import those modules, it is failing.

This problem could be an issue with your environmental variable PSModulePath.
Just to verify, can you confirm the paths by following these steps:
Go to System Properties (Windows Key + Pause Break) >> Click on Advanced System Settings >> Click on Environment Variables
Pick "PSModulePath" and click on "Edit" button:
EditEnviromentalVariable.png
EditEnviromentalVariable.png (20.01 KiB) Viewed 14021 times
If any changes are made, please restart ModuleManager and the PowerShell console.
Brittney
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: NuGet failed to install

Post by Alexander Riedel »

I have been going over this post again from the beginning. Please note that this is all just guesswork on our part because obviously we cannot access your machine. So, I hope any of the following helps and is not adding to your frustration.
Generally 99% of all "this does not work" problems boil down to permissions, or better, lack thereof.
Here are some observations, please correct them if I am wrong somewhere.
Your personal documents folder is redirected to a OneDrive folder. "C:\Users\<name>\OneDrive\Documents"
When you install Nuget, you install it your personal folder: C:\Users\<name>\OneDrive - <company name>\Documents\WindowsPowerShell\Modules

Now, from here on out it all depends on how your user is configured. Module Manager needs to run elevated. It prompts you for elevation when you start it.
If you are an admin user and you just elevate, all should be fine. But I suspect you are not an admin. You run with a 'regular' user id and if you start an elevated process you need to log in with an admin id and password. In that case, this: "C:\Users\<name>\OneDrive\Documents" does not exist or points to a completely different folder, since you are now logged on as a different user for that process.
That would explain the error message you see about the missing modules. They do actually not exists in the scope of your admin user id.
You can add that path to your PSModulePath until you get green around the gills, it won't help, because
C:\Users\WhatsHerFace\OneDrive - FancyCorp\Documents\WindowsPowerShell\Modules
simply does not exist or is not accessible for a user "Snoppy" and
C:\Users\Snoopy\OneDrive - FancyCorp\Documents\WindowsPowerShell\Modules
has different modules (or none at all).

The PackageManagement and PowerShellGet modules are typically installed for ALL users under C:\Program Files\WindowsPowerShell\Modules because in that location they are available for ALL users, elevated or not, regardless of where your personal folders are.

Obviously I do not know if you have them installed there as well or not, but I would suspect not, or you have outdated versions.
As a general rule (at least for me) PowerShell modules should NEVER be installed in a personal documents folder, unless you really 100% only use it from that particular user id.
If you do that, you may have to install any given module again and again for each individual user id on a machine. That can get silly fast, so I always recommend to install modules for ALL users.

I hope, maybe, this points you in the right direction.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
SynacorSID
Posts: 9
Last visit: Thu Jan 05, 2023 9:23 am
Has voted: 1 time

Re: NuGet failed to install

Post by SynacorSID »

Thanks guys! I really appreciate your help. It lead me to this solution.

I added C:\Program Files\WindowsPowerShell\Modules\PackageManagement in the PSModule environmental path. This path already existed "C:\Program Files\WindowsPowerShell\Modules". Powershell wasn't seeing PackageManagement for whatever reason. After adding a direct path it started working. Was able to do all the steps you guys mentioned which allowed me to fix it. Powershell then let me delete all the mentions to "C:\Users\<name>\OneDrive - <company name>\Documents\WindowsPowerShell\Modules". Before it would give me an error and not let me delete it. After deleting all the modules pointing to that path things started working. Running sfc /scannow and dism to restorehealth may have helped as well. Still have some problems but I should be able to fix those.

I think what happened is OneDrive basically synced all of the corrupted files and configuration over. So you guys were pretty much right on the money.
This topic is 2 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.