Jira (PUP-11348) Remove Windows ENV patches on Ruby 3

1 view
Skip to first unread message

Josh Cooper (Jira)

unread,
Nov 11, 2021, 2:11:03 PM11/11/21
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Improvement PUP-11348
Remove Windows ENV patches on Ruby 3
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2021/11/11 11:10 AM
Fix Versions: PUP 8.0.0
Priority: Normal Normal
Reporter: Josh Cooper

Ruby on Windows now stores environment variables and values as UTF-8, see https://bugs.ruby-lang.org/issues/9715#note-8 so we should be able to remove the various monkey patches and workarounds in puppet.

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Nov 11, 2021, 2:28:03 PM11/11/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Ruby on Windows now stores environment variables and values as UTF-8, see [https://bugs.ruby-lang.org/issues/9715#note-8] so we should be able to remove the various monkey patches and workarounds in puppet , such as {{Puppet::Util . get_env}}

 

Josh Cooper (Jira)

unread,
Sep 2, 2022, 2:43:03 PM9/2/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PA-4664
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Josh Cooper (Jira)

unread,
Sep 12, 2022, 2:20:03 PM9/12/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Phoenix

Josh Cooper (Jira)

unread,
Dec 5, 2022, 8:34:03 PM12/5/22
to puppe...@googlegroups.com

Morgan Rhodes (Jira)

unread,
Dec 8, 2022, 1:32:03 PM12/8/22
to puppe...@googlegroups.com
Morgan Rhodes updated an issue
 
Change By: Morgan Rhodes
Story Points: 5

Josh Cooper (Jira)

unread,
Jan 9, 2023, 3:41:02 PM1/9/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Ruby on Windows now stores environment variables and values as UTF-8, see [https://bugs.ruby-lang.org/issues/9715#note-8] so we should be able to remove the various monkey patches and workarounds in puppet, such as {{Puppet::Util.get_env}}
 
Puppet should be able to:
* manage registry entries with non-ascii characters
 
* manage users with umlat, C:\Users\John
 
* execute process with non-ascii in the command line
 
* get/set environment variables with rune characters: https://bugs.ruby-lang.org/issues/8822#note-6

Josh Cooper (Jira)

unread,
Jan 9, 2023, 3:50:02 PM1/9/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Ruby on Windows now stores environment variables and values as UTF-8, see [https://bugs.ruby-lang.org/issues/9715#note-8] so we should be able to remove the various monkey patches and workarounds in puppet, such as {{Puppet::Util.get_env}}
 
Puppet should be able to:
* manage registry entries with non-ascii characters
 
* manage users with umlat, C:\Users\ John Jöhn
 
* execute process with non-ascii in the command line
as a non-ascii user
 
* get/set environment variables with rune characters:
[ https://bugs.ruby-lang.org/issues/8822#note-6 ]

See related info in :

https://tickets.puppetlabs.com/browse/PUP-5726?focusedCommentId=261201&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-261201

And

{code:puppet}
exec { 'tomcat-configure-service':
  command  => "powershell.exe Get-ChildItem Env:",
  onlyif   => 'powershell.exe exit 0',      
  provider => windows,
  logoutput => true,
  #notify => $tomcat_service,
  tag      => 'tomcat-configure-service',
}
{code}

{noformat}
set USERNAME=Jöhn
set USERPROFILE=C:\Users\Jöhn
C:\> puppet apply manifests\bug_swedish_userprofile.pp --test
{noformat}

Josh Cooper (Jira)

unread,
Jan 9, 2023, 3:51:01 PM1/9/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Ruby on Windows now stores environment variables and values as UTF-8, see [https://bugs.ruby-lang.org/issues/9715#note-8] so we should be able to remove the various monkey patches and workarounds in puppet, such as {{Puppet::Util.get_env}}
 
Puppet should be able to:
* manage registry entries with non-ascii characters
 
* manage users with umlat, C:\Users\Jöhn

 
* execute process with non-ascii in the command line as a non-ascii user
 
* get/set environment variables with rune characters: [https://bugs.ruby-lang.org/issues/8822#note-6]

See related info in :

https://tickets.puppetlabs.com/browse/PUP-5726?focusedCommentId=261201&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-261201

And

{code:puppet}
exec { 'tomcat-configure-service':
  command  => "powershell.exe Get-ChildItem Env:",
  onlyif   => 'powershell.exe exit 0',      
  provider => windows,
  logoutput => true,
  #notify => $tomcat_service,
  tag      => 'tomcat-configure-service',
}
{code}

{noformat}
set USERNAME=Jöhn
set USERPROFILE=C:\Users\Jöhn
C:\> puppet apply manifests\bug_swedish_userprofile.pp --test
{noformat}

Josh Cooper (Jira)

unread,
Jan 27, 2023, 1:38:02 PM1/27/23
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-11348
 
Re: Remove Windows ENV patches on Ruby 3

Putting this in needs information until we have builds of puppet-agent with Ruby 3.2

Michael Hashizume (Jira)

unread,
Mar 29, 2023, 1:08:05 PM3/29/23
to puppe...@googlegroups.com
Michael Hashizume updated an issue
 
Change By: Michael Hashizume
Sprint: Phoenix 2023-04-12

Josh Cooper (Jira)

unread,
Apr 11, 2023, 4:48:03 PM4/11/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Ruby on Windows now stores environment variables and values as UTF-8, see [https://bugs.ruby-lang.org/issues/9715#note-8]  so we should be able to remove .

Using
the various monkey patches and workarounds in latest puppet -agent and runtime with the default external encoding set to "locale" , such as modify {{ Puppet::Util. get_env}}
 
Puppet should be able to:
* manage registry entries with non-ascii characters
 
* manage users with umlat , C:\Users\Jöhn
 
* execute process with non-ascii in
{{clear_environment}} and {{set_env}} to no longer special case Windows and just delegate to Ruby's {{ENV}}. Then try to reproduce the command line as a non-ascii user
 
* get/set environment variables with rune characters: [
issue described in https://bugs.ruby-lang.org/ issues projects / 8822#note ruby - 6]

See related info in :

https:
master / /tickets.puppetlabs.com/browse/PUP-5726 activity ? focusedCommentId from = 261201&page=com.atlassian.jira.plugin.system.issuetabpanels:comment 2016 - tabpanel#comment 06 - 261201

https://tickets.puppetlabs.com/browse/PUP-5768?focusedCommentId=273221
22 to see that environment values can be set & page=com get correctly . atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-273221

And Environment names should be case insensitive.

{code:puppet}
exec { 'tomcat-configure-service':
  command  => "powershell
Environment values should be case preserving . exe Get-ChildItem Env:",
  onlyif   => 'powershell It should be possible to get/set environment values using characters that are valid for the current locale, e . exe exit 0' g. if chcp is set to CP1252 ,       
  provider => windows,
it should be possible to store extended ascii characters as values like Á
  logoutput => true,
  #notify => $tomcat_service Also related ,
  tag      => 'tomcat-configure-service'
if the current user profile contains extended ascii , then it should be possible to do:
}
{
code}

{
noformat}

set USERNAME=Jöhn
set USERPROFILE=C:\Users\Jöhn
C:\> puppet apply manifests\bug_swedish_userprofile.pp --test
{noformat}

Josh Cooper (Jira)

unread,
Apr 12, 2023, 1:05:11 PM4/12/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Phoenix 2023-04-12 , Phoenix 2023-04-26

Josh Cooper (Jira)

unread,
Apr 13, 2023, 1:15:01 PM4/13/23
to puppe...@googlegroups.com
Josh Cooper assigned an issue to Josh Cooper
Change By: Josh Cooper
Assignee: Josh Cooper

Josh Cooper (Jira)

unread,
Apr 13, 2023, 1:37:01 PM4/13/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Ruby on Windows now stores environment variables and values as UTF-8, see [https://bugs.ruby-lang.org/issues/9715#note-8].

Using the latest puppet-agent and runtime with the default external encoding set to "locale", modify {{get_env}}, {{clear_environment}} and {{set_env}} to no longer special case Windows and just delegate to Ruby's {{ENV}}. Then try to reproduce the issue described in https://bugs.ruby-lang.org/
projects issues / ruby 9715#note - master/activity?from=2016-06-22 8 to see that environment values can be set & get correctly.


Environment names should be case insensitive.
Environment values should be case preserving.
It should be possible to get/set environment values using characters that are valid for the current locale, e.g. if chcp is set to CP1252, it should be possible to store extended ascii characters as values like Á

Also related, if the current user profile contains extended ascii, then it should be possible to do:

{noformat}

set USERNAME=Jöhn
set USERPROFILE=C:\Users\Jöhn
C:\> puppet apply manifests\bug_swedish_userprofile.pp --test
{noformat}

See more details in: https://tickets.puppetlabs.com/browse/PUP-5726?focusedCommentId=261201&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-261201

Josh Cooper (Jira)

unread,
Apr 13, 2023, 2:07:02 PM4/13/23
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-11348
 
Re: Remove Windows ENV patches on Ruby 3

Verified external encoding is set to the locale encoding, in this case CP932/Shift-JIS. And ruby can retrieve an environment, transcoding its value from CP932 to UTF-8:

C:\>type encodings.rb
%w[external internal locale filesystem].each do |name|
  enc = Encoding.find(name)
  puts "#{name}: #{enc ? enc.name : '<undefined>'}"
end
 
C:\>ruby encodings.rb
external: Windows-31J
internal: <undefined>
locale: Windows-31J
filesystem: UTF-8
 
C:\>type env.rb
value = ENV['UNICODE']
puts value.valid_encoding?
puts value.encoding
puts value
puts value.bytes.map { |b| b.ord }.map { |i| i.to_s(16) }.join(' ')
 
C:\>set UNICODE=㐀
 
C:\>ruby  env.rb
true
UTF-8
e3 90 80

Josh Cooper (Jira)

unread,
Apr 14, 2023, 5:26:02 PM4/14/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Deprecation
Release Notes Summary: The Puppet::Util methods for getting, setting, clearing and merging environment variables are still available, but are deprecated and will be removed in the next major release. Puppet 8 now uses Ruby's builtin ENV class to manage environment variables on Windows.

Parker Leach (Jira)

unread,
Apr 19, 2023, 2:54:01 PM4/19/23
to puppe...@googlegroups.com
Parker Leach updated an issue
Change By: Parker Leach
Labels: docs_reviewed
Reply all
Reply to author
Forward
0 new messages