msys2 / msys2-launcher

Helper for launching MSYS2 shells

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shortcut to executable (Qt Creator) in mingw64 environment

FSund opened this issue · comments

I've installed QtCreator and was hoping to be able to add a shortcut to it on my start menu, to avoid having to first open a mingw64 shell and then typing in qtcreator. Is there any easy way to do this using msys2-launcher?

I've tried creating a shortcut with Target set to C:\msys64\mingw64.exe qtcreator, which mostly works, but also opens a terminal which I would like to avoid. Any way to do this?

Just to reiterate; I would like to know if there is an option to hide the terminal window, that can be given in the Target field of a shortcut. I tried -w hide, but that didn't work.

Sorry for the late reply. What's wrong with a shortcut to C:\msys64\mingw64\bin\qtcreator.exe?

I'm closing this issue because at the moment I believe this feature is out of scope for this project, but discussion can continue.

a shortcut directly to qtcreator won’t start it with the awareness of the msys2 folder hierarchy

I don't know how this awareness is implemented, but I assume it should be configurable somehow inside QtCreator. I suggest you try to figure out that part.

Also if you don't mind a terminal window for a brief moment, you could try C:\msys64\mingw64.exe start qtcreator.

the usual suspect to start something with the ability to use linux style / pathing and discoverability is done via setting MSYSTEM and starting a command with bash -lc, probably similar to how this launcher is working
i don’t think that’s something to setup on a per tool basis, especially since it needs to propagate

i’m quite happy starting it manually in mintty and also with it showing the output when started with the launcher without start

maybe @FSund is happy with start already, but i guess he was asking for a generic »run in msys env« (without any window) functionality this launcher could provide

Yeah, I was looking for perhaps a flag to launch the terminal window in the background/hidden.

There is nothing magical about starting QtCreator from an established MINGW shell. QtCreator is still a mingw-w64 program and doesn't understand virtual msys paths this way any more than any other way.

I have some ideas for what the launcher could be enhanced to do, but I still think launching a native Windows app with a shell set-up underneath it is pretty much out of scope. All the mingw-w64 programs are supposed to be operable outside of the shells, ideally. I can try to direct you to isolate what exactly is helping QtCreator detect the presence of MSYS2.

It is able to find binaries as if path is set without having to explicitly do so…

Is there a reason the appended command to mingw64.exe is run in an extra (non-login) shell (sh cmd args)? I just noticed it not working for me with only a bare exec fish in .bashrc – using if [ -z "$BASH_EXECUTION_STRING" ]; then exec fish; fi works, but it got me curious.

It is able to find binaries as if path is set without having to explicitly do so.

This is exactly the reason I want to launch it this way. It's very convenient not having to set up everything manually.

It is able to find binaries as if path is set without having to explicitly do so…

Okay, that's a step forward. The MINGW64 shell prepends /mingw64/bin to PATH. You can use the env command (preferably a mingw build) to change PATH for one program invocation, for example like this: ...\env.exe PATH=C:\msys64\mingw64\bin C:\msys64\mingw64\bin\qtcreator.exe

Is there a reason the appended command to mingw64.exe is run in an extra (non-login) shell (sh cmd args)?

I don't think I can make mintty append a command to a login shell. And getting the login shell path from inside MSYS2 is not very easy nor quick, so I didn't implement that. May I ask why the shell matters to you when you're executing a command?

I mentioned an issue at the end:

I just noticed it not working for me with only a bare exec fish in .bashrc – using if [ -z "$BASH_EXECUTION_STRING" ]; then exec fish; fi works, but it got me curious.

And regarding »generic launcher« and login shell, i was thinking that having that as a substitute for setting MSYSTEM manually and running bash -lc afterwards for e.g. CI could be nice.

So you're running something like msys2.exe bash -lc "command; command"?

i mean this https://github.com/msys2/MINGW-packages/blob/386d87efad5e034913212022f51a54449b20b4a5/appveyor.yml#L21
that pacman is run outside bash only works because the image is so outdated
and if you don’t use makepkg-mingw, additionally setting MSYSTEM is also required

Pacman doesn't need to be run inside Bash and doesn't care about MSYSTEM. Maybe some of the post-install scripts do, but even then I don't see the connection with how outdated the image is.

I still don't quite understand the use case, so let me say that there's not much reason to run msys2.exe bash -lc ... because msys2.exe ... should work just as well.

i never mentioned msys2.exe
MSYSTEM is currently required to set the correct paths when compiling in the CI
and yes, post-install scripts, which are relevant if the image is new enough so the pacman update, that’s run before the build script, doesn’t stop after the core system upgrade (which doesn’t have post-install scripts) because there are no updates to the core system.