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

Error: Could not prefetch printer provider 'cups': undefined method `include?' for nil:NilClass #44

Open
kbotnen opened this issue Feb 20, 2015 · 8 comments

Comments

@kbotnen
Copy link

kbotnen commented Feb 20, 2015

Hei,

I updated code to newest master, and Now I get the following error:

Error: Could not prefetch printer provider 'cups': undefined method `include?' for nil:NilClass

It worked without this in an earlier version.

Working version: https://gist.github.com/kbotnen/8c52f7b99e759da152a8
Errorenous version: https://gist.github.com/kbotnen/2270d4a8857d657145e6

Despite the error the printers show up on lpstat -v.

If I try to remove a printer I get more errors

==> precise-gui: Error: Could not prefetch printer provider 'cups': undefined method `include?' for nil:NilClass
==> precise-gui: Notice: /Stage[main]/App::Print/Printer[IT_Print_Ricoh]/ensure: removed
==> precise-gui: Debug: Executing '/usr/sbin/lpadmin -x IT_Print_Ricoh'
==> precise-gui: Error: /Stage[main]/App::Print/Printer[IT_Print_Ricoh]: Could not evaluate: Execution of '/usr/sbin/lpadmin -x IT_Print_Ricoh' returned 1: lpadmin: The printer or class does not exist.

It looks like it try to remove the printer even if its not there (which it doesnt know since the prefetch step failed?).

All behaviour observed in a vagrant environment, with a Ubuntu 12.04 box.

  • Kristian -
@mosen
Copy link
Owner

mosen commented Feb 20, 2015

Hiya kbotnen,
The provider automatically attempts to remove a failed printer so that you don't end up with a queue in a half working state.

I think the failure is due to the way options handling was changed (I'll check your linked files to double check). iirc I was whitelisting allowed options before, and only scraping the output for those options. I then changed it to allowing any option and now it explodes.

mosen pushed a commit that referenced this issue Feb 21, 2015
… inject instead of each.

Switch beaker testing nodesets to use other boxes from hashicorp atlas, since puppetlabs boxes seem slightly out of date.
Switch default beaker box to ubuntu precise, because that's the biggest use case outside of osx.
Ignore beaker log and junit output.
Note about switching nodesets in README.md
Remove TODOs about i18n, since puppet is supposed to set LC_LANG
Replaced Regexp matching with simple splits where possible, because a pattern match was unnecessary.
FIX: #44 Undefined method include? for nil. Not checking whether resource[:options] exists before calling include? on it.
Add more debug output for each stage of the prefetch, mostly for my own use.
Remove redundant call to lpadmin for vendor options.
@mosen
Copy link
Owner

mosen commented Feb 23, 2015

Hi kbotnen, please check with latest HEAD branch.
This specific issue should be fixed.

@kbotnen
Copy link
Author

kbotnen commented Feb 25, 2015

Hi,

It fixed the original problem on precise, but now I get a error on my trusty-box when i do vagrant up

==> trusty-gui: Notice: /Stage[main]/App::Print/File[/usr/share/ppd/uib]/ensure: created
==> trusty-gui: Notice: /Stage[main]/App::Print/File[pullprintricoh_ps]/ensure: defined content as '{md5}910cde0d9a0b270efdc5d638c87d6701'
==> trusty-gui: Notice: /Stage[main]/App::Print/Printer[pullprintricoh_ps]/ensure: created
==> trusty-gui: Error: /Stage[main]/App::Print/Printer[pullprintricoh_ps]: Could not evaluate: Execution of '/usr/sbin/lpadmin -x pullprintricoh_ps' returned 1: lpadmin: Broken pipe
==> trusty-gui:
==> trusty-gui: Notice: /Stage[main]/App::Print/Printer[pullprintricoh_ps2]/ensure: created
==> trusty-gui: Error: /Stage[main]/App::Print/Printer[pullprintricoh_ps2]: Could not evaluate: Execution of '/usr/sbin/lpadmin -x pullprintricoh_ps2' returned 1: lpadmin: Broken pipe
==> trusty-gui:

(the longer debug output is here: https://gist.github.com/kbotnen/eb016d159865acac09e6)

When I do a new vagrant provision it works:

==> trusty-gui: Notice: /Stage[main]/App::Print/Printer[pullprintricoh_ps]/ensure: created
==> trusty-gui: Notice: /Stage[main]/App::Print/Printer[pullprintricoh_ps2]/ensure: created

@mosen
Copy link
Owner

mosen commented Mar 3, 2015

Hiya kbotnen. Can you verify the status of the cups service after vagrant up? I can't see much wrong with the commands being executed.

@timdaman
Copy link

I am seeing this issue as well with the following code.

  printer { "UPS_Printer":
    ensure      => present,
    shared      => true,
    uri         => $shipping_printer,
    description => "shipping label printer",
    model       => "raw",
  }

  printer { "PT9800PCN":
    ensure      => present,
    shared      => true,
    uri         => $label_printer,
    description => "Label Printer",
    model       => "raw",
  }

I get the error.

err: Could not prefetch printer provider 'cups': undefined method `captures' for nil:NilClass
notice: /Stage[main]/Kiosk_role/Printer[UPS_Printer]/uri: defined 'uri' as 'usb://Zebra%20Technologies/ZTC%20ZP%20450-200dpi?serial=26J144900592'
notice: /Stage[main]/Kiosk_role/Printer[UPS_Printer]/description: defined 'description' as 'shipping label printer'
notice: /Stage[main]/Kiosk_role/Printer[UPS_Printer]/enabled: defined 'enabled' as 'true'
notice: /Stage[main]/Kiosk_role/Printer[UPS_Printer]/accept: defined 'accept' as 'true'
notice: /Stage[main]/Kiosk_role/Printer[PT9800PCN]/uri: defined 'uri' as 'usb://Brother/PT-9800PCN?serial=K4Z860542'
notice: /Stage[main]/Kiosk_role/Printer[PT9800PCN]/description: defined 'description' as 'Label Printer'
notice: /Stage[main]/Kiosk_role/Printer[PT9800PCN]/enabled: defined 'enabled' as 'true'
notice: /Stage[main]/Kiosk_role/Printer[PT9800PCN]/accept: defined 'accept' as 'true'

If I comment out one of the resources so I am only declaring one printer at a time the problem goes away.

I checked out master and am on commit

commit 43c9dd8fdf09430767d497bd4cd6059296a09342
Author: Mosen <[email protected]>
Date:   Sat Feb 21 23:38:02 2015 +1100

@mosen
Copy link
Owner

mosen commented Mar 24, 2015

Interesting, I'll add a test similar to your manifest and see if i can replicate it.

mosen added a commit that referenced this issue Mar 24, 2015
@mosen mosen mentioned this issue Mar 24, 2015
@mosen
Copy link
Owner

mosen commented Mar 25, 2015

The issue has been replicated and I'm working on a fix.

@mosen
Copy link
Owner

mosen commented Mar 25, 2015

@timdaman This issue is related to trying to fetch PPD options for the 'raw' model which is actually impossible, since theres no PPD.
Updating so that PPD fetching failures are skipped with message.

mosen added a commit that referenced this issue Mar 25, 2015
…row exception.

Some test fixtures werent being cleaned up after tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants