PDK 1.0.0.1 on Windows

84 views
Skip to first unread message

Peter Faller

unread,
Aug 17, 2017, 2:12:21 AM8/17/17
to Puppet Users
While trying to use the PDK on Windows (instead of using a Linux VM for development), I've come across a few hitches:

1) 'rake' is not available as a command (it is accessible via $env:DEVKIT_BASEDIR/private/private\ruby\2.1.9\bin\rake though)
2) 'rspec' is not available as a command
3) errors related to file paths (seems to be an old Windows-related issue): Parameter path failed on File[/tftpboot]: File paths must be fully qualified, not '/tftpboot' at line 4

Are there any workarounds for these?

(BTW: Initially I had a standard Ruby 2.1 install in my PATH - that caused a lot of trouble too.)

David Schmitt

unread,
Aug 17, 2017, 4:33:08 AM8/17/17
to Puppet Users
On 17 August 2017 at 07:12, Peter Faller <pgfa...@gmail.com> wrote:
While trying to use the PDK on Windows (instead of using a Linux VM for development), I've come across a few hitches:

1) 'rake' is not available as a command (it is accessible via $env:DEVKIT_BASEDIR/private/private\ruby\2.1.9\bin\rake though)
2) 'rspec' is not available as a command
3) errors related to file paths (seems to be an old Windows-related issue): Parameter path failed on File[/tftpboot]: File paths must be fully qualified, not '/tftpboot' at line 4

Are there any workarounds for these?

The first two are easily addressed by running the commands through `pdk bundle`. This ensures that you are using the PDK's ruby, and execution environment. Generally the `pdk bundle` command should support running any command that you have available through your Gemfile. for example `pdk bundle exec "rake -T"`. See https://github.com/puppetlabs/pdk#pdk-bundle-command (or the built-in help) for details.

Would you mind sharing (even if privately) your use cases, where `pdk test unit` is not providing enough functionality for you?

Number 3) has been fixed in rspec-puppet 2.6.0. If you are running an earlier version, please update! If you are running rspec-puppet 2.6, or newer, would you mind sending in a repro case directly on the rspec-puppet github repo, so that we can have a poke at it?


(BTW: Initially I had a standard Ruby 2.1 install in my PATH - that caused a lot of trouble too.)

This is surprising to me. We took great care that the pdk command is independent of  existing ruby installations. Can you send me the commands you were running, and how they failed on you, as well as how you installed the PDK, and which versions of Windows, and PowerShell you were running?


Thank you for your feedback!


Cheers, David

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/238147f7-36e6-4a8f-998e-4f2570e68c91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Faller

unread,
Aug 17, 2017, 7:11:35 AM8/17/17
to Puppet Users
Hi David

Thanks for pointing out 'pdk bundle' - it does provide what I was looking for. It is however a bit noisy (but that's not a big deal):

PS> pdk bundle exec -- rspec .\spec\classes\apg_base_spec.rb
.

Finished in 7.81 seconds (files took 1.85 seconds to load)
1 example, 0 failures

C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:6: warning: already initialized constant FFI::WIN32_FALSE
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:5: warning: previous definition of WIN32_FALSE was here
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:9: warning: already initialized constant FFI::ERROR_SUCCESS
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:8: warning: previous definition of ERROR_SUCCESS was here
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:21: warning: already initialized constant FFI::Pointer::NULL_HANDLE
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:20: warning: previous definition of NULL_HANDLE was here
!! spec/fixtures/modules/rimcdm already exists and is not a symlink 


The things that I use 'rake' and 'rspec' for are:

> rspec spec/classes/some_class_spec.rb # to run a single unit test instead of all tests
> rake spec_prep # to update fixtures
> rake spec_standalone # to run tests without updating fixtures

I'm working on refactoring an over-sized module; that's why being able to do quick tests is important to me.

I'm using the version of rspec-puppet bundled with the PDK - it appears to be version 2.6.7:

PS> pdk bundle exec -- rspec --debug
...
# C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/rspec-puppet-2.6.7/lib/rspec-puppet/monkey_patches.rb:273:in `require'
...

On Thursday, 17 August 2017 10:33:08 UTC+2, David Schmitt wrote:
<why does google groups insist on quoting every message?? - snip>

David Schmitt

unread,
Aug 17, 2017, 9:32:49 AM8/17/17
to Puppet Users
On 17 August 2017 at 12:11, Peter Faller <pgfa...@gmail.com> wrote:
Hi David

Thanks for pointing out 'pdk bundle' - it does provide what I was looking for. It is however a bit noisy (but that's not a big deal):

PS> pdk bundle exec -- rspec .\spec\classes\apg_base_spec.rb
.

Finished in 7.81 seconds (files took 1.85 seconds to load)
1 example, 0 failures

C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:6: warning: already initialized constant FFI::WIN32_FALSE
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:5: warning: previous definition of WIN32_FALSE was here
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:9: warning: already initialized constant FFI::ERROR_SUCCESS
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:8: warning: previous definition of ERROR_SUCCESS was here
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:21: warning: already initialized constant FFI::Pointer::NULL_HANDLE
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:20: warning: previous definition of NULL_HANDLE was here
!! spec/fixtures/modules/rimcdm already exists and is not a symlink 

This is now tracked in https://tickets.puppetlabs.com/browse/FACT-1733, but the underlying problem is https://tickets.puppetlabs.com/browse/FACT-1542 , which will require some time to resolve.
 
The things that I use 'rake' and 'rspec' for are:

> rspec spec/classes/some_class_spec.rb # to run a single unit test instead of all tests

Eventually, `pdk test unit` will properly expose rspec's selector CLI.


> rake spec_prep # to update fixtures
> rake spec_standalone # to run tests without updating fixtures

I'm working on refactoring an over-sized module; that's why being able to do quick tests is important to me.

 

I'm using the version of rspec-puppet bundled with the PDK - it appears to be version 2.6.7:

PS> pdk bundle exec -- rspec --debug
...
# C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/rspec-puppet-2.6.7/lib/rspec-puppet/monkey_patches.rb:273:in `require'
...


That's interesting. In the scientific sense. Is there a way you could share the module, or a reduced example that repro's the issue?



Cheers, David



Peter Faller

unread,
Aug 17, 2017, 11:14:26 AM8/17/17
to Puppet Users
Hi David

Reduced example manifest and test attached ... 

On Linux:

[root@tstpuppet01 rimcdm]# rspec spec/defines/test_reduced_spec.rb 
.

Finished in 0.79952 seconds (files took 2.66 seconds to load)
1 example, 0 failures

On Windows:

PS rimcdm> pdk bundle exec -- rspec .\spec\defines\test_reduced_spec.rb
F

Failures:

  1) rimcdm::test_reduced Create Test environment should compile into a catalogue without dependency cycles
     Failure/Error: is_expected.to compile
       error during compilation: Parameter path failed on File[/var/lib/tftpboot]: File paths must be fully qualified, n
ot '/var/lib/tftpboot' at line 3
     # ./spec/defines/test_reduced_spec.rb:18:in `block (3 levels) in <top (required)>'

Finished in 8.33 seconds (files took 2.02 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/defines/test_reduced_spec.rb:17 # rimcdm::test_reduced Create Test environment should compile into a catalo
gue without dependency cycles


On Thursday, 17 August 2017 15:32:49 UTC+2, David Schmitt wrote:
...
test_reduced.pp
test_reduced_spec.rb

David Schmitt

unread,
Aug 17, 2017, 12:22:24 PM8/17/17
to Puppet Users
Oh, that was easier than expected: rspec-puppet does not provide a default set of facts to your tests. Without any facts, puppet assumes your "host" OS as test environment. Since your test is targeting a Linux machine, when running the tests on Windows, this assumption is wrong.

To fix, use rspec-puppet-facts in your tests to provide prefab fact sets to your tests. The pdk ships a copy, but you'll have to add it to your Gemfile (or use the Gemfile from the pdk-module-template (e.g. copying over from a `pdk new module` run). PDK-428 will make that easier, soon.

https://github.com/puppetlabs/pdk-module-template/blob/master/object_templates/class_spec.erb is the default class test, and the rspec-puppet-facts README has more explanations.


Cheers, David


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.

Peter Faller

unread,
Aug 18, 2017, 5:16:03 AM8/18/17
to Puppet Users
Thanks David - the combination of rspec-puppet-facts and 'operatingsystem_support' in metadata.json makes it work.

On Thursday, 17 August 2017 18:22:24 UTC+2, David Schmitt wrote:
<snip>

Ethan Brown

unread,
Aug 19, 2017, 1:24:01 PM8/19/17
to puppet...@googlegroups.com
On Thu, Aug 17, 2017 at 6:32 AM, David Schmitt <david....@puppet.com> wrote:


On 17 August 2017 at 12:11, Peter Faller <pgfa...@gmail.com> wrote:
Hi David

Thanks for pointing out 'pdk bundle' - it does provide what I was looking for. It is however a bit noisy (but that's not a big deal):

PS> pdk bundle exec -- rspec .\spec\classes\apg_base_spec.rb
.

Finished in 7.81 seconds (files took 1.85 seconds to load)
1 example, 0 failures

C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:6: warning: already initialized constant FFI::WIN32_FALSE
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:5: warning: previous definition of WIN32_FALSE was here
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:9: warning: already initialized constant FFI::ERROR_SUCCESS
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:8: warning: previous definition of ERROR_SUCCESS was here
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/puppet-5.0.1-x64-mingw32/lib/puppet/util/windows
/api_types.rb:21: warning: already initialized constant FFI::Pointer::NULL_HANDLE
C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/facter-2.5.0-x64-mingw32/lib/facter/util/windows
/api_types.rb:20: warning: previous definition of NULL_HANDLE was here
!! spec/fixtures/modules/rimcdm already exists and is not a symlink 

This is now tracked in https://tickets.puppetlabs.com/browse/FACT-1733, but the underlying problem is https://tickets.puppetlabs.com/browse/FACT-1542 , which will require some time to resolve.

FACT-1729 has been merged which addresses the constant redefinition issue, and is pending release next week in Facter 2.5.1.

 
 
The things that I use 'rake' and 'rspec' for are:

> rspec spec/classes/some_class_spec.rb # to run a single unit test instead of all tests

Eventually, `pdk test unit` will properly expose rspec's selector CLI.


> rake spec_prep # to update fixtures
> rake spec_standalone # to run tests without updating fixtures

I'm working on refactoring an over-sized module; that's why being able to do quick tests is important to me.

 

I'm using the version of rspec-puppet bundled with the PDK - it appears to be version 2.6.7:

PS> pdk bundle exec -- rspec --debug
...
# C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/ruby/2.1.0/gems/rspec-puppet-2.6.7/lib/rspec-puppet/monkey_patches.rb:273:in `require'
...


That's interesting. In the scientific sense. Is there a way you could share the module, or a reduced example that repro's the issue?



Cheers, David



--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ethan Brown
Principal Engineer
-- 
Reply all
Reply to author
Forward
0 new messages