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

aws-sam-cli formula broken after latest revision #151657

Closed
4 tasks done
amancevice opened this issue Oct 18, 2023 · 10 comments
Closed
4 tasks done

aws-sam-cli formula broken after latest revision #151657

amancevice opened this issue Oct 18, 2023 · 10 comments
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age

Comments

@amancevice
Copy link
Contributor

amancevice commented Oct 18, 2023

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

https://gist.github.com/amancevice/ab5de57a8b2f6a97d33aef71353617a7

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)?

after upgrading to the latest version of the aws-sam-cli formula I found myself unable to run sam commands due to missing libraries (pyyaml and packaging)

What happened (include all command output)?

$ sam build
2023-10-18 11:37:19 Command 'build' is not configured correctly. Unable to import 'samcli.commands.build'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/aws-sam-cli/1.98.0_1/libexec/lib/python3.12/site-packages/samcli/cli/command.py", line 263, in get_command
    mod = importlib.import_module(pkg_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/homebrew/Cellar/aws-sam-cli/1.98.0_1/libexec/lib/python3.12/site-packages/samcli/commands/build/__init__.py", line 6, in <module>
    from .command import cli  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.98.0_1/libexec/lib/python3.12/site-packages/samcli/commands/build/command.py", line 11, in <module>
    from samcli.commands._utils.options import (
  File "/opt/homebrew/Cellar/aws-sam-cli/1.98.0_1/libexec/lib/python3.12/site-packages/samcli/commands/_utils/options.py", line 32, in <module>
    from samcli.commands._utils.template import TemplateNotFoundException, get_template_artifacts_format, get_template_data
  File "/opt/homebrew/Cellar/aws-sam-cli/1.98.0_1/libexec/lib/python3.12/site-packages/samcli/commands/_utils/template.py", line 9, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'
Usage: sam [OPTIONS] COMMAND [ARGS]...
Try 'sam -h' for help.

Error: No such command 'build'.

What did you expect to happen?

sam build should work.

I was able to fix this by adding the resources for pyyaml and packaging to the formula and building from source, but I'm not sure why that is necessary given that the formula depends on pyyaml and python-packaging formulae.

resource "pyyaml" do
  url "https://files.pythonhosted.org/packages/cd/e5/af35f7ea75cf72f2cd079c95ee16797de7cd71f29ea7c68ae5ce7be1eda0/PyYAML-6.0.1.tar.gz"
  sha256 "bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"
end

resource "packaging"
  url "https://files.pythonhosted.org/packages/fb/2b/9b9c33ffed44ee921d0967086d653047286054117d584f1b1a7c22ceaf7b/packaging-23.2.tar.gz"
  sha256 "048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"
end

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

brew reinstall aws-sam-cli
sam build
@amancevice amancevice added the bug Reproducible Homebrew/homebrew-core bug label Oct 18, 2023
@amancevice
Copy link
Contributor Author

Might be related to update to the python@3.12 runtime. My cfn-lint formula also appears to be broken

@dylanlan
Copy link

I also seem to be running into some unexpected broken formula installs today. The brew install command succeeds, but trying to use --version on the installed binary has similar errors:

  • sam --version: No module named 'pygments'
  • aws-sso-util --version: No module named 'six'

I'll also try building from source

@amancevice
Copy link
Contributor Author

@dylanlan I took out my resource blocks and reverted the python from python@3.12 to python@3.11 and then reinstalled with the --build-from-source flag and that seems to have worked

@cho-m
Copy link
Member

cho-m commented Oct 18, 2023

These errors often mean dependencies were migrated to python@3.12 without a revision bump so they aren't auto-updated on user machines.

The workaround is to brew reinstall corresponding dependencies (maybe brew reinstall python-packaging pyyaml).

The fix is to add revision bump to formulae so that users get correct version installed.

@cho-m
Copy link
Member

cho-m commented Oct 19, 2023

  • aws-sso-util --version: No module named 'six'

This doesn't sound right as six was revision bumped in #149418 and should have auto-updated.

Do you have some environment variables set to block upgrades? You may want to check brew info six and/or brew outdated.

@cho-m
Copy link
Member

cho-m commented Oct 19, 2023

Since #151695 and #151697 are merged, try doing an update & upgrade (and revert any workarounds/source-builds).

@dylanlan
Copy link

Looks like that fixed it for me, thanks! 🎉

That previous --build-from-source workaround had also worked for me, either downloading an older formula file, or downgrading the latest formula's depends_on "python@3.12" to 3.11

But now I've been able to install as usual without issues:

brew uninstall aws-sso-util aws-sam-cli
brew update && brew upgrade
brew install aws-sso-util aws-sam-cli
aws-sso-util --version # succeeds!
sam --version # succeeds!

@czabriskie
Copy link

I had the same issue when installing with brew. downloading the GUI installation ended up solving it for me

@cho-m
Copy link
Member

cho-m commented Oct 31, 2023

For anyone still experiencing issues, there is a brew upgrade bug that is causing revision bumps to not get installed (see PR at Homebrew/brew#16152). Until then, please use brew reinstall ... or perhaps a full brew upgrade to try to work around any Python 3.12-related import failures.

@cho-m
Copy link
Member

cho-m commented Nov 13, 2023

Closing as Homebrew/brew#16152 is merged and in release and all missing revision bumps were added. Manual intervention is still needed on broken installs (perhaps with full upgrade or brew upgrade-ing problematic formulae).

@cho-m cho-m closed this as completed Nov 13, 2023
@github-actions github-actions bot added the outdated PR was locked due to age label Dec 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2023
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
Projects
None yet
Development

No branches or pull requests

4 participants