Skip to content

Conversation

@gajeshbhat
Copy link

@gajeshbhat gajeshbhat commented Aug 23, 2025

Description

Fixes the issue where jf config add hangs indefinitely on WSL2 when using "Web Login" authentication method.

Problem

In WSL2 environments, the browser.OpenURL() function fails because there's no default browser configured. The original code treated this as a fatal error and exited immediately, causing the CLI to appear to hang since users never saw the authentication URL.

Solution

  • Always display the authentication URL prominently before attempting browser opening
  • Continue on browser failure instead of exiting, allowing manual authentication
  • Add WSL2-specific environment variable support:
    • BROWSER=none - Disables automatic browser opening
    • JFROG_CLI_BROWSER_COMMAND - Allows custom browser command (e.g., Windows browser from WSL2)
  • Provide clear user guidance with WSL2-specific instructions

Changes

  • Modified utils/coreutils/coreconsts.go to add browser command environment variable
  • Enhanced artifactory/utils/weblogin.go with improved browser opening logic
  • Added comprehensive unit tests in artifactory/utils/weblogin_test.go

Testing

  • Added unit tests covering all new functionality
  • Tested environment variable support
  • Verified graceful error handling scenarios

WSL2 Usage Examples

# Disable browser opening
export BROWSER=none
jf config add my-server --url=https://company.jfrog.io

# Use Windows Chrome from WSL2
export JFROG_CLI_BROWSER_COMMAND="/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
jf config add my-server --url=https://company.jfrog.io

Closes

Fixes jfrog/jfrog-cli#3008

Files Summary:

  • 2 files modified and 1 new unit test file added
  • Backward compatible - existing functionality unchanged
  • WSL2-specific improvements without affecting other platforms
  • Comprehensive test coverage for new functionality

- Add graceful browser opening fallback for WSL2 environments
- Display authentication URL prominently when browser fails to open
- Add support for BROWSER and JFROG_CLI_BROWSER_COMMAND environment variables
- Continue to token polling instead of exiting on browser failure
- Add comprehensive unit tests for new browser handling logic

Fixes #3008
@github-actions
Copy link
Contributor

github-actions bot commented Aug 23, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@gajeshbhat
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@gajeshbhat
Copy link
Author

recheck

@gajeshbhat gajeshbhat closed this Sep 4, 2025
@gajeshbhat gajeshbhat reopened this Sep 4, 2025
@gajeshbhat
Copy link
Author

Closing this Pull request for now. I think the workaround should be sufficient for now.

@gajeshbhat gajeshbhat closed this Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jf config add hangs on WSL2

1 participant