Skip to content
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

PowerShell Core global config file #924

Closed
Naomi010Sentzke opened this issue Mar 24, 2020 · 9 comments
Closed

PowerShell Core global config file #924

Naomi010Sentzke opened this issue Mar 24, 2020 · 9 comments
Labels

Comments

@Naomi010Sentzke
Copy link

PowerShell Core's global config is stored in a 'profile.ps1' file in $PSHome (%SCOOP%\apps\pwsh\current). Its not persisted.

@Naomi010Sentzke
Copy link
Author

I tried to create this
https://gist.github.com/Naomi010Sentzke/48d6ed4aeadb562522ed338d4ee84249
Unfortunately Scoop changes "profile.ps1" to "profile.ps1.original" and persists a folder called "profile.ps1" instead.

@BlackPowerade
Copy link
Contributor

"if (!(Test-Path \"$persist_dir\\mednafen.cfg\")) {",
"   New-Item \"$dir\\mednafen.cfg\" | Out-Null",
"}"

I use this snippet all the time for applications that don't come with a file that needs to be persisted, or only creates it after being run.

@Naomi010Sentzke
Copy link
Author

@BlackPowerade It still renames "profile.ps1" to "profile.ps1.original" and persists a folder called "profile.ps1".

@BlackPowerade
Copy link
Contributor

@Naomi010Sentzke Sorry, forgot to mention it doesn't work when used in pre-install. Place it in installer or post-install, delete the profile.ps1 folder in your persist directory and try it again.

@Ash258
Copy link
Contributor

Ash258 commented Apr 14, 2020

@BlackPowerade Stop confusing users and spreading clearly incorrect information.

Doing persist checks inside post-install is completely nonsense as it leads to anything.

You can do anything to $pesist_dir in any of the script blocks as it is defined in whole lifecycle of the manifest installation.

post_install is happening after the actual persisting. Which lead into the file being created as directory and leading to same problem as you had before.

Persist checks has to be done in pre_install or installer.script as done in all of the manifests everywhere in official buckets.

image

@Naomi010Sentzke
Copy link
Author

Naomi010Sentzke commented Apr 14, 2020

Yeah, persisting happens before post-install. Installer script has the same issue - profile.ps1 gets renamed to profile.ps1.original and a folder called profile.ps1 gets persisted.
Here is a revision with installer script
https://gist.github.com/Naomi010Sentzke/48d6ed4aeadb562522ed338d4ee84249/146a1bb73c9026fd6ae989a59caddc6ac6936a78

@BlackPowerade
Copy link
Contributor

@Ash258 I see. I thought post-install happened right after extraction, but before persisting.
Also @Naomi010Sentzke You have to change mednafen.cfg to profile.ps1.

"if (!(Test-Path \"$persist_dir\\mednafen.cfg\")) {",
            "   New-Item \"$dir\\profile.ps1\" | Out-Null",
            "}"

@Naomi010Sentzke
Copy link
Author

@BlackPowerade oops. my bad.

@stale
Copy link

stale bot commented Oct 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 27, 2021
@stale stale bot closed this as completed Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
@Ash258 @BlackPowerade @Naomi010Sentzke and others