-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Flake] error: 'file:///tmp/测试' is not a valid URL #5759
Comments
The error ( |
Did some rudimentary test and it seems to work: Run following code online: https://coliru.stacked-crooked.com/a/7966647daeafabab Input: #include <iostream>
#include <locale>
int main() {
const wchar_t c = L'\u86e4'; // Ideograph clam CJK
std::locale loc1("C");
std::cout << "isalnum('蛤', C locale) returned "
<< std::boolalpha << std::isalnum(c, loc1) << '\n';
std::locale loc2("en_US.UTF-8");
std::cout << "isalnum('蛤', Unicode locale) returned "
<< std::boolalpha << std::isalnum(c, loc2) << '\n';
} Outputs:
|
@kidonng ah indeed, need to use a |
Please don't use |
Yup’, but the regex engine is apparently not aware of that. Maybe I’m just not doing things properly (I must confess that I’ve more or less no idea what I’m doing), but I can’t get a regex that matches any UTF-8 character on plain |
I marked this as stale due to inactivity. → More info |
Also change the flakeref parser to just check if the directory exists. While using `c & 0xFF` doesn't look pretty, it's the only thing that works. I suspect it has something to do with the intersection between the previous conversion to unsigned, and the templating used in boost. This closes NixOS#5759 and NixOS#4563. TODO: Just deleting the regex like I did does not work. You still need to be able to parse paths that aren't there, if they aren't used lazily.
Still a problem |
What's the reason to have this regex in the first place? |
I just had this happen with a space in my filesystem path:
|
It's used to parse the input since it's not just a path, but an arbitrary flake input. @chronoslynx I think #6614 would fix that, but it's abandoned. Do you feel like you could take it over (essentially rebase it since it's mostly good apart from the merge conflicts)? |
Regarding the original issue,
|
I'll take a swing at it. I'm ill this weekend, so won't be quick unfortunately |
That's a promising start after I rebase. I'll take a deeper look tomorrow |
So the following actually works on a release build of nix. We don't seem to bother with parsing the file path as a URL unless the directory is a git repo:
That PR also does not fix the problem when spaces are present in a URL. I added some prints to the top of parseURL and it looks like the path with a space isn't being encoded prior to the call to parseURL:
On your notes above: the path regex actually looks fine. I dumped the full url regex and put it into https://regex101.com to test it out and it handles percent-encoding without issue. It looks more like we aren't always percent-encoding the string in the first place |
To support using nix flakes in paths with spaces, this introduces the convention that the path part of the URL should be percent-encoded when dealing with paths. It follows the convention of firefox, which uses percent encoding when encoding a local path to an URL. Eventually, this might also allow paths with arbitrary unicode characters, if the percent encoding and decoding methods are improved such that they can handle them. This closes NixOS#6394. Make url encoding work for arbritrary unicode characters Also change the flakeref parser to just check if the directory exists. While using `c & 0xFF` doesn't look pretty, it's the only thing that works. I suspect it has something to do with the intersection between the previous conversion to unsigned, and the templating used in boost. This closes NixOS#5759 and NixOS#4563. TODO: Just deleting the regex like I did does not work. You still need to be able to parse paths that aren't there, if they aren't used lazily.
I just hit this with also a space in the path, ha |
@pearsche I think #6614 (merged, but not yet released) should fix this. |
I have the same with a path including an @-sign |
Describe the bug
If a flake is under a dir with non english characters, the error is out when running
nix flake lock
.Steps To Reproduce
or
Expected behavior
It can work.
nix-env --version
outputnix-env (Nix) 2.4 (nixpkgs: c6fc79a2ac611b58ff93574cf787260ed2101d06)
Additional context
The problem is caused by flakeUrl and parseFlakeRefWithFragment probably
cc: @NickCao
The text was updated successfully, but these errors were encountered: