Call MSYS2 Shell from the command line or PowerShell

Starting from the command line or PowerShell (everything is fine; I can figure out how to do something different given this), how can I call MSYS2 to run the command?

More specific question

I have included this information in order to avoid the XY problem, but I am firmly convinced that it is best solved by answering the above (more general) question.

In particular, I hope to write a shell script to update the packages listed in Part III, step 3 here . So I need something like:

[invoke msys2 bash] -c "pacman -Sy --needed msys2-runtime"

Invoking the bash executable directly does not work:

C:\>C:\msys64\usr\bin\bash.exe -c "pacman -Sy --needed msys2-runtime"
/usr/bin/bash: pacman: command not found

I guess this is an environmental issue. Changing PATHto include the bin path of the MSYS2 bin also does not solve the problem. When he tries to install the package, something bad happens (nano is just an example):

C:\>bash -c "pacman -Sy --needed --noconfirm nano"
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
resolving dependencies...
looking for conflicting packages...

Packages (1) nano-2.3.6-2

Total Installed Size:  1.81 MiB
Net Upgrade Size:      0.17 MiB

:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring                                                                   [########################################################] 100%
(1/1) checking package integrity                                                                 [########################################################] 100%
(1/1) loading package files                                                                      [########################################################] 100%
(1/1) checking for file conflicts                                                                [########################################################] 100%
(1/1) checking available disk space                                                              [########################################################] 100%
(1/1) upgrading nano                                                                             [########################################################] 100%
error: command (/usr/bin/bash /usr/bin/bash -c . /tmp/alpm_shqjUE/.INSTALL; post_upgrade 2.3.6-2 2.3.2-1 ) failed to execute correctly

When I try to call the batch file (C: \ msys64 \ msys2_shell.bat), a new shell opens in a new window, because of which I do not know if it was unsuccessful or successful.

So how do I put the shell into the normal state of MSYS2?

+7
source share
1 answer

We are working hard to fix our dirty update process, we want it to be hassle-free.

You can see some examples of how we call MSYS2 from a batch file when creating a new installer in:

https://github.com/Alexpux/MSYS2-packages/blob/master/msys2-installer/make-msys2-installer.bat

, @StevenPenny,

bash -l -c "pacman ..."

.

+5

All Articles