Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it work under Windows #30

Open
p3r7 opened this issue Mar 19, 2016 · 11 comments
Open

Make it work under Windows #30

p3r7 opened this issue Mar 19, 2016 · 11 comments

Comments

@p3r7
Copy link

p3r7 commented Mar 19, 2016

This mode works great, except it doesn't play nice under Microsoft Windows, even when a cygwin installation as been performed.

It would be great to make it work, as both Emacs and Vagrant are pretty much OS-agnostic solutions.

I'd be ready to give a hand, with my limited knowledge.

@ryanprior
Copy link
Collaborator

Thank you for offering, @p3r7. What can you tell me about how vagrant-tramp works under Windows?

If you're in a shell:

  • does vagrant global-status work?
  • does vagrant ssh in a folder associated with a running Vagrant machine work?
  • does the bin/vagrant-tramp-ssh script work? (to invoke it, you use the name of a folder associated with a running Vagrant machine. So for example, if one such folder is /home/ryan/scratch then vagrant-tramp-ssh scratch should log me into that machine.

I'm looking forward to getting this working on Windows. It would be nice to try it with the new Bash for Windows as soon as possible, too.

@nverno
Copy link

nverno commented Apr 20, 2016

I just tried installing from melpa using windows and it fails creating the autoloads. It looks like the problem is executable-find not finding the shell script: abbreviated backtrace

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
replace-regexp-in-string("(\*)"" "\1\1\"" nil)
shell-quote-argument(nil)
byte-code("[removed]" [load-file-name buffer-file-name shell-quote-argument executable-find file-name-directory "bin/vagrant-tramp-ssh"] 4)
....

Simply removing the executable-find seems to work fine, is it necessary since there is only the one file in /bin anyhow?

@ryanprior
Copy link
Collaborator

No, that executable-find doesn't seem necessary. I don't remember including it for any particular reason, so maybe I just threw it in there all like "oh yeah I'm totally finding an executable hurr durr"

@nverno
Copy link

nverno commented Apr 21, 2016

Removing that makes the melpa install work fine, but I still couldn't get the script to work correctly using mingw port of bash -- not sure why exactly I was going to try to isolate the problem tomorrow and maybe implement in elisp so there would be no portability issues. All the command line vagrant stuff you mention above works the same on windows as far as I can tell.

@ryanprior
Copy link
Collaborator

Tramp is rather inflexible in how it invokes the connection program. If we use vagrant ssh without a wrapper, it needs to be passed a hash id of a machine, which means that we would have to offer hash IDs as completions in Emacs. Which is not a great experience.

There are three ways I could think of to get around that:

  1. use a wrapper script, which as you point out carries potential portability issues
  2. submit a patch to Vagrant allowing people to globally identify a machine in human-readable format, similar to the scheme vagrant-tramp uses now.
  3. submit a patch to Tramp which introduces an optional function that transforms the Tramp hostname to arguments for the connection program

I went with the first option since it's the one I could implement for myself without needing to get agreement from the Vagrant or Emacs upstream communities.

In the long term I think that either 2 or 3 are ultimately better options for portability and simplicity of vagrant-tramp and similar tools. In the short term, I'm interested to see if we can find a way to make the wrapper script work on Windows.

What do you think?

@nverno
Copy link

nverno commented Apr 21, 2016

Yea, having a solution without an additional wrapper script sounds best, but I can't offer a solution. I will try to look closely at the code and learn me some elisp when I can. I had to spend a while to understand your awk script, so I am not likely to be useful in improving your bash script. Perhaps, if you want the wrapper to work on windows as well there could be a parallel batch script? I don't know, if I come up with something I will post it.

@ryanprior
Copy link
Collaborator

Note that there's a new version of the wrapper script that I introduced in #31. The previous script gave problems on many platforms, not just Windows.

@p3r7
Copy link
Author

p3r7 commented Apr 24, 2016

I've just tested the script vagrant-tramp-ssh under cygwin bash, providing my runing VM name as an argument, and the script works fine.

@ryanprior
Copy link
Collaborator

@p3r7 thanks for testing that out. A couple more questions for you:

Is anything printed to the *Messages* buffer when you try to use the vagrant method to find a file?

Are you able to use Alt-xvagrant-tramp-term to launch a terminal session?

@p3r7
Copy link
Author

p3r7 commented Apr 28, 2016

I'm very pleased to discover that M-x term works flawlessly on w32 emacs 25.0.92.1. I didn't know that! M-x vagrant-tramp-term works as well!

Please note that I have a setup where cygwin's bin folders get added to emacs' PATH at startup, so that might be why I can launch a term window (see https://github.com/p3r7/emacs.d/blob/master/init/components/init-cygwin-integration.el for full implementation).

I don't have completion when I M-x find-file /vagrant:, but that might be due to a conflict with cygwin-mount plugin.

When I explicitely do a M-x find-file /vagrant:trusty32:/, a buffer /vagrant:root@trusty32:/ opens up, but it prints :
Tramp: Sending command ‘"c:/Users/jordan.besly/AppData/Roaming/.emacs.d/plugins/vagrant-tramp/bin/vagrant-tramp-ssh" trusty32 && exit || exit’
and a message telling that the OS failed to find any valid executable.
No additional information is available in the *Messages* buffer.

Indeed, MS Windows searches for files with extensions sur as .exe, .bat ...

I guess we'd need a windows equivalent to script vagrant-tramp-ssh, or a wrapper around it that would call it via cygwin's bash.

@marsam
Copy link

marsam commented Apr 30, 2016

Hi:
I had problems with the lock system of vagrant commands, so my solution was to write the ssh configuration of vagrant machines into a separate ssh_config and use ssh: https://github.com/emacs-pe/vagrant.el/blob/c87ea8/vagrant.el#L290-L302

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

No branches or pull requests

4 participants