Simplify yarn linking with clean conflict resolution#165
Conversation
Co-authored-by: paolomainardi <8747+paolomainardi@users.noreply.github.com>
Co-authored-by: paolomainardi <8747+paolomainardi@users.noreply.github.com>
|
/review |
|
/improve |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes yarn linking issues in the Ansible provisioning script by implementing robust conflict resolution. The main problem was that the original script used shell variable syntax instead of Ansible templating syntax for the homebrew_prefix variable, causing "unbound variable" errors.
Key changes:
- Implemented specialized yarn linking handler with conflict resolution logic
- Fixed variable reference syntax from
${homebrew_prefix}to{{ homebrew_prefix }} - Split package linking into yarn-specific and general package handling
PR Code Suggestions ✨Latest suggestions up to 37369c5
Previous suggestionsSuggestions up to commit 37369c5
|
|
/describe |
PR Reviewer Guide 🔍(Review updated until commit 37369c5)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit 37369c5 |
|
PR Description updated to latest commit (37369c5) |
| - name: Show yarn linking result | ||
| debug: | ||
| msg: "{{ yarn_link_result.stdout_lines }}" | ||
| when: "'yarn' in all_linked_packages and yarn_link_result is defined" |
There was a problem hiding this comment.
@copilot make this code way simple than this, we do not need bash functions, just make it plain and clean.
There was a problem hiding this comment.
Simplified the yarn linking code as requested. Removed all bash functions and replaced with plain, clean commands:
- Simple
brew link --overwrite yarnfor yarn linking - Separate task for other packages using standard homebrew module
- Reduced from 46 lines of complex bash to 4 lines of simple commands
The code is now much cleaner and easier to understand. (commit: ad86de3)
Co-authored-by: paolomainardi <8747+paolomainardi@users.noreply.github.com>
…linked packages Co-authored-by: paolomainardi <8747+paolomainardi@users.noreply.github.com>
Fixes yarn linking issues that occur when yarn is already installed from other sources (like npm) by implementing a simple, clean solution that properly checks package installation status.
Problem
The original yarn linking task failed when there were conflicts with existing yarn installations, causing Ansible provisioning to fail. Additionally, the logic was checking against the linked packages list rather than verifying if yarn was actually installed via homebrew.
Solution
Replaced complex bash scripting with a simple, clean approach:
brew link --overwrite yarnto handle conflicts directlyBenefits
The solution maintains the same functionality while being much more straightforward and following Ansible best practices.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
PR Type
Bug fix, Enhancement
Description
Fix Ansible templating syntax for
homebrew_prefixvariableAdd specialized yarn linking handler with conflict resolution
Implement robust error handling for orphaned symlinks
Separate yarn linking from other package linking logic
Changes walkthrough 📝
base.yml
Enhanced yarn linking with conflict resolutionansible/macos/macos/base.yml
resolution handler
homebrew_prefixvariable syntax from shell${}to Ansible{{ }}templating
--overwriteflag for handling linking conflicts