egalpin / apt-vim

Fully-automated, Cross-platform Plugin Manager for Vim
MIT License
478 stars 35 forks source link

"cross-platform"? #42

Open zwhitchcox opened 8 years ago

zwhitchcox commented 8 years ago

In the readme, you say you're cross platform, yet, I see no instructions for installation on any system but unix.

egalpin commented 8 years ago

The instructions in the readme work for both nix and Mac OSX (...nix). As for Windows, I was assuming that someone using Vim on Windows would also be using Cygwin or a similar terminal emulator. This assumption, however, could easily be wrong.

Could you elaborate on your setup? If you are having trouble installing, I'd love to know the tools/platform etc. that you're using so that I can try to improve apt-vim. Thanks!

zwhitchcox commented 8 years ago

Hey, thanks for your quick response...I'm using git bash, and this is the error I get

./install.sh: eval: line 28: syntax error near unexpected token `('
./install.sh: eval: line 28: `export PATH=/k//bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/k/bin:/c/oracle/product/12.1.0/client_1/bin:/c/Program Files (x86)/CA/DCS/CAWIN:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/System32/WindowsPowerShell/v1.0:/c/windows/esisoft:/c/Program Files (x86)/IBM/Personal Communications:/c/Program Files (x86)/IBM/Trace Facility:/c/Program Files/Internet Explorer:/c/SQLLIB/BIN:/c/SQLLIB/FUNCTION:/c/Program Files/Common Files/ThinPrint:/c/Programs/DCPS/npm:/c/Programs/DCPS/Git/cmd:/c/Programs/DCPS/PostgreSQL/9.4/bin:/cmd:/c/PROGRAMS/DCPS/NODEJS:%USERPROFILE%/.dnx/bin:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/oracle/product/12.1.0/client_1/bin:/c/Program Files (x86)/CA/DCS/CAWIN:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/System32/WindowsPowerShell/v1.0:/c/windows/esisoft:/c/Program Files (x86)/IBM/Personal Communications:/c/Program Files (x86)/IBM/Trace Facility:/c/Program Files/Internet Explorer:/c/SQLLIB/BIN:/c/SQLLIB/FUNCTION:/c/Program Files/Common Files/ThinPrint:/c/Programs/DCPS/npm:/c/Programs/DCPS/Git/cmd:/c/Programs/DCPS/PostgreSQL/9.4/bin:/cmd:/c/PROGRAMS/DCPS/NODEJS:%USERPROFILE%/.dnx/bin:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Users/276655/AppData/Roaming/npm:/c/Program Files/Sublime Text 3:/usr/bin/vendor_perl:/usr/bin/core_perl:/k//bin:/k//.npm/bin:/k//.vimpkg/bin'

Which I'm guessing has something to do with the parentheses in Program Files (x86) not being escaped, plus the spaces

zwhitchcox commented 8 years ago

I have not tried cygwin though

zwhitchcox commented 8 years ago

Ok, I put path in a string, , but now, I'm getting a new error

./install.sh: line 37: printf: `U': invalid format character
== Added apt-vim PATH to '~/.bashrc'
./install.sh: line 37: printf: `U': invalid format character
== Added apt-vim PATH to '~/.bash_profile'
apt-vim setup starting
There's already an apt-vim root directory at K:\.vimpkg

Are you sure you want to continue? [y|N]:  Traceback (most recent call last):
  File "<stdin>", line 12, in <module>
  File "./apt-vim", line 553, in first_run
    ASSUME_YES=False)
  File "./apt-vim", line 52, in report_fail
    if user_confirm(confirm_msg, ASSUME_YES=ASSUME_YES):
  File "./apt-vim", line 65, in user_confirm
    user_choice = input(msg).strip().lower()
  File "./apt-vim", line 845, in stdin_prompt
    sys.stdin = open('/dev/tty')
IOError: [Errno 2] No such file or directory: '/dev/tty'

== Error:
   Installation failed.
egalpin commented 8 years ago

Awesome, thanks for the info. You're spot on; the install script definitely doesn't take into account escaping Windows' PATH.

RE your new error, this also makes sense. When trying to install via install.sh, there was a previous bug in which user input was ignored entirely by python launched via install.sh. To resolve the bug, I used that little hacky trick: sys.stdin = open('/dev/tty'). Unfortunately, that's very Windows-unfriendly.

These are a few things that need to get fixed; thanks for your help in identifying them. To get you off the ground sooner rather than later, you might try the manual installation? Sorry about that. Let me know if you get stuck during manual installation, I'd be happy to try to help

zwhitchcox commented 8 years ago

Idk which character it's referring to, but this is my path

export PATH='/k//bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/k/bin:/c/oracle/product/12.1.0/client_1/bin:/c/Program Files (x86)/CA/DCS/CAWIN:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/System32/WindowsPowerShell/v1.0:/c/windows/esisoft:/c/Program Files (x86)/IBM/Personal Communications:/c/Program Files (x86)/IBM/Trace Facility:/c/Program Files/Internet Explorer:/c/SQLLIB/BIN:/c/SQLLIB/FUNCTION:/c/Program Files/Common Files/ThinPrint:/c/Programs/DCPS/npm:/c/Programs/DCPS/Git/cmd:/c/Programs/DCPS/PostgreSQL/9.4/bin:/cmd:/c/PROGRAMS/DCPS/NODEJS:%USERPROFILE%/.dnx/bin:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/oracle/product/12.1.0/client_1/bin:/c/Program Files (x86)/CA/DCS/CAWIN:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/System32/WindowsPowerShell/v1.0:/c/windows/esisoft:/c/Program Files (x86)/IBM/Personal Communications:/c/Program Files (x86)/IBM/Trace Facility:/c/Program Files/Internet Explorer:/c/SQLLIB/BIN:/c/SQLLIB/FUNCTION:/c/Program Files/Common Files/ThinPrint:/c/Programs/DCPS/npm:/c/Programs/DCPS/Git/cmd:/c/Programs/DCPS/PostgreSQL/9.4/bin:/cmd:/c/PROGRAMS/DCPS/NODEJS:%USERPROFILE%/.dnx/bin:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Users/276655/AppData/Roaming/npm:/c/Program Files/Sublime Text 3:/usr/bin/vendor_perl:/usr/bin/core_perl:/k//bin:/k//.npm/bin':/k//.vimpkg/bin
zwhitchcox commented 8 years ago

This is the line that fails

      printf "\n$bin_string\n" >> "$HOME/.$rc"
zwhitchcox commented 8 years ago

Yeah, I tried the manual installation, but had a lot of trouble with that as well

zwhitchcox commented 8 years ago

running ./apt-vim init doesn't do anything. It just sits there perpetually. Doesn't even give an error message.

zwhitchcox commented 8 years ago

I think that's because I can't run python in git bash though

zwhitchcox commented 8 years ago

And running in powershell gives me this error

Valid modes: ['add', 'delete', 'init', 'install', 'list', 'remove', 'update']

apt-vim> py.exe .\apt-vim init
Traceback (most recent call last):
  File ".\apt-vim", line 856, in <module>
    apt_vim.main()
  File ".\apt-vim", line 832, in main
    self.process_cmd_args()
  File ".\apt-vim", line 805, in process_cmd_args
    self.MODES[mode]()
  File ".\apt-vim", line 579, in first_run
    os.symlink(self.INSTALL_TARGET, BUNDLE_PATH)
AttributeError: 'module' object has no attribute 'symlink'

Python version 2.7.12

egalpin commented 8 years ago

Another item to add to the fix list: os.symlink is only supported by *nix. Workaround would be to delete the usage of os.symlink from apt-vim and then use mklink in Windows to create a symlink from ~/.vimpkg/bundle to Windows equivalent of ~/.vim/bundle. I'm not entirely sure where vim bundles/plugins are installed on windows, sorry.

zwhitchcox commented 8 years ago

idk regularly...I'm just on a Windows computer for work (at the government)...I wouldn't normally use a PC for development, but on my machine, they're stored (by git bash) on K://.vim/bundle. Git bash has an alias for ~/.vim/bundle though. Although my actual home directory is `C:\Users{username}\

zwhitchcox commented 8 years ago

Ok, so I added a "polyfill" I guess per this SO question, but I'm still getting an error,

apt-vim> py .\apt-vim init
There's already an apt-vim root directory at C:\Users\276655\.vimpkg

Are you sure you want to continue? [y|N]:
Invalid option. Please enter `Y` or `N` only
Are you sure you want to continue? [y|N]:  Y
Traceback (most recent call last):
  File ".\apt-vim", line 874, in <module>
    apt_vim.main()
  File ".\apt-vim", line 850, in main
    self.process_cmd_args()
  File ".\apt-vim", line 823, in process_cmd_args
    self.MODES[mode]()
  File ".\apt-vim", line 604, in first_run
    if not self.call_silent(['cp', os.path.realpath(__file__), SCRIPT_EXE_PATH]):
  File ".\apt-vim", line 516, in call_silent
    exit_code = call(command, stdout=devnull)
  File "C:\Python27\lib\subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Python27\lib\subprocess.py", line 711, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 959, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
zwhitchcox commented 8 years ago

ok, I removed the ~/.vimpkg, now, I'm getting this error:

apt-vim $ python apt-vim init
Traceback (most recent call last):
  File "apt-vim", line 874, in <module>
    apt_vim.main()
  File "apt-vim", line 850, in main
    self.process_cmd_args()
  File "apt-vim", line 823, in process_cmd_args
    self.MODES[mode]()
  File "apt-vim", line 597, in first_run
    os.symlink(self.INSTALL_TARGET, BUNDLE_PATH)
  File "apt-vim", line 20, in symlink
    raise ctypes.WinError()
WindowsError: [Error 5] Access is denied.
zwhitchcox commented 8 years ago

Sidenote: Would most people have just given up by now? I'm guessing so, or you would have had this issue before haha

zwhitchcox commented 8 years ago

This is the error I get with mklink

apt-vim $ python apt-vim init
There's already an apt-vim root directory at K:\.vimpkg

Are you sure you want to continue? [y|N]:  y
Traceback (most recent call last):
  File "apt-vim", line 856, in <module>
    apt_vim.main()
  File "apt-vim", line 832, in main
    self.process_cmd_args()
  File "apt-vim", line 805, in process_cmd_args
    self.MODES[mode]()
  File "apt-vim", line 579, in first_run
    os.mklink(self.INSTALL_TARGET, BUNDLE_PATH)
AttributeError: 'module' object has no attribute 'mklink'
egalpin commented 8 years ago

Haha, yes definitely most would have bailed by now. Sorry for the rough ride. I'm also away from computer access so you're facing the front line of issues alone. I'll definitely be making fixes based on your struggles, but unfortunately they won't be immediate :-(

zwhitchcox commented 8 years ago

Ok, this polyfill appears to work

import os
if os.name == "nt":
    def symlink_ms(source, link_name):
        import ctypes
        csl = ctypes.windll.kernel32.CreateSymbolicLinkW
        csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
        csl.restype = ctypes.c_ubyte
        flags = 1 if os.path.isdir(source) else 0
        try:
            if csl(link_name, source.replace('/', '\\'), flags) == 0:
                raise ctypes.WinError()
        except:
            pass
    os.symlink = symlink_ms

But, now, I'm getting an error that K:.vimpkg\bin isn't in my path, when it is

egalpin commented 8 years ago

Sorry, I wasn't very clear at all. You'll need to run mklink in command prompt on windows. You'll also need to remove the apt-vim code that checks for and replaces an existing ~/.vimpkg directory, as you know yours is in a good state

egalpin commented 8 years ago

Oh ok, you've made great progress. Can you start interactive python in your current shell and try the following like so:

python -i

import os
print os.environ['PATH']

Does it list the apt-vim bin directory?

zwhitchcox commented 8 years ago

Ok, no problem...I mean, you've already sort of done your part by creating the actual program...

But I actually got it to work now, but it's now, it's asking me if I have any of these programs installed, and I have to say y for every one, and then it names the package y for some reason

apt-vim $ python ~/.vimpkg/bin/apt-vim install http://github.com/scrooloose/nerdcommenter
No recipe for `vim` for your OS
Do you wish to continue anyways? [y|N]:  y
No recipe for `git` for your OS
Do you wish to continue anyways? [y|N]:
Invalid option. Please enter `Y` or `N` only
Do you wish to continue anyways? [y|N]:  y
No recipe for `brew` for your OS
Do you wish to continue anyways? [y|N]:  hello
Invalid option. Please enter `Y` or `N` only
Do you wish to continue anyways? [y|N]:  y

Configuring and installing `y`
Cloning into 'y'...
remote: Counting objects: 1849, done.
remote: Total 1849 (delta 0), reused 0 (delta 0), pack-reused 1849
Receiving objects: 100% (1849/1849), 599.18 KiB | 584.00 KiB/s, done.
Resolving deltas: 100% (745/745), done.
Checking connectivity... done.
Completed successfully.
zwhitchcox commented 8 years ago

Yes, it's listed on the path

K:\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Pr
ogram Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw6
4\bin;C:\Program Files\Git\usr\bin;K:\bin;C:\oracle\product\12.1.0\client_1\bin;
C:\Program Files (x86)\CA\DCS\CAWIN;C:\windows\system32;C:\windows;C:\windows\Sy
stem32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0;C:\windows\esisoft;C:\Pro
gram Files (x86)\IBM\Personal Communications;C:\Program Files (x86)\IBM\Trace Fa
cility;C:\Program Files\Internet Explorer;C:\SQLLIB\BIN;C:\SQLLIB\FUNCTION;C:\Pr
ogram Files\Common Files\ThinPrint;C:\Programs\DCPS\npm;C:\Programs\DCPS\Git\cmd
;C:\Programs\DCPS\PostgreSQL\9.4\bin;C:\Program Files\Git\cmd;C:\PROGRAMS\DCPS\N
ODEJS;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program File
s\Microsoft SQL Server\130\Tools\Binn;C:\oracle\product\12.1.0\client_1\bin;C:\P
rogram Files (x86)\CA\DCS\CAWIN;C:\windows\system32;C:\windows;C:\windows\System
32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0;C:\windows\esisoft;C:\Program
 Files (x86)\IBM\Personal Communications;C:\Program Files (x86)\IBM\Trace Facili
ty;C:\Program Files\Internet Explorer;C:\SQLLIB\BIN;C:\SQLLIB\FUNCTION;C:\Progra
m Files\Common Files\ThinPrint;C:\Programs\DCPS\npm;C:\Programs\DCPS\Git\cmd;C:\
Programs\DCPS\PostgreSQL\9.4\bin;C:\Program Files\Git\cmd;C:\PROGRAMS\DCPS\NODEJ
S;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files\Mi
crosoft SQL Server\130\Tools\Binn;C:\Users\276655\AppData\Roaming\npm;C:\Program
 Files\Sublime Text 3;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\
Git\usr\bin\core_perl;K:\bin;K:\.npm\bin.lnk;K:\.vimpkg\bin
zwhitchcox commented 8 years ago

The command seems to run in a subshell somehow though, and my bashrc isn't executed for some reason

zwhitchcox commented 8 years ago

So, it's probably not in there for the process that is run