Chef shell-init command on windows is having encoding issues and corrupting the $profile
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 18
- Forks
- 23
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 1
Description
Running the following command with ChefDK 0.14.25 on Win10 with PowerShell v5:
powershell
S:> "chef shell-init powershell | Invoke-Expression" >> $PROFILE
The shell-init command is added to my $profile with null bytes between each character. Launching a new PowerShell session throws error from the $profile.
``` powershell```
S:\> gc $PROFILE
## Import Modules
# Import-Module PSReadLine
# Import-Module PsGet
# Import-Module pscx
## Import Modules end
c h e f s h e l l - i n i t p o w e r s h e l l | I n v o k e - E x p r e s s i o n
The root issue here is that my $profile file was using ANSI encoding instead of UTF8 or USC2.
One solution is to append with a specific encoding:
powershell
"chef shell-init powershell | Invoke-Expression" | out-file $PROFILE -Encoding utf8 -append
... but then you end up changing the encoding type of the entire file. And that might cause other problems for people.
[PSVersionTable.txt](https://github.com/chef/chef-dk/files/273469/PSVersionTable.txt)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using ChefDK 0.14.25 on Windows 10 with PowerShell 5, running the shown shell-init command against an ANSI-encoded $PROFILE. No repository file or test is named; done means the command no longer inserts null bytes or corrupts the existing profile encoding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, ruby
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100