chezmoi: Chezmoi script doesn't work with powershell script.

What exactly are you trying to do?

Chezmoi script run_ doesn’t work with powershell script(ps1).

When I try to apply the run_ powershell scripts the script return

At C:\Users\Ronny\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:1 char:17
+ $env:USERPROFILE\.config\powershell\user_profile.ps1
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '\.config\powershell\user_profile.ps1' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

Even though I can execute it normally through terminal. I know I can use .bat but I want to use .ps1

The run_once-test.bat file indicated with R, even after applying it. It’s still in chezmoi status so I can apply it multiple times without it’s content changing.

What have you tried so far?

  • Run powershell with no profile.
  • Run powershell with $ENV:shell="cmd" or “pwsh”.

Where else have you checked for solutions?

Output of any commands you’ve tried with --verbose flag

diff --git a/once-test.bat b/once-test.bat
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..211f200e3bd2b13ece6e738815610688fb7e2ce2 100755
--- a/once-test.bat
+++ b/once-test.bat
@@ -0,0 +1 @@
+echo Testing

C:\Users\Ronny>echo Testing
Testing

Output of chezmoi doctor

RESULT    CHECK                MESSAGE
ok        version              v2.25.0, commit b3a8879e30a20134c9bef48646055e57aa78d8c5, built at 2022-10-13T14:01:32Z, built by goreleaser
ok        latest-version       v2.25.0
ok        os-arch              windows/amd64
ok        systeminfo           Microsoft Windows 10 Pro (10.0.19043 N/A Build 19043)
ok        go-version           go1.19.2 (gc)
ok        executable           ~/scoop/apps/chezmoi/current/chezmoi.exe
ok        upgrade-method       replace-executable
ok        config-file          ~/.config/chezmoi/chezmoi.toml, last modified 2022-10-19T20:10:14+07:00
warning   source-dir           ~/.local/share/chezmoi is a git working tree (dirty)
warning   suspicious-entries   ~/.local/share/chezmoi/dot_config/chezmoi/chezmoi.toml
warning   working-tree         ~/.local/share/chezmoi is a git working tree (dirty)
ok        dest-dir             ~ is a directory
ok        cd-command           found C:/Program Files/WindowsApps/Microsoft.PowerShell_7.2.6.0_x64__8wekyb3d8bbwe/pwsh.exe
ok        cd-args              'C:\\Program Files\\WindowsApps\\Microsoft.PowerShell_7.2.6.0_x64__8wekyb3d8bbwe\\pwsh.exe'
info      diff-command         not set
ok        edit-command         found ~/scoop/shims/nvim.exe
ok        edit-args            nvim
ok        git-command          found C:/Program Files/Git/cmd/git.exe, version 2.36.1
ok        merge-command        found ~/scoop/shims/nvim.exe
ok        shell-command        found C:/Program Files/WindowsApps/Microsoft.PowerShell_7.2.6.0_x64__8wekyb3d8bbwe/pwsh.exe
ok        shell-args           'C:\\Program Files\\WindowsApps\\Microsoft.PowerShell_7.2.6.0_x64__8wekyb3d8bbwe\\pwsh.exe'
info      age-command          age not found in $PATH
info      gpg-command          gpg not found in $PATH
info      pinentry-command     not set
info      1password-command    op not found in $PATH
info      bitwarden-command    bw not found in $PATH
info      gopass-command       gopass not found in $PATH
info      keepassxc-command    keepassxc-cli not found in $PATH
info      keepassxc-db         not set
info      keeper-command       keeper not found in $PATH
info      lastpass-command     lpass not found in $PATH
info      pass-command         pass not found in $PATH
info      passhole-command     ph not found in $PATH
info      vault-command        vault not found in $PATH
info      secret-command       not set

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

What is the output of chezmoi apply --debug? I’m particularly interested in the lines that contain test.bat.