puppetlabs / puppetlabs-vcsrepo

Support for source control repositories
http://forge.puppetlabs.com/puppetlabs/vcsrepo
GNU General Public License v2.0
223 stars 285 forks source link

Syntax error #624

Open gdelhumeau opened 1 year ago

gdelhumeau commented 1 year ago

Describe the Bug

I cannot clone a repository.

Expected Behavior

It should clone the repository.

Steps to Reproduce

This is my manifest:

vcsrepo { '/etc/test/repo':
    ensure   => present,
    provider => git,
    source   => 'https://someUrl/repo.git',
    require => [ File['/etc/test'], Package['git'] ]
  }

I get the following error, when I execute /opt/puppetlabs/puppet/bin/puppet agent -t on the agent:

2023-09-28 17:02:15.134363 WARN  puppetlabs.facter - locale environment variables were bad; continuing with LANG=C LC_ALL=C
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Error: Could not autoload puppet/provider/vcsrepo/cvs: /opt/puppetlabs/puppet/cache/lib/puppet/provider/vcsrepo/cvs.rb:77: syntax error, unexpected ']'
        @rev = contents[1..]
                           ^
Error: Could not autoload puppet/type/vcsrepo: Could not autoload puppet/provider/vcsrepo/cvs: /opt/puppetlabs/puppet/cache/lib/puppet/provider/vcsrepo/cvs.rb:77: syntax error, unexpected ']'
        @rev = contents[1..]
                           ^
Error: Failed to apply catalog: Could not autoload puppet/type/vcsrepo: Could not autoload puppet/provider/vcsrepo/cvs: /opt/puppetlabs/puppet/cache/lib/puppet/provider/vcsrepo/cvs.rb:77: syntax error, unexpected ']'
        @rev = contents[1..]

Environment (on the agent)

Environment (on the server)

kenyon commented 1 year ago

Same as #620 and #618.

anthonysomerset commented 1 year ago

According to https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/601 - Puppet 6 support is dropped, i had same issue - fixed by upgrading the agent to 7.x

bugfood commented 10 months ago

I'm getting a similar error on an AlmaLinux 8 host running puppetserver 7.6.

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Type-Name, Could not autoload puppet/type/vcsrepo: Could not autoload puppet/provider/vcsrepo/cvs: /etc/puppetlabs/code/modules/vcsrepo/lib/puppet/provider/vcsrepo/cvs.rb:77: syntax error, unexpected '{ arg'
        @rev = contents[1..]
                           ^ (file: /etc/puppetlabs/code/local_environments/production/modules/custom/manifests/repo.pp, line: 110, column: 60) (file: /etc/puppetlabs/code/local_environments/production/modules/<redacted>, line: 43) on node <redacted>

The strange thing is that this happens only on the first catalog compilation that uses vcsrepo after a restart. Subsequent compilations that use vcsrepo (for either the same client or for other clients) are fine. Compilations of catalogs without vcsrepo have no effect either way.

This is running puppetserver from a puppetlabs RPM, so It should be using the vendored ruby (and jruby).

$ rpm -qa puppetserver
puppetserver-7.6.0-1.el8.noarch

For what it's worth, the system ruby is new enough as well:

$ ruby --version
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]

I don't think this is the same bug as originally reported, but it's caused by the same commit: https://github.com/puppetlabs/puppetlabs-vcsrepo/commit/f91d02d41315f831b12fe24da9a038034e326457 Reverting that commit makes the problem go away.

I'm not currently in a position to try a newer puppetserver, but I wanted to write this issue down somewhere, for now.

kenyon commented 10 months ago

@bugfood that might be fixed by doing a puppet generate types or restarting puppetserver.

bugfood commented 10 months ago

@bugfood that might be fixed by doing a puppet generate types or restarting puppetserver.

Thanks, but this problem manifests immediately after a restart of puppetserver--and then goes away after the first time it happens.

I don't know about puppet generate types. I've never run this before, but it seems to have something to do with environment isolation, which we don't use.

https://www.puppet.com/docs/puppet/7/environment_isolation.html#env_generate_types

hesco commented 7 months ago

According to #601 - Puppet 6 support is dropped, i had same issue - fixed by upgrading the agent to 7.x

This was also the fix for me.

As an enhancement, I urge that this line (77) which fails with puppet6 on the agent (not the puppetserver, as suggested above, and which for my own environment had previously been upgraded to 7), be wrapped in a try...catch which links to this thread and advises an upgrade of puppet on the client.