Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

MSYS/MINGW Client Support (FINNALLY Working) #127

Closed
wants to merge 13 commits into from
Closed

MSYS/MINGW Client Support (FINNALLY Working) #127

wants to merge 13 commits into from

Conversation

Merith-TK
Copy link
Contributor

@Merith-TK Merith-TK commented Jul 24, 2019

EDIT: OLD IMAGES HAVE BEEN REDUCED TO LINKS TO SAVE POST SPACE

Basically, I have made sshcode run properly on msys/mingw enviroments,

TL;DR

  • Chrome only works when using msys/cygwin based enviroments
  • sshcode only works in msys/cygwin based enviroments
  • sshcode in cmd.exe does not work yet due to how sshcode calls ssh

Summary of my edits

  • main.go > Added filepath conversion, (thanks @eargollo )
  • settings.go > added default paths for VSCode data on windows
  • sshcode.go > copied and slightly tweaked the wslPath to match a windows enviroment for accessing the C:\ drive.

TODO

  • 100% windows support: NOTE, I do not plan on implementing this for the time being, i feel like i have dont enought to make a great step towards windows support, this todo will be a log of the errors in windows
    • Some odd bug where it returns this when running with cmd.exe
    • The error appears to be sshcode not actually executing ssh on windows even if it is in %path%
      • This appears to be because of how sshcode calls the ssh command
C:\Misc\MegaSync\Code\Workspace\sshcode>go build

C:\Misc\MegaSync\Code\Workspace\sshcode>sshcode.exe --skipsync merith@192.168.0.101
2019-07-29 20:58:13 �[94mINFO�[0m       failed to stat ~/.ssh directory, disabling connection reuse feature: CreateFile ~\.ssh: The system cannot find the path specified.
2019-07-29 20:58:13 �[94mINFO�[0m       ensuring code-server is updated...
2019-07-29 20:58:13 �[31mFATAL�[0m      error: failed to update code-server:
---ssh cmd---
ssh  merith@192.168.0.101 '/usr/bin/env bash -l'
---download script---
set -euxo pipefail || exit 1

[ "$(uname -m)" != "x86_64" ] && echo "Unsupported server architecture $(uname -m). code-server only has releases for x86_64 systems." && exit 1
pkill -f ~/.cache/sshcode/sshcode-server || true
mkdir -p ~/.local/share/code-server ~\.cache\sshcode
cd ~\.cache\sshcode
curlflags="-o latest-linux"
if [ -f latest-linux ]; then
        curlflags="$curlflags -z latest-linux"
fi
curl $curlflags https://codesrv-ci.cdr.sh/latest-linux
[ -f ~/.cache/sshcode/sshcode-server ] && rm ~/.cache/sshcode/sshcode-server
ln latest-linux ~/.cache/sshcode/sshcode-server
chmod +x ~/.cache/sshcode/sshcode-server: exec: "sh": executable file not found in %PATH%

attached image is of it building and running (first working release,)
https://user-images.githubusercontent.com/10422110/61765201-ef1c0e80-ad90-11e9-87cb-b46e6dc2a909.gif

This image is of the second build working just fine, Note, yes i did have to drag the window over from the side, that is because i have two monitors, and for some reason my mouse wasnt recorded so... thats a thing
https://user-images.githubusercontent.com/10422110/62153007-8533c580-b2b8-11e9-9d2b-03e25af9bbd0.gif

8-9-2019, 1211 -7PST
This build has the sshMaster fix (i didnt bother building it again just for the example as it would take FOREVER as seen in previous pictures, and sorry for horrible quality,)
https://user-images.githubusercontent.com/10422110/62803352-094b3180-ba9f-11e9-818f-4c4b93fb60ed.gif

8-9-2019, 1308 -7PST
this build is a work in progress, some users may have to modify main.go to match their setups. otherwise sshcode --skipsync user@server /<choosen filepath> works. In the example i open /opt on the server
https://user-images.githubusercontent.com/10422110/62806173-f50b3280-baa6-11e9-8438-71a5aa6d7104.gif

8-9-2019, 1358 -7PST
Not going to upload gif, would take to long, but rsync now works provided its installed and in path
UPDATE: DESPITE WHAT TRAVIS SAYS, IT WORKS, AND BUILDS JUST FINE

@Merith-TK Merith-TK changed the title Msys support MSYS/MINGW Client Support Jul 24, 2019
@Merith-TK Merith-TK mentioned this pull request Jul 24, 2019
Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

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

If this was compiled on regular Windows, do paths like /c/.../ even work?

Chrome support needs to be tested before this can be merged.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@Merith-TK
Copy link
Contributor Author

Merith-TK commented Jul 30, 2019

If this was compiled on regular Windows, do paths like /c/.../ even work?

You were correct in questioning this,
paths like /c/Program Files (x86)/Google/Chrome/Application/chrome.exethe correct path for this wouldve been /Program Files (x86)/Google/Chrome/Application/chrome.exe

@deansheather

@Merith-TK Merith-TK changed the title MSYS/MINGW Client Support MSYS/MINGW Client Support (Working Properly) Aug 2, 2019
@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 6, 2019

@deansheather

If this was compiled on regular Windows, do paths like /c/.../ even work?

Chrome support needs to be tested before this can be merged.

Can you please close this edit? i am unable to since i had to roll back a little bit and its missing. so it just bugs our and gives a error that the commit does not exist
image

Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

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

This needs the relative path stuff from eargollo's PR so ~/file on windows corresponds to ~/file on the server instead of C:\Users\dean\file. I understand you two wanted to combine your PRs into one.

The README's "OS support" section should be updated saying how to get it working on Windows.

@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 6, 2019

@deansheather The issue i am seeing with his code, is that there is ATLEAST 100+ lines of code MISSING from his fork and the Mainstream Repo. Which means (to me atleast) i dont know if i can SAFELY add his code into mine and have it be update, which i have informed him of this and he is confused about it

Also he has yet to get back to me on that

EDIT: On local build, adding his code into mine manually does seem to work, but if i were to, for example sshcode --skipsync developer@archlinux /home, in the command status output, it gives this bash: line 0: cd: /home/developer/../../msys: No such file or directory which means its treating the root folder as its own file path arg, which i have no clue how to fix.
Another example. is persay i want to edit ~/.bashrc, it tries to open /home/developer/../../msys/home/merith/.bashrc instead of /home/developer/.bashrc
bash: line 0: cd: /home/developer/../../msys/home/merith/.bashrc

@Merith-TK Merith-TK changed the title MSYS/MINGW Client Support (Working Properly) MSYS/MINGW Client Support (Mostly Working) Aug 7, 2019
@deansheather
Copy link
Member

That needs to be fixed then, should be as simple as stripping the msys paths.

@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 7, 2019 via email

@teddy-codes
Copy link
Contributor

You should probably use deltacopy instead of rsync on windows.

@Merith-TK
Copy link
Contributor Author

@roberthmiller

You should probably use deltacopy instead of rsync on windows.

Welp this is actually my first time even touching go code and judging from the progress, im actually doing pretty okay. I dont know how to do that yet so if you want, feel free to fork and help me out!

Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

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

Tested this with Merith today on Windows 10 in a VM, using MINGW64 (from Git Bash):

  • Syncing doesn't work, even with rsync installed:
    2019-08-08 12:59:14 FATAL       error: failed to sync settings: CreateFile //Users/dean/AppData/Roaming/Code/User: The network name cannot be found.
    
  • SSH master connections don't work:
    2019-08-08 12:52:25 INFO        failed to stat ~/.ssh directory, disabling connection reuse feature: CreateFile ~\.ssh: The system cannot find the path specified.
    
  • Slash paths (i.e. /home/dean/folder) don't work, but tilde/dot paths work (i.e. ~/folder, ./folder):
    bash: line 0: cd: too many arguments
    

@deansheather
Copy link
Member

My bad, forgot Windows doesn't have sockets. SSH master connections aren't really possible on Windows except in WSL. If the OS is Windows, we should skip the SSH directory check and not attempt to open a master socket.

@teddy-codes
Copy link
Contributor

I am pretty sure that is what he was attempting to do with --skip-sync, but we would have to apply that by default on windows... Not sure if that is a good idea or not (seems fine for me).

@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 8, 2019 via email

@deansheather
Copy link
Member

@roberthmiller I wasn't referring to sync when I said master connections don't work on Windows. Sync is definitely possible on Windows, and should work with rsync once the code that determines which directory to use locally is fixed.

@Merith-TK
Copy link
Contributor Author

Updated with master ssh connection fixed, AND the

2019-08-08 12:59:14 FATAL error: failed to sync settings: CreateFile //Users/user/AppData/Roaming/Code/User: The network name cannot be found.

issue, the code that converted the windows filepath to a linux compatable format was adding a extra / where it wasnt needed

in reference to @eargollo 's

// gitbashWindowsDir translates a directory similar to `C:\Users\username\path` to `~/path` for compatibility with Git bash.
func gitbashWindowsDir(dir string) (res string) {
    res = filepath.ToSlash(dir)
    res = "/" + strings.Replace(res, ":", "", -1)
    return res
}

Specifically res = "/" + strings.Replace(res, ":", "", -1)

Copy link
Contributor Author

@Merith-TK Merith-TK left a comment

Choose a reason for hiding this comment

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

I looked, specifically to remove the annoying "requested changes" that left basically nothing

@Merith-TK
Copy link
Contributor Author

Tested this with Merith today on Windows 10 in a VM, using MINGW64 (from Git Bash):

  • Syncing doesn't work, even with rsync installed:
    2019-08-08 12:59:14 FATAL       error: failed to sync settings: CreateFile //Users/dean/AppData/Roaming/Code/User: The network name cannot be found.
    
  • SSH master connections don't work:
    2019-08-08 12:52:25 INFO        failed to stat ~/.ssh directory, disabling connection reuse feature: CreateFile ~\.ssh: The system cannot find the path specified.
    
  • Slash paths (i.e. /home/dean/folder) don't work, but tilde/dot paths work (i.e. ~/folder, ./folder):
    bash: line 0: cd: too many arguments
    

*Fixed Master SSH connection issue (Flat out Disabled if on windows)

*~/ seem to go to WINDOWS ~ for some odd reason...

*rsync is now the issue. error 11, testing possible fixes

@teddy-codes
Copy link
Contributor

teddy-codes commented Aug 9, 2019

It looks like the ~ is a problem. Is the issue here? https://github.com/cdr/sshcode/pull/127/files#diff-7ddfb3e035b42cd70649cc33393fe32cR134

Why not exclusively use user. HomeDir ?

@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 9, 2019

It looks like the ~ is a problem. Is the issue here? https://github.com/cdr/sshcode/pull/127/files#diff-7ddfb3e035b42cd70649cc33393fe32cR134

Quite possibly. Im testing to see if that entire code block, "relativeWindowsPath" is actually needed. when i disabled it. it seems to simplfy the issue from /home/user/../../<path to mingw isntall directory on windows>/<path you told it to go to> not existing,
to /<path to mingw install directory>/<path you told it to go to> not existing

My mingw install dir is C:\msys\

example sshcode developer@archlinux used to give the error (for me)
bash: line 0: cd: /home/developer/../../msys/opt/ No such file or directory

now its
bash: line 0: cd: /msys/opt: No such file or directory

EDIT for your comment @roberthmiller : I dont know yet, Im still learning this programming language, but i am working on ~/ paths, if you have a replacement for that, i would be happy to hear it (along with a gobyexample link so i can look at its reference if possible?)

@Merith-TK
Copy link
Contributor Author

rsync still does not work due to how its requesting the server's directory

2019-08-09 13:40:22 INFO       syncing settings
sending incremental file list
rsync: change_dir "/Users/zachd/AppData/Roaming/Code/User" failed: No such file or directory (2)
rsync: mkdir "/home/developer/~/.local/share/code-server/User" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(664) [Receiver=3.1.3]
2019-08-09 13:40:23 FATAL      error: failed to sync settings: failed to rsync '/Users/zachd/AppData/Roaming/Code/User/' to 'developer@archlinux:~/.local/share/code-ser
ver/User/': exit status 11

@Merith-TK
Copy link
Contributor Author

I MADE IT WORK!!! So rsync was trying to use /Users inside a mingw enviroment, which flat out doesnt work, so i tried slapping a /c to the beginning AND IT WORKS

zachd@DESKTOP-BQUQ80R MINGW64 /c/Users/zachd/Documents/Workspace2/sshcode-msys
$ ./sshcode.exe developer@archlinux workspace
2019-08-09 13:49:46 INFO        OS is windows, disabling connection reuse feature
2019-08-09 13:49:46 INFO        ensuring code-server is updated...
++ uname -m
+ '[' x86_64 '!=' x86_64 ']'
+ pkill -f /home/developer/.cache/sshcode/sshcode-server
+ true
+ mkdir -p /home/developer/.local/share/code-server /home/developer/.cache/sshcode
+ cd /home/developer/.cache/sshcode
+ curlflags='-o latest-linux'
+ '[' -f latest-linux ']'
+ curlflags='-o latest-linux -z latest-linux'
+ curl -o latest-linux -z latest-linux https://codesrv-ci.cdr.sh/latest-linux
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
+ '[' -f /home/developer/.cache/sshcode/sshcode-server ']'
+ rm /home/developer/.cache/sshcode/sshcode-server
+ ln latest-linux /home/developer/.cache/sshcode/sshcode-server
+ chmod +x /home/developer/.cache/sshcode/sshcode-server
2019-08-09 13:49:48 INFO        syncing settings
sending incremental file list

sent 226 bytes  received 14 bytes  480.00 bytes/sec
total size is 1,131,117  speedup is 4,712.99
2019-08-09 13:49:49 INFO        synced settings in 414.7449ms
2019-08-09 13:49:49 INFO        syncing extensions
sending incremental file list
./
13xforever.language-x86-64-assembly-2.2.11/
13xforever.language-x86-64-assembly-2.2.11/.vsixmanifest
13xforever.language-x86-64-assembly-2.2.11/CHANGELOG.md
13xforever.language-x86-64-assembly-2.2.11/LICENSE.txt
13xforever.language-x86-64-assembly-2.2.11/README.md
13xforever.language-x86-64-assembly-2.2.11/language-configuration.json
13xforever.language-x86-64-assembly-2.2.11/logo.png
13xforever.language-x86-64-assembly-2.2.11/package.json
13xforever.language-x86-64-assembly-2.2.11/.vscode/
13xforever.language-x86-64-assembly-2.2.11/.vscode/launch.json

I cut off there becayse it was going to take FOREVER with all my extensions

@Merith-TK Merith-TK changed the title MSYS/MINGW Client Support (Mostly Working) MSYS/MINGW Client Support (FINNALLY Working) Aug 9, 2019
@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 9, 2019

When i ran travis personally on this, i get this

 go test -v ./...
=== RUN   TestSSHCode
2019-08-09 21:07:59 INFO	ensuring code-server is updated...
sh: 25: [[: not found
Warning: Permanently added '[127.0.0.1]:9360' (RSA) to the list of known hosts.
sh: 25: [[: not found
go version go1.12.7 linux/amd64
++uname -m
+'[' x86_64 '!=' x86_64 ']'
+pkill -f /home/travis/.cache/sshcode/sshcode-server
+true
+mkdir -p /home/travis/.local/share/code-server /home/travis/.cache/sshcode
+cd /home/travis/.cache/sshcode
+curlflags='-o latest-linux'
+'[' -f latest-linux ']'
+curl -o latest-linux https://codesrv-ci.cdr.sh/latest-linux
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 90.1M  100 90.1M    0     0  82.3M      0  0:00:01  0:00:01 --:--:-- 82.4M
+'[' -f /home/travis/.cache/sshcode/sshcode-server ']'
+ln latest-linux /home/travis/.cache/sshcode/sshcode-server
+chmod +x /home/travis/.cache/sshcode/sshcode-server
2019-08-09 21:08:01 INFO	syncing settings
sh: 25: [[: not found
sending incremental file list
rsync: mkdir "/home/travis/gopath/src/go.coder.com/retry/.local/share/code-server/User" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(674) [Receiver=3.1.1]

@Merith-TK
Copy link
Contributor Author

But when i actually BUILD it. it has no issue? i built it and ran it myself. (Archlinux, windows10-mingw64) it didnt have any issues...

Copy link
Contributor Author

@Merith-TK Merith-TK left a comment

Choose a reason for hiding this comment

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

how do i make this "requested changes" GO AWAY!? IVE MADE THE CHANGES!

@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 10, 2019

@roberthmiller I looked into your suggestion, that would work for git4windows as your home directory is C:\Users\user, but it wouldnt exactly play NICE with mingw enviroments, since mingw uses /home/user instead,

Although i think i could implement the os/user import to help determine user, only issue with that is on windows it flat out gives your user in this format PACNAME\username

@deansheather
Copy link
Member

If you just need the home directory path, use os.UserHomeDir().

@Merith-TK
Copy link
Contributor Author

That's fine for git4win (uses your c:\users\Username as home) , but it still reads Mingw as windows when Mingw uses /home/username

GOOS on git4win and Mingw, are detected as WINDOWS,

But I shall check further, I still and trying to figure out just WHY Travis is failing despite the program compiling and running without any issue on actual systems (hell, it still works on my android phone. Chrome doesn't work but every thing else does as expected)

@Merith-TK
Copy link
Contributor Author

Merith-TK commented Aug 14, 2019

FROM THIS POINT ON, THE PUSHES ARE JUST GOING TO BE SHILLED TO TRY AND GET IT TROUGH THE BLOODY PIPELINE WHILE ALSO NOT BREAKING SUPPORT FOR SYSTEMS

@Merith-TK
Copy link
Contributor Author

closing this to make a CLEANER PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants