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

Ansible AttributeError: module 'bcrypt' has no attribute '__about__' #160525

Closed
4 tasks done
fmunteanu opened this issue Jan 21, 2024 · 13 comments
Closed
4 tasks done

Ansible AttributeError: module 'bcrypt' has no attribute '__about__' #160525

fmunteanu opened this issue Jan 21, 2024 · 13 comments
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age upstream issue An upstream issue report is needed

Comments

@fmunteanu
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config
HOMEBREW_VERSION: 4.2.4-76-g9b4427d
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9b4427d9d81ae3d7bcfe82882f475a1f8fff2aa9
Last commit: 9 hours ago
Core tap HEAD: 86eb2ffefe6bc27ad9dcdd423c948ac541965f81
Core tap last commit: 2 hours ago
Core tap JSON: 21 Jan 04:42 UTC
Core cask tap HEAD: 48836a5452ffd4dcf81cb1e50a6e15264f0fcefd
Core cask tap last commit: 28 minutes ago
Core cask tap JSON: 21 Jan 04:42 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 24
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.1.4 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 24-core 64-bit westmere
Clang: 14.0.0 build 1400
Git: 2.43.0 => /usr/local/bin/git
Curl: 8.1.2 => /usr/bin/curl
macOS: 12.7.2-x86_64
CLT: 14.2.0.0.1.1668646533
Xcode: N/A

$ brew doctor
Your system is ready to brew.

Verification

  • My "brew doctor output" says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

There is an issue with ansible bcrypt.py handler, running this simple playbook to generate a bcrypt password:

- name: Test
  hosts: apollo
  become: true
  gather_facts: true
  vars:
    foo: bar
  tasks:
    - name: Debug hashed foo
      ansible.builtin.debug:
        var: foo | password_hash('bcrypt')

What happened (include all command output)?

Produces this warning:

TASK [Gathering Facts] *********
ok: [apollo]
(trapped) error reading bcrypt version
Traceback (most recent call last):
  File "/usr/local/Cellar/ansible/9.1.0/libexec/lib/python3.12/site-packages/passlib/handlers/bcrypt.py", line 620, in _load_backend_mixin
    version = _bcrypt.__about__.__version__
              ^^^^^^^^^^^^^^^^^
AttributeError: module 'bcrypt' has no attribute '__about__'

What did you expect to happen?

No warning should be generated, however, the password is successfully generated:

TASK [Debug hashed foo] *********
ok: [apollo] =>
  foo | password_hash('bcrypt'): $2b$12$mnIC9P5s9j.O7PX1DfjOtOpNuysrj1aC.V3tnTHxaxKJgJmWStFgG

Step-by-step reproduction instructions (by running brew commands)

brew install ansible
@fmunteanu fmunteanu added the bug Reproducible Homebrew/homebrew-core bug label Jan 21, 2024
@fmunteanu
Copy link
Author

See pyca/bcrypt#684, upgrading to bcrypt 4.1.2 seems to address the issue.

@cho-m cho-m added the upstream issue An upstream issue report is needed label Jan 21, 2024
@fmunteanu
Copy link
Author

@cho-m should I report this issue to Ansible developers?

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Feb 23, 2024
@fmunteanu
Copy link
Author

Any update on this issue?

@github-actions github-actions bot removed the stale No recent activity label Feb 23, 2024
@ZhongRuoyu
Copy link
Member

ansible 9.2.0 should have bcrypt 4.1.2 already:

resource "bcrypt" do
url "https://files.pythonhosted.org/packages/72/07/6a6f2047a9dc9d012b7b977e4041d37d078b76b44b7ee4daf331c1e6fb35/bcrypt-4.1.2.tar.gz"
sha256 "33313a1200a3ae90b75587ceac502b048b840fc69e7f7a0905b5f87fac7a1258"
end

Can you do brew upgrade and try again?

@fmunteanu
Copy link
Author

The warning still shows with 9.2.0:

Friday 23 February 2024  16:21:52 -0500 (0:00:02.833)       0:14:55.827 *******
(trapped) error reading bcrypt version
Traceback (most recent call last):
  File "/usr/local/Cellar/ansible/9.2.0/libexec/lib/python3.12/site-packages/passlib/handlers/bcrypt.py", line 620, in _load_backend_mixin
    version = _bcrypt.__about__.__version__
              ^^^^^^^^^^^^^^^^^
AttributeError: module 'bcrypt' has no attribute '__about__'

@Bo98
Copy link
Member

Bo98 commented Feb 23, 2024

The warning is from passlib but passlib hasn't received an update in over 3 years and is currently seen to be abandonware, leading to some fork attempts: https://pypi.org/project/passlib-fork.

There's been some discussions upstream about it: ansible/ansible#81949.

We're unlikely to downgrade bcrypt, as using an old version of a security-focussed library is worse than silencing a warning.

This is a wider discussion than just Homebrew: passlib in its current form will partially break in Python 3.13 for other reasons.

@fmunteanu
Copy link
Author

fmunteanu commented Feb 23, 2024

Sure, on my side, I don’t really care about that warning, as it does not break any functionality for me. I simply wanted to inform you about the issue.

Edit: just read the second part of your comment, that would be an issue. Is there an alternative or planned fix for passlib in Python 3.13? Running in 3.12 now.

@Bo98
Copy link
Member

Bo98 commented Feb 23, 2024

Is there an alternative or fix?

There's been some effort to reach out to the original developer: https://foss.heptapod.net/python-libs/passlib/-/issues/187

It's got enough attention I'm not too concerned: the situation will improve in some form as there's plenty of people showing interest to sort things out, but it's currently unknown exactly how yet.

@fmunteanu
Copy link
Author

Thank you for the useful information.

@cho-m
Copy link
Member

cho-m commented Feb 24, 2024

May just close this issue as "not planned" as there isn't really an ideal actionable task for Homebrew right now.

The best we can do is just drop passlib support totally by removing it from getting added to venv:

"passlib", "pexpect", "proxmoxer", "pysphere3", "python-consul",

But the end result is the same as current situation as the feature will remain unusable.

Corresponding upstream projects will need to take the step forward before anything can be done in Homebrew.

For example, if Ansible adds support for alternatives to passlib, e.g. some partial changes in ansible/ansible#82665 but haven't check what extent it replaces reliance on passlib.

@fmunteanu
Copy link
Author

Makes sense, I would personally not remove passlib.

@cho-m
Copy link
Member

cho-m commented Feb 24, 2024

Closing for now. Can revisit if any upstream activity that allows us to switch libs or backport commits.

@cho-m cho-m closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2024
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 26, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age upstream issue An upstream issue report is needed
Projects
None yet
Development

No branches or pull requests

4 participants