-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fixes for MSYS2 #11907
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
Fixes for MSYS2 #11907
Conversation
src/builtins/ulimit.rs
Outdated
| pub const NPROC: libc::c_int = -1; | ||
| } else { | ||
| pub const NPROC: libc::c_int = libc::RLIMIT_NPROC as _; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | |
| } |
Me, too. Some of them might be caused by MSYS2 which doesn't respect the file permissions like cygwin, but it's harder to setup a testing environment for fish on original cygwin. I don't know if cygwin/MSYS2 was tested in CI before fish 4.0, but if it wasn't, it's an acceptable status currently (maybe). |
| shell: msys2 {0} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: msys2/setup-msys2@v2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool so I assume this will give a Bash shell, as opposed to the default (powershell?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
.github/workflows/main.yml
Outdated
| - uses: msys2/setup-msys2@v2 | ||
| with: | ||
| update: true | ||
| install: >- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does the >- syntax do? convert barewords to list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copy/pasted what the tutorial for MSYS2 github action does.
And yes, it converts the multi-line word list into a single-line list (>) without a newline at the end ('-'). Not really needed here but that will be one less line change if we need to add more packages and organize them
| update: true | ||
| install: >- | ||
| git rust | ||
| msystem: MSYS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these translate to pacman -S git rust commands right?
Could we use those (so it's easier for me to copy-paste these steps onto any Windows system).
Unless there's a relevant difference of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In essence, it's indeed just a pacman -S.
Looking at their code, strictly speaking, it's doing a pacman --noconfirm -S --needed --overwrite '*' git rust.
It also has some caching being done so that when testing multiple environment (MSYS2, MINGW32, MINGW64, ...) it won't re-download the common packages, which we'll probably never need.
| - uses: actions/checkout@v4 | ||
| - name: cargo build | ||
| run: | | ||
| cargo build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is already a great step in the right direction.
We could even add a smoke test like
set -x
[ "$(target/debug/fish.exe -c 'echo (math 1 + 1)')" = 2 ]
(FWIW debug builds currently only work due to 012b507 (Workaround
for embed-data debug builds on Cygwin, 2025-09-16) which we should
get rid of.. there is some problem with Windows paths in rust-embed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is some problem with Windows paths in rust-embed
If it is built with rustc shipped with MSYS2, the paths should be in POSIX style, I assume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could even add a smoke test
You mean as a temporary replacement for calling cargo test, as an extra "name / run"?
| #RUN: %fish %s | ||
|
|
||
| #REQUIRES: command -v tmux | ||
| isolated-tmux-start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One test was added, to ensure
fish_configcan be shutdown (as
requested in #11805), but it does not test that a browser can access
the server (because this would add a#REQUIRESfor a new command,
e.g.wget/curl).
I do not know if that one test is sufficient for this PR, so for
now, I'm not checking that TODO
Right, if it's easy to add curl localhost:$port | grep some line,
that sounds like a nice addition to this test.
But I'm happy to merge without a faithful test.
Historically, this functionality sometimes broke in Cygwin and WSL,
where we don't run these tests in the CI anyway yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My issue was adding curl (or wget) as a new requirement for testing since I didn't see any other test doing http request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I'd normally prefer curl since it's more widely used but wget is fine too of course.
Can you maybe install wget explicitly in the main CI job (the first ubuntu one in .github/workflows/main.yml).
(Could also add it to other platforms but before we do that we should probably extract functions for installing all test dependencies, so it doesn't get any messier. For example ./.github/actions/install-sphinx-markdown-builder is one such function.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with wget because it's pretty much pre-installed on any system. Like the equivalent of nano vs emacs/vi. Even my router, whose firmware has to be as small as possible, has it (OpenWRT). And it's ubiquitous enough to be a tool integrated into Busybox.
If you really want, I can add it to the Ubuntu build, it's simple enough. But it feels unnecessary. It passes all the tests, which means wget is already installed. For that matter wget is a dependency of the ubuntu-standard meta package so if it's not there, we have bigger problems.
tests/checks/tmux-fish_config.fish
Outdated
| isolated-tmux capture-pane -p | sed \ | ||
| -e '1h;2,$H;$!d;g' \ | ||
| -e 's|file://.*\.html|<file_url>|' \ | ||
| -e 's|http://.*/\n|<http_url>\n|' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably awk would be more readable than sed magic but sure,
if it works on BSD sed too.
FWIW the 80 columns are not set in stone;
it's from the isolated-tmux new-session -x 80 -y 10 line
For example the test could change it with (untested)
isolated-tmux resize-window -x 500
which is probably a better solution than working around it in sed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do.
Alternative: redirect Doesn't work because of buffering inside the redirectfish_config output to a file and use cat or tail instead of tmux capture-pane and avoid the width limit entirely.
only if downstream (Cygwin packagers) tested it |
|
You mean as a temporary replacement for calling `cargo test`, as an extra "name / run"?
yeah. Just to test it can start and execute commands
> @@ -0,0 +1,26 @@
+#RUN: %fish %s
+
+#REQUIRES: command -v tmux
+isolated-tmux-start
My issue was adding `curl` (or `wget`) as a new requirement for testing since I didn't see any other test doing http request.
Right. Maybe use `python -c 'import requests; ...'` ?
I think we can already assume that `python` exists in `PATH`.
+isolated-tmux capture-pane -p | sed \
+ -e '1h;2,$H;$!d;g' \
+ -e 's|file://.*\.html|<file_url>|' \
+ -e 's|http://.*/\n|<http_url>\n|'
Can do.
Alternative: redirect `fish_config` output to a file and use `cat` or `tail` instead of `tmux capture-pane` and avoid the width limit entirely.
Good idea -- write to a file in the current directory,
and then use `cat log` outside tmux.
|
I tried and it doesn't work. The problem is that the file is buffered so there is no data until we exit |
8ad4a7a to
18eccd5
Compare
.github/workflows/main.yml
Outdated
| - name: install needed | ||
| # Not using setup-msys2 `install` option to make it easier to copy/paste | ||
| run: | | ||
| pacman --noconfirm -S --needed --overwrite '*' git rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--overwrite '*' is sus; it seems like a workaround for weird packaging bugs;
I hope we don't need this, so better remove it and add it only if we really need to
share/tools/web_config/webconfig.py
Outdated
|
|
||
| def runThing(): | ||
| if isMacOS10_12_5_OrLater(): | ||
| if os.environ.get("BROWSER", "") == "true": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that looks reasonable;
for as long as we have all these weird workarounds,
we want a reliable way to have system tests disable this.
BTW, we should probably leave out the , "" default argument,
it doesn't add any useful behavior, and it's already obvious
from our use of .get() that a missing variable is not an error.
(As mentioned in #11926 this workaround for macOS 10.12.5 or later,
has been fixed in macOS 10.12.6 according to https://andrewjaffe.net/blog/2017/05/python_bug_hunt/,
I think we can assume all users have upgraded to that patch version
So let's remove this workaround, but that can be in a different PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, we should probably leave out the , "" default argument,
it doesn't add any useful behavior, and it's already obvious
I thought get would throw if the variable was not present, but I must have been confused with [...] or the get of some other language. Will remove.
tests/checks/tmux-fish_config.fish
Outdated
| isolated-tmux capture-pane -p | ||
| # CHECK: prompt 0> BROWSER=true fish_config | ||
| # CHECK: Web config started at file://{{.*}}.html | ||
| # CHECK: If that doesn't work, try opening http://localhost:8000/{{\w+}}/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails for me due to a port number mismatch:
If that doesn't work, try opening http://localhost:8001/9b54d4275031129e9fa88e340623e5f9/
Probably we don't care about the exact port number?
FWIW, I ran the test twice, in two different ways:
# passes
ninja -Cbuild test_tmux-fish_config.fish
# fails
tests/test_driver.py target/debug tests/checks/tmux-fish_config.fish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hardcoded the number because that way I could just hardcode the bad URL. But it's easy enough to extract it from base_url.
As-is it certainly will fail if you have another instance of fish_config already running (or, of course, if any other server app is on that port)
tests/checks/tmux-fish_config.fish
Outdated
|
|
||
| # Check a bad URL | ||
| wget -q -O /dev/null "http://localhost:8000/invalid_auth/" 2>/dev/null | ||
| or test $status -eq 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as written, this test statement is useless.
If the test statement fails, nothing happens.
Should follow it up with or echo "unexpected exit code from wget".
That's probably more reliable than testing the exact wget output below.
|
|
||
| # Check a good URL | ||
| set -l workspace_root (path resolve -- (status dirname)/../../) | ||
| diff -q "$workspace_root/share/tools/web_config/index.html" (wget -q -O - $base_url 2>/dev/null | psub -f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
yeah I could reproduce the same buffering behavior in |
- Windows allows port reuse under certain conditions. In fish_config case, this allows the signal socket to use the same port as http (e.g. when using MINGW python). This can cause some browsers to access the signal socket rather than the http one (e.g. when connecting using IPv4/"127.0.0.1" instead of IPv6/"::1"). - This is also more efficient since we already know that all ports up to and including the http one are not available Fixes fish-shell#11805
a4a773f to
b1b6b4c
Compare
In particular - test that it will return an error if the URL is invalid - that the main page matches the index.html in git - that "Enter" key will exit
|
Arf! Looks like Busybox's |
- Windows allows port reuse under certain conditions. In fish_config case, this allows the signal socket to use the same port as http (e.g. when using MINGW python). This can cause some browsers to access the signal socket rather than the http one (e.g. when connecting using IPv4/"127.0.0.1" instead of IPv6/"::1"). - This is also more efficient since we already know that all ports up to and including the http one are not available Fixes fish-shell#11805 Part of fish-shell#11907
In particular - test that it will return an error if the URL is invalid - that the main page matches the index.html in git - that "Enter" key will exit Part of fish-shell#11907
- Windows allows port reuse under certain conditions. In fish_config case, this allows the signal socket to use the same port as http (e.g. when using MINGW python). This can cause some browsers to access the signal socket rather than the http one (e.g. when connecting using IPv4/"127.0.0.1" instead of IPv6/"::1"). - This is also more efficient since we already know that all ports up to and including the http one are not available Fixes fish-shell#11805 Part of fish-shell#11907
In particular - test that it will return an error if the URL is invalid - that the main page matches the index.html in git - that "Enter" key will exit Part of fish-shell#11907
- Windows allows port reuse under certain conditions. In fish_config case, this allows the signal socket to use the same port as http (e.g. when using MINGW python). This can cause some browsers to access the signal socket rather than the http one (e.g. when connecting using IPv4/"127.0.0.1" instead of IPv6/"::1"). - This is also more efficient since we already know that all ports up to and including the http one are not available Fixes fish-shell#11805 Part of fish-shell#11907
In particular - test that it will return an error if the URL is invalid - that the main page matches the index.html in git - that "Enter" key will exit Part of fish-shell#11907
- Windows allows port reuse under certain conditions. In fish_config case, this allows the signal socket to use the same port as http (e.g. when using MINGW python). This can cause some browsers to access the signal socket rather than the http one (e.g. when connecting using IPv4/"127.0.0.1" instead of IPv6/"::1"). - This is also more efficient since we already know that all ports up to and including the http one are not available Fixes fish-shell#11805 Part of fish-shell#11907
In particular - test that it will return an error if the URL is invalid - that the main page matches the index.html in git - that "Enter" key will exit Part of fish-shell#11907
- Windows allows port reuse under certain conditions. In fish_config case, this allows the signal socket to use the same port as http (e.g. when using MINGW python). This can cause some browsers to access the signal socket rather than the http one (e.g. when connecting using IPv4/"127.0.0.1" instead of IPv6/"::1"). - This is also more efficient since we already know that all ports up to and including the http one are not available Fixes #11805 Part of #11907
In particular - test that it will return an error if the URL is invalid - that the main page matches the index.html in git - that "Enter" key will exit Part of #11907
fish_confignot working in msys2 #11805Fixes issue #11805
TODOs:
Changes to fish usage are reflected in user documentation/manpages.[None]Note
One test was added, to ensure
fish_configcan be shutdown (as requested in #11805), but it does not test that a browser can access the server (because this would add a#REQUIRESfor a new command, e.g.wget/curl).I do not know if that one test is sufficient for this PR, so for now, I'm not checking that TODO
User-visible changes noted in CHANGELOG.rst[None]