puppetlabs / ruby-pwsh

A ruby gem for interacting with PowerShell
MIT License
15 stars 23 forks source link

Windows long path support #185

Closed josuemotte closed 2 years ago

josuemotte commented 2 years ago

Hi

Bug description

We are trying to run install via librarian-puppet a module which rely on puppetlabs-pwshlib, all other dependency seemed to be installed successfully but not puppetlabs-pwshlib

It looks like to be a common issue while using librarian-puppet on Windows however the long path issue has been fixed with Ruby 3.0.2 as explained here : https://github.com/ruby/ruby/pull/4505 and here : https://puppet.com/blog/supporting-long-file-paths-on-windows/ https://puppet.com/docs/puppet/6/release_notes_puppet.html#release_notes_puppet_6-23-0

Here is the Puppetfile.lock :

FORGE
  remote: https://a_token_service_user:very_long_token@choco.pomme.renard.com/artifactory/api/puppet/hzeym_azwrivvgjjkntbtnhwptqlbkwbnweyxfgbdicbwqrkgrscffbgnlbuhn-forge
  specs:
    puppetlabs-chocolatey (5.2.1)
      puppetlabs-powershell (>= 1.0.1, < 5.0.0)
      puppetlabs-registry (>= 1.0.0, < 4.0.0)
      puppetlabs-stdlib (>= 4.6.0, < 7.0.0)
    puppetlabs-concat (6.1.0)
      puppetlabs-stdlib (>= 4.13.1, < 7.0.0)
      puppetlabs-translate (>= 1.0.0, < 3.0.0)
    puppetlabs-powershell (4.1.0)
      puppetlabs-pwshlib (>= 0.4.0, < 2.0.0)
    puppetlabs-pwshlib (0.10.1)
    puppetlabs-registry (3.2.0)
    puppetlabs-stdlib (6.0.0)
    puppetlabs-translate (2.2.0)

DEPENDENCIES
  puppetlabs-chocolatey (>= 5.0.2, < 6.0.0)

And the error message we are getting while running librarian-puppet install --verbose

Error executing puppet module install. Check that this command succeeds:
puppet module install --version 0.10.1 --target-dir C:/tmp/.tmp/librarian/cache/source/puppet/forge/hzeym_azwrivvgjjkntbtnhwptqlbkwbnweyxfgbdicbwqrkgrscffbgnlbuhn-forge/puppetlabs-pwshlib/0.10.1 --module_repository https://a_token_service_user:very_long_token@choco.pomme.renard.com/artifactory/api/puppet/hzeym_azwrivvgjjkntbtnhwptqlbkwbnweyxfgbdicbwqrkgrscffbgnlbuhn-forge --modulepath C:/tmp/.tmp/librarian/cache/source/puppet/forge/hzeym_azwrivvgjjkntbtnhwptqlbkwbnweyxfgbdicbwqrkgrscffbgnlbuhn-forge/puppetlabs-pwshlib/0.10.1 --module_working_dir C:/tmp/.tmp/librarian/cache/source/puppet/forge/hzeym_azwrivvgjjkntbtnhwptqlbkwbnweyxfgbdicbwqrkgrscffbgnlbuhn-forge/puppetlabs-pwshlib/0.10.1 --ignore-dependencies puppetlabs-pwshlib
Error:
Error: No such file or directory @ rb_sysopen - C:/tmp/.tmp/librarian/cache/source/puppet/forge/hzeym_azwrivvgjjkntbtnhwptqlbkwbnweyxfgbdicbwqrkgrscffbgnlbuhn-forge/puppetlabs-pwshlib/0.10.1/cache/tmp20210929-2988-wrs695/puppetlabs-pwshlib-0.10.1/lib/puppet/provider/dsc_base_provider/invoke_dsc_resource_functions.ps1
Error: Try 'puppet help module install' for usage
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/source/forge/repo.rb:129:in `rescue in cache_version_unpacked!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/source/forge/repo.rb:114:in `cache_version_unpacked!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/source/forge/repo.rb:56:in `install_version!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/source/forge.rb:115:in `install!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/manifest.rb:73:in `install!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/action/install.rb:49:in `block in install_manifests'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/action/install.rb:48:in `each'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/action/install.rb:48:in `install_manifests'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/action/install.rb:39:in `perform_installation'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/action/install.rb:12:in `run'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/cli.rb:101:in `install!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/cli.rb:70:in `install'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/cli.rb:31:in `returning_status'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/cli.rb:26:in `block in bin!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/cli.rb:47:in `with_environment'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarianp-0.6.4/lib/librarian/cli.rb:26:in `bin!'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/librarian-puppet-3.0.0/bin/librarian-puppet:7:in `<top (required)>'
C:/tools/ruby30/bin/librarian-puppet:23:in `load'
C:/tools/ruby30/bin/librarian-puppet:23:in `<main>'

Expected Behavior

To work

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a simple puppet module that require puppetlabs-chocolatey
  2. Install librarian-puppet and run librarian-puppet install --no-use-v1-api --verbose

Environment

michaeltlombardi commented 2 years ago

Hi @josuemotte! Can you validate that HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled is set? While Ruby and Puppet both added support for long file paths, it needs to be enabled on the server as well.

josuemotte commented 2 years ago

Hello @michaeltlombardi ,

Yes it's set

PS C:\tmp> Get-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled'

LongPathsEnabled : 1
PSPath           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem
PSParentPath     : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control
PSChildName      : FileSystem
PSDrive          : HKLM
PSProvider       : Microsoft.PowerShell.Core\Registry
michaeltlombardi commented 2 years ago

@josuemotte thinking on this overnight, I believe this issue is not with this repository, as such, but possibly with the implementation of librarian-puppet - the long file paths are not being hit because this repository's files are particularly long but because of how librarian is pulling them down; unfortunately, I don't think there's anything I can do to impact this from the library perspective - I know from prior validation efforts for Puppet.Dsc that files with long paths can be pulled locally and deployed by both puppet module install and r10k.

If you have any ideas for how we could better support you, I'd be interested and we can reopen!