bcurran3 / ChocolateyPackages

My published Chocolatey packages
206 stars 94 forks source link

install fails - Access to the path is denied #338

Closed cforce closed 12 months ago

cforce commented 1 year ago

I can not install from Admin shell successfully - and i have no idea what the issue is

C:>choco install choco-package-list-backup Chocolatey v2.1.0 Installing the following packages: choco-package-list-backup By installing, you accept licenses for the packages. Progress: Downloading choco-package-list-backup 2023.6.28... 100%

choco-package-list-backup v2023.6.28 [Approved] choco-package-list-backup package files install completed. Performing other installation steps. Adding C:\ProgramData\chocolatey\bin\choco-package-list-backup.bat and pointing it to powershell command C:\tools\BCURRAN3\choco-package-list-backup.ps1 SUCCESS: The parameters of scheduled task "choco-package-list-backup" have been changed.

** Existing choco-package-list-backup scheduled task found:

Folder: \ TaskName Next Run Time Status ======================================== ====================== =============== choco-package-list-backup 24.07.2023 06:00:00 Ready

Keeping existing scheduled task and upgrading script files. Progress: 100% - 1/1 completed Running Choco-Package-List-Backup.ps1 to create backup(s)... Choco-Package-List-Backup.ps1 v2023.06.28 - backup Chocolatey packages list locally and to the cloud Copyleft 2017-2023 Bill Curran (bcurran3@yahoo.com) - free for personal and commercial use

Choco Package List Backup Summary:

** Saving to DOCUMENTS: ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Rename-Item : Access to the path is denied. The install of choco-package-list-backup was NOT successful. Error while running 'C:\ProgramData\chocolatey\lib\choco-package-list-backup\tools\ChocolateyInstall.ps1'. See log for details.

Chocolatey installed 0/1 packages. 1 packages failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures

C:>CPLB.bat Choco-Package-List-Backup.ps1 v2023.06.28 - backup Chocolatey packages list locally and to the cloud Copyleft 2017-2023 Bill Curran (bcurran3@yahoo.com) - free for personal and commercial use

Choco Package List Backup Summary:

** Saving to DOCUMENTS: Rename-Item : Access to the path is denied. At C:\tools\BCURRAN3\choco-package-list-backup.ps1:323 char:48

bcurran3 commented 1 year ago

This is the line mentioned: if (Test-Path "$SavePath\$PackagesListFile") {Rename-Item "$SavePath\$PackagesListFile" "$SavePath\$PackagesListFile.bak"}

Make sure <PackagesListFile>packages.config</PackagesListFile> looks right in your config.

cforce commented 1 year ago

Exactly that is the line inC:\tools\BCURRAN3\choco-package-list-backup.config

bcurran3 commented 1 year ago

OK. Well the error is "CategoryInfo : PermissionDenied:" meaning you don't have permissions to rename the file for some reason. So you should fix the permissions on the file and you're problem will go away.

cforce commented 1 year ago

I have and use the shell with LocalAdmin rights .. however i might not have extended rights to manipulate system or system32 files .. so .. i really would like to understand what rights in which folders and files are expected and how i can explicit define which folder i want to use here. It definitely shall allow me to restrict my installation target to defined folder where i have rights, but it don't see that there is a issue as i have this rights anyway

bcurran3 commented 1 year ago

Hallo. You're problem is in the Documents folder. You should have access. You shouldn't even need admin rights if it's your account's documents folder. Honestly that's the least helpful place to store your package list backup as if your computer dies, you loose the files. The main purpose of CPLB is to recover from a crash or migrate to a new computer. If you want to fix the current problem, you can right click on the packages.config file that exists in your documents folder and view the properties to see the security settings. By default it's YOUR Documents folder and you should have rights. Simply delete the file and you'll be able to make another backup and if those permissions are standard/default you should be good to go to rename the file in the future. IMHO: I'd set UseDocuments to false in the config and make sure the backup gets created in some more useful cloud storage or local server for backup.

With that said, I could be completely off with some other unexpected x-factor causing the problem. If you've modified your config file at all you should post your config file for me to look at or simply uninstall and re-install so I know it's at defaults.

cforce commented 1 year ago

The problem seems that my documents folder points/mapped to some samba drive which has strange rights and i can't disable /reconfigure it . Of course i have OneDrives available i can use but CLBP still fails if it can't use the "default" document folder properly. I try to switch of via settings all but my oneDrive.