-
Notifications
You must be signed in to change notification settings - Fork 907
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
cannot escape from "warning: PWD environment variable doesn't match current directory" #1892
Comments
Normally, your shell would automatically set PWD. It's odd that it isn't. What shell are you using? The PWD variable allows KJ to better-support the case where the current directory includes symbolic links. The For example, say you typed With all that said, in most cases the difference doesn't actually matter. If your current directory in your shell doesn't include any symlinks, then it definitely doesn't matter. Also, the capnproto build does not attempt to reach outside the build directory and so whether it's a symlink or not doesn't matter. So, this warning is spurious in your case and can be ignored. |
Thank you for the reply! I'm using zsh and CMake 3.26.4. I've verified that PWD is set by printing the $ENV(PWD) from within CMake. For the launch directory both "pwd -L" and "pwd -p" give the same directory, which match PWD printed from CMake. Perplexing. Could be some nuance with CMake. Seems like others would be seeing it though. It does work, although frustrating. I try hard to enforce a "do not ignore warnings" policy. |
So, looking at the actual code: capnproto/c++/src/kj/filesystem-disk-unix.c++ Lines 1689 to 1712 in 6917c0f
It looks like the error will occur when (Actually... this seems like a bug... these should be using It looks like the error message should include the path that PWD reported. I guess you removed that part from the error in your bug report. But does the path appear to be correct? Perhaps you could adjust the code slightly: - KJ_LOG(WARNING, "PWD environment variable doesn't match current directory", pwd);
+ char buf[512];
+ KJ_LOG(WARNING, "PWD environment variable doesn't match current directory", pwd, getcwd(buf, 512)); This way the error will report both the content of PWD and the actual current directory path. Are they the same? |
Great suggestion. That narrowed it down. I am using a specified build directory with CMake.
Maybe just remove this check and the cwd stuff from capnp? If someone is using symbolic links, it could be on them to make sure they are not dot-dot'ing around to unknown parts. |
I could be convinced that we should just remove the warning. If PWD doesn't match, we just ignore it and use the canonical path. But I do think this code provides value when it works. Consider what would happen if Like imagine if your home directory contains a symlink
The above doesn't actually happen in practice, but only because the shell's implementation of
This second example is real: cat actually works this way. When I tested this, my shell actually auto-completed KJ's weird stuff with PWD avoids this problem: A KJ-based tool will do the intuitive thing and will actually find |
I would definitely appreciate removing the warning! For removing the check altogether, I'm happy either way. I'm planning to paint inside the lines. If I don't get a warning doing that, I'm a all good. For consideration though, sometimes when tools are 'automagical' it can be frustrating. "How in the world is this working? The Linux commands don't even do that.." Just my two cents, if someone cd's ".." to the point leaving a symbolic link, that's for them to debug. A friendly error message is always nice though. All the best, Kenton. I appreciate that thought that goes into this. I was leery at first, but I'm a Capn'p convert. Love it. |
Happy to accept a PR removing the |
I am all for downgrading it to INFO for my situation. In my case I was seeing this in the output. [2024-03-19T19:20:45.014Z] python3 test_integration_shep_gs.py -v -f [2024-03-19T19:20:45.385Z] kj/filesystem-disk-unix.c++:1703: warning: PWD environment variable doesn't match current directory; pwd = /home/**** [2024-03-19T19:20:45.386Z] test_api_create (main.GSLS) ... :914: ImportWarning: _Importer.find_spec() not found; falling back to find_module() [2024-03-19T19:20:45.747Z] kj/filesystem-disk-unix.c++:1703: warning: PWD environment variable doesn't match current directory; pwd = /home/**** [2024-03-19T19:20:46.108Z] FAIL [2024-03-19T19:20:46.108Z] FAIL I am wondering if the ImportWarning is also coming from capnproto? I am going to try isolating. I am using pycapnp in my code along with a C++ version of capnp. I am not sure if the messages are coming from the pycapnp code or the C++ library I linked into our .so. Will spend some time isolating this. |
@kentdlee The ImportWarning is not from C++. |
I'm using CMake with Linux in an AWS account.
I always get this warning:
kj/filesystem-disk-unix.c++:1734: warning: PWD environment variable doesn't match current directory;
I've verified that I'm not launching from symbolic linked directory.
Even it if worked (presumably only warning about symbolic link) what value does it add? Seems quite legitimate to build in a symbolic linked directory.
It is an annoying little warning.
Anyone else seeing it? Any way to suppress it?
The text was updated successfully, but these errors were encountered: