Skip to content

CHEF-37570: Add Chef Workstation 26 path support - #275

Merged
nikhil2611 merged 3 commits into
mainfrom
nikhil/CHEF-37570-WS26-path-support
Aug 13, 2026
Merged

nikhil2611 merged 3 commits into
mainfrom
nikhil/CHEF-37570-WS26-path-support

Conversation

@nikhil2611

@nikhil2611 nikhil2611 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

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

    • Checks CW26 path first: C:\hab\bin\cookstyle.bat
    • Falls back to CW25 path: C:\opscode\chef-workstation\bin\cookstyle.bat
    • Logs which version path is being used for troubleshooting
  • Unix/macOS/Linux: Uses /usr/local/bin/cookstyle

    • Works for both CW25 and CW26 via symlinks
    • CW25: /usr/local/bin/cookstyle → /opt/chef-workstation/bin/cookstyle
    • CW26: /usr/local/bin/cookstyle → habitat package wrapper

README.md

  • Added documentation about CW26 support
  • Clarified automatic detection behavior

Testing

  • ✅ TypeScript compilation (0 errors)
  • ✅ Path logic verified for both platforms
  • ✅ Backward compatible with CW25

Compatibility

Platform CW25 CW26
Windows ✅ Fallback path ✅ Primary path
Unix/macOS/Linux ✅ Symlink works ✅ Symlink works

Related Issues

Notes

  • Users with custom installations can still override via rubocop.path setting
  • No breaking changes - fully backward compatible
  • Console logging helps users understand which version is detected

- 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>
@nikhil2611
nikhil2611 requested review from a team as code owners August 11, 2026 09:58
Copilot AI lite review requested due to automatic review settings August 11, 2026 09:58
@nikhil2611
nikhil2611 requested review from a team as code owners August 11, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread extension.ts Resolved
Comment thread extension.ts Resolved
- 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>
Copilot AI review requested due to automatic review settings August 11, 2026 10:22
@nikhil2611

Copy link
Copy Markdown
Contributor Author

Response to Copilot feedback

Regarding path checking and logging:

I've simplified the code to match the original extension behavior:

  • No additional logging needed - The path is set, and if it doesn't exist, checkCookstyleVersion() will detect and show a proper error: "Chef extension could not detect Cookstyle at: [path]..."

  • Same behavior as before - The original extension didn't check if paths exist either. It set the path and let the version check handle errors gracefully.

For Unix/macOS/Linux:

  • CW25 creates /usr/local/bin/cookstyle symlink (verified on my system) ✅
  • CW26 creates /usr/local/bin/cookstyle symlink ✅
  • No fallback needed - single path works for both versions

This keeps the code simple while maintaining full backward compatibility with both CW25 and CW26.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/cookstyle to /usr/local/bin/cookstyle can be a regression when the /usr/local/bin symlink 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/cookstyle is 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 rubocopPath silently. 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>
Copilot AI review requested due to automatic review settings August 11, 2026 14:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/cookstyle as 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.

@nikhil2611
nikhil2611 merged commit ac34073 into main Aug 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants