randy3k / Terminus

Bring a real terminal to Sublime Text
https://packagecontrol.io/packages/Terminus
MIT License
1.37k stars 83 forks source link

Windows 'teminus_exec' fails with cargo with arguments #368

Open eugenesvk opened 1 year ago

eugenesvk commented 1 year ago

This is a copy of a previously closed, but still unresolved issue https://github.com/randy3k/Terminus/issues/310

I've managed to find out that the core issue is that the winpty version is too old — for some reason it doesn't work with composable commands like ["cargo","--version"], only works with ["cargo"] (same issue with rustc)

After I've manually updated winpty that your pywinpty uses to the latest version the issue disappeared

(haven't tested any of the previous versions nor tested with the 3.3 plugin host (the latest version of pyte requires 3.7)

Would you please update this and your other packages to the latest pypi versions that would finally resolve this issue? Thanks!

PWAlessi commented 1 year ago

I'm having the same issue in Sublime. You should probably submit a PR with your fix.

eugenesvk commented 1 year ago

It's not that simple — the fix touches dependencies, which are poorly documented, so I couldn't even test them locally

And as I've later found out after wasting much time on trying to fix the deps, you might not even be able to move deps to python 3.8 according to this forum comment

No. Only py33 plugin can use dependencies at this moment.

(that explains why my local dependencies only worked under the python 3.3 plugin host despite all the .python-version with 38 files I added)

Thus the fix might be more involved and require vendoring all the deps instead, but that might also be rather tricky due to the way Sublime overrides python package loading (I had issues with loading deps that were failing because they couldn't find themselves before)

So I'm not sure what the proper fix is and will better wait for the more knowledgable repo/deps owner to chime in

randy3k commented 1 year ago

@eugenesvk, thanks for the detail investigation. So the workaround is to update https://github.com/packagecontrol/pywinpty?

eugenesvk commented 1 year ago

There might be a simple workaround like that, though the challenge is that the newer https://pypi.org/project/pywinpty/ versions might not work with the old py3.3 plugin host in Sublime

Maybe the version 1.1.0 :

but there are no py3.3 wheels on pypi, so I haven't tested it.

Otherwise you'd need to update not only pywinpty, but also all the other dependencies of Terminus (pyte and wcwidth), move all of them to the new py3.8 plugin host and, since this new plugin host doesn't seem to support dependencies yet, vendor all the dependencies instead of relying on package control

Or maybe I'm missing something and there is a simpler way

eugenesvk commented 10 months ago

fyi this fork seems to work via a direct Package Control install, it vendors those deps (and thus can't be packed due to winpty binaries) and uses a hack to append module loading path (didn't manage to do it propertly, winpty would only load when placed in the plugin hosts' folder, not locally with Terminus)

jeefs commented 9 months ago

I'm also experiencing this problem, what should I do to fix it?

gwentmaster commented 9 months ago

passing the original command to a shell like cmd or bash works for me

{
    "cancel": "terminus_cancel_build",
    "cmd": [
        "cmd", "/C",
        "cargo test $file -- tests --nocapture"
    ],
    "env": {
        "RUSTFLAGS": "-Awarnings"
    },
    "file_regex": "(?|, ([^,<\n]*\\.[A-z]{2}):([0-9]+)|[ \t]*-->[ \t]*([^<\n]*):([0-9]+):([0-9]+))",
    "selector": "source.rust",
    "syntax": "Packages/Rust/Cargo.sublime-syntax",
    "target": "terminus_exec",
    "working_dir": "$project_dir"
}