Repository navigation
CHEF-37570: Add Chef Workstation 26 path support - #275
Conversation
- Windows: Check CW26 path (C:\hab\bin\cookstyle.bat) first, fall back to CW25 (C:\opscode\chef-workstation\bin\cookstyle.bat) - Unix/macOS/Linux: Use /usr/local/bin/cookstyle (works for both CW25 and CW26 via symlinks) - Add console logging to show which version path is being used - Update README with CW26 support information This ensures the extension works seamlessly with both Chef Workstation 25 (omnibus-based) and Chef Workstation 26 (habitat-based) installations without requiring manual configuration. Fixes: CHEF-37570 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: nikhil2611 <ngupta@progress.com>
There was a problem hiding this comment.
Pull request overview
Adds support for Chef Workstation 26’s habitat-based installation layout by updating default Cookstyle path resolution (notably on Windows), and documents the new behavior for users of the VS Code Chef extension.
Changes:
- Update Windows default Cookstyle resolution to prefer the CW26 habitat path and fall back to the CW25 omnibus path.
- Change the non-Windows default Cookstyle path to
/usr/local/bin/cookstyle. - Document CW26 support and the auto-detection behavior in the README.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| README.md | Documents CW26 support and the new default path behavior per platform. |
| extension.ts | Implements platform-specific Cookstyle path selection logic (CW26-first on Windows; new default on Unix/macOS/Linux). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Remove console logs from Windows path detection (keep it simple like before) - Let checkCookstyleVersion() handle error messaging if path doesn't exist - Maintains same behavior as original code: set path, try to use it, fail gracefully - Reduces code complexity while keeping full functionality Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: nikhil2611 <ngupta@progress.com>
Response to Copilot feedbackRegarding path checking and logging: I've simplified the code to match the original extension behavior:
For Unix/macOS/Linux:
This keeps the code simple while maintaining full backward compatibility with both CW25 and CW26. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
extension.ts:36
- Switching the default Unix/macOS/Linux path from
/opt/chef-workstation/bin/cookstyleto/usr/local/bin/cookstylecan be a regression when the/usr/local/binsymlink isn't present (e.g., non-standard installs). To maintain the stated CW25 backward compatibility, consider falling back to the old omnibus path when/usr/local/bin/cookstyleis missing.
// Unix/macOS/Linux: /usr/local/bin/cookstyle works for both CW25 and CW26
// CW25 creates symlink: /usr/local/bin/cookstyle -> /opt/chef-workstation/bin/cookstyle
// CW26 creates symlink: /usr/local/bin/cookstyle -> habitat package wrapper
rubocopPath = "/usr/local/bin/cookstyle";
extension.ts:31
- The PR description says the extension logs which Chef Workstation path/version is being used, but this branch selection currently sets
rubocopPathsilently. Adding a log here would make troubleshooting match the described behavior.
if (fs.existsSync(cw26Path)) {
rubocopPath = cw26Path;
} else {
rubocopPath = cw25Path;
}
Implement array-based path detection following kitchen-chef-enterprise pattern to properly support Chef Workstation 26 (habitat-based) alongside CW25 (omnibus-based) across Windows, macOS, and Linux. Key changes: - Check multiple candidate paths in priority order (CW26 first, CW25 fallback) - Platform-specific path arrays: - Windows: C:\hab\bin, C:\opscode\chef-workstation\bin - macOS: /usr/local/bin, /opt/chef-workstation/bin - Linux: /usr/bin, /usr/local/bin, /opt/chef-workstation/bin - Loop through candidates, break on first existing path - Maintain backward compatibility: CW25 users unaffected Fixes: - CW26 detection on all platforms (was using wrong/missing paths) - Linux path issue: Ubuntu uses /usr/bin/cookstyle, not /usr/local/bin Verified on: - macOS + CW26 (8.7.8): Works via /usr/local/bin/cookstyle symlink - Simulated all platform/version combinations: No regressions Pattern based on: https://github.com/chef/kitchen-chef-enterprise/blob/main/lib/kitchen/provisioner/chef_base.rb#L436 Signed-off-by: nikhil2611 <ngupta@progress.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (4)
extension.ts:47
- The inline comments for the Linux/Unix candidate paths describe them as CW26-only symlinks, but these locations can be used for either CW25 or CW26 depending on how Cookstyle is installed/symlinked. Updating the comments avoids encoding incorrect assumptions.
candidatePaths = [
"/usr/bin/cookstyle", // CW26 symlink (common on Linux)
"/usr/local/bin/cookstyle", // CW26 symlink (some distros)
"/opt/chef-workstation/bin/cookstyle" // CW25 omnibus direct path
extension.ts:64
- The PR description says the extension logs which Chef Workstation path/version was detected, but the auto-detection branch currently does not log the selected Cookstyle path. This makes troubleshooting harder when multiple candidate paths exist.
// Fallback to first candidate if none found
// checkCookstyleVersion() will handle the error and show appropriate warning
if (!rubocopPath) {
rubocopPath = candidatePaths[0];
}
extension.ts:41
- The inline comment labels
/usr/local/bin/cookstyleas a CW26-only symlink, but per the README/PR intent this path is intended to work for both CW25 and CW26 (via symlink). The comment is misleading during maintenance/debugging.
This issue also appears on line 44 of the same file.
candidatePaths = [
"/usr/local/bin/cookstyle", // CW26 symlink (habitat wrapper)
"/opt/chef-workstation/bin/cookstyle" // CW25 omnibus direct path
];
README.md:22
- This README bullet says Unix/macOS/Linux uses only
/usr/local/bin/cookstyle, but the implementation also checks/usr/bin/cookstyle(Linux) and falls back to/opt/chef-workstation/bin/cookstyle. The docs should match the actual detection order/paths.
* **Requirements**: This extension requires [Chef Workstation](https://docs.chef.io/workstation/install/) installed with [Cookstyle](https://github.com/chef/cookstyle) **8.6.10 or later**. For example, Chef Workstation 26.1.0 includes Cookstyle 8.7.6. Linting should "just work" on Windows, macOS, and Linux.
* **Chef Workstation 26 Support**: The extension automatically detects both Chef Workstation 25 and 26 installations. On Windows, it checks for CW26 (`C:\hab\bin\cookstyle.bat`) first, then falls back to CW25 (`C:\opscode\chef-workstation\bin\cookstyle.bat`). On Unix/macOS/Linux, it uses `/usr/local/bin/cookstyle` which works for both versions.
* If Chef Workstation is not installed in the default location, you can set the executable path by setting ```{ "rubocop.path": "c:\\path\\to\\cookstyle.bat"}``` in user/workspace settings.
Summary
Adds automatic detection and support for Chef Workstation 26 (habitat-based) installations while maintaining backward compatibility with Chef Workstation 25 (omnibus-based).
Changes
extension.ts
Windows: Implements path fallback logic
C:\hab\bin\cookstyle.batC:\opscode\chef-workstation\bin\cookstyle.batUnix/macOS/Linux: Uses
/usr/local/bin/cookstyle/usr/local/bin/cookstyle→/opt/chef-workstation/bin/cookstyle/usr/local/bin/cookstyle→ habitat package wrapperREADME.md
Testing
Compatibility
Related Issues
Notes
rubocop.pathsetting