Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

allow coder login for WSL#446

Merged
deansheather merged 4 commits intocoder:mainfromarminaaki:main
Oct 6, 2021
Merged

Conversation

arminaaki
Copy link
Contributor

Issue

coder login fails to open user's browser while running fromWindows Subsystem for Linux.

$ coder login <coder_url>/usr/bin/xdg-open: 869: www-browser: not found/usr/bin/xdg-open: 869: links2: not found/usr/bin/xdg-open: 869: elinks: not found/usr/bin/xdg-open: 869: links: not found/usr/bin/xdg-open: 869: lynx: not found/usr/bin/xdg-open: 869: w3m: not found

Changes

  • allowcoder login to work while running from WSL.
  • Detect if running in WSL by identifyingmicrosoft in/proc/version file.
$ cat /proc/versionLinux version ....-Microsoft (Microsoft@Microsoft.com) (gcc version ... (GCC) ) #...-Microsoft ....

Co-authored-by: Armin <arminaaki@users.noreply.github.com>
Copy link
Contributor

@greyscaledgreyscaled left a comment

Choose a reason for hiding this comment

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

Code looks great to me, appreciate the extra log! Thanks for the contribution! 👍🏻

@@ -66,7 +69,8 @@ func login(cmd *cobra.Command, workspaceURL *url.URL) error {
q.Add("show_token", "true")
authURL.RawQuery = q.Encode()

if err := browser.OpenURL(authURL.String()); err != nil {
if err := openURL(authURL.String()); err != nil {
clog.LogWarn(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the additional warning log 👍🏻

arminaaki reacted with hooray emoji
@greyscaledgreyscaled added the enhancementNew feature or request labelSep 24, 2021

// isWSL determines if coder-cli is running within Windows Subsystem for Linux
func isWSL() (bool, error) {
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like we should make use of constants that are already defined:

https://github.com/cdr/coder-cli/blob/582f213d183be7135e2fcf0e6f839ea320e6c2f3/internal/cmd/update.go#L37

we should addgoosDarwin as a const as well

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thank you for your review. Updated!

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This may resolve →#448

if wsl {
cmd = "cmd.exe"
args = []string{"/c", "start"}
url = strings.Replace(url, "&", "^&", -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
url=strings.Replace(url,"&","^&",-1)
url=strings.ReplaceAll(url,"&","^&")

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done!

var cmd string
var args []string

wsl, err := isWSL()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is good, but I do wonder whether we could propose this upstream to pkg/browser

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thank you for the review. I agree, this work should ideally be part of upstreampkg/browser. But Thoughts on moving forward with the work for Coder until I have the patch ready for upstream?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think it makes sense to make this change now for sure! No objection to it :)

Thanks for your contribution!

@deansheatherdeansheather merged commit6640696 intocoder:mainOct 6, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@jawnsyjawnsyjawnsy left review comments

@greyscaledgreyscaledgreyscaled approved these changes

Assignees

@jawnsyjawnsy

Labels
enhancementNew feature or request
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@arminaaki@jawnsy@greyscaled@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp