Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find a valid module template to use. #1427

Open
raakasf opened this issue Dec 12, 2024 · 5 comments
Open

Unable to find a valid module template to use. #1427

raakasf opened this issue Dec 12, 2024 · 5 comments
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor

Comments

@raakasf
Copy link

raakasf commented Dec 12, 2024

Describe the bug
I get the following error when I run pdk new module --skip-interview foo /Users/<user>/Workspace/puppet/foo/foo:

pdk (INFO): Creating new module: foo
pdk (FATAL): Unable to find a valid module template to use.

I installed the VS Code extension and trying to create a new module using VS Code. Of course, the same command doesn't work from cli. Installed pdk using brew on MacOS.

To Reproduce
Install pdk, pdk new module --skip-interview foo /Users/<user>/Workspace/puppet/foo/foo

Expected behavior
Should create a module

Additional context

  • Your PDK installation method (native packages or via Rubygems): brew
    • (If via Rubygems, please include your Ruby version ruby -v)
  • Your PDK version (pdk --version): 3.4.0
  • Your operating system / platform: MacOS
@raakasf raakasf added bug needs-triage Newly created issue that has not been reviewed by a PDK contributor labels Dec 12, 2024
@raakasf
Copy link
Author

raakasf commented Dec 17, 2024

Can someone help with this please?

@tuxmea
Copy link

tuxmea commented Dec 27, 2024

Running with debug shows:

pdk (DEBUG): STDERR: 
fatal: detected dubious ownership in repository at '/opt/puppetlabs/pdk/share/cache/pdk-templates.git'
To add an exception for this directory, call:

	git config --global --add safe.directory /opt/puppetlabs/pdk/share/cache/pdk-templates.git
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@avitacco
Copy link

avitacco commented Jan 9, 2025

FWIW, this is affecting me too. And I get the same output running with -d.

@natemccurdy
Copy link
Contributor

A temporary workaround is to add the --template-url and --template-ref flags, pointing to the canonical puppetlabs/pdk-templates repo, when creating a new module.

For example:

pdk new module foo --template-url=https://github.com/puppetlabs/pdk-templates --template-ref=main

@psreed
Copy link

psreed commented Jan 15, 2025

FWIW: I was able to use the workaround successfully on a Windows 11 workstation, but NOT on a Ubuntu 24.04 instance
(same workstation under WSL, both updated to 3.4.0)...

I tried with both ref options:
--template-url=https://github.com/puppetlabs/pdk-templates --template-ref=main
--template-url=https://github.com/puppetlabs/pdk-templates --template-ref=3.4.0
per the workaround in the current known issues on the release notes page.

Not sure what the difference would be, and didn't really take the time to troubleshoot further. Worked fine with previous versions of the PDK in both cases.

I'm always willing to assist in providing more relevant details / helping to troubleshoot this if needed on request.

EDIT: Perhaps we're looking at a certificate issue as well ... which i thought was taken care of with the update to 3.4.0? And also confirming what was shown above for the git directory traversal problem:

#pdk new module --skip-interview testmodule --debug                                                                                                                                                                                                                                                                                    
pdk (INFO): Creating new module: testmodule
pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/git/bin/git ls-remote --exit-code https://github.com/puppetlabs/pdk-templates'
pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/git/bin/git ls-remote --exit-code https://github.com/puppetlabs/pdk-templates' complete (duration: 0.123733103s; exit code: 128)
pdk (DEBUG): STDOUT: N/A
pdk (DEBUG): STDERR:
fatal: unable to access 'https://github.com/puppetlabs/pdk-templates/': SSL certificate problem: unable to get local issuer certificate

pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/git/bin/git ls-remote --exit-code file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git'
pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/git/bin/git ls-remote --exit-code file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git' complete (duration: 0.019740061s; exit code: 128)
pdk (DEBUG): STDOUT: N/A
pdk (DEBUG): STDERR:
fatal: detected dubious ownership in repository at '/opt/puppetlabs/pdk/share/cache/pdk-templates.git'
To add an exception for this directory, call:

        git config --global --add safe.directory /opt/puppetlabs/pdk/share/cache/pdk-templates.git
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

pdk (FATAL): Unable to find a valid module template to use.
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.4.0/lib/pdk/util/template_uri.rb:249:in `first_valid_uri'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.4.0/lib/pdk/util/template_uri.rb:57:in `initialize'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.4.0/lib/pdk/generate/module.rb:43:in `new'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.4.0/lib/pdk/generate/module.rb:43:in `invoke'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.4.0/lib/pdk/cli/new/module.rb:48:in `block (2 levels) in <module:CLI>'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:362:in `run_this'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:298:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:316:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:316:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.4.0/lib/pdk/cli.rb:58:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.4.0/exe/pdk:6:in `<top (required)>'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/bin/pdk:25:in `load'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/3.2.5/bin/pdk:25:in `<main>'

Resolution:
Issue seems to be resolved (but maybe not properly from a security perspective) with:
git config --global --add safe.directory /opt/puppetlabs/pdk/share/cache/pdk-templates.git
as is pointed out in the debug.

Not sure if this is the proper thing to add to the installer/upgrade for PDK though, I'll leave that to others to determine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor
Projects
None yet
Development

No branches or pull requests

5 participants