-
Notifications
You must be signed in to change notification settings - Fork 94
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
CLI fails if cylc executables are not in $PATH #3915
Comments
I tried the $ cd cylc-flow
$ pip install --user .
$ cylc run --no-detach five That works with no issues. Looking where's Cylc installed:
If I modify my I think that means that the default location used by |
Sorry, I should have been more explicit about what I did. I invoked cylc using an explicit path, knowing that cylc wasn't in $PATH. For instance:
I expected cylc to work (as many commands do) when invoked in this way. Instead, I got
Most of the cylc sub-commands fail in a similar way. For instance:
It seems that the something in the cylc CLI assumes that its entry points are all installed to a directory that is included in $PATH. Obviously this is fairly easy to work around by modifying $PATH. However, in my opinion it would be better to avoid the assumption that the entry points are in $PATH in the first place. That would simplify things for users and would potentially make cylc more resilient to changes in environment. I'm working on a PR to address this. It prevents the problem described above, but the implementation still needs some work before it's ready to merge (my changes break some of the integration and functional tests). |
@jhaiduce is there are reason why you couldn't source/activate the From your explanation, I am assuming you created a Python virtual environment With the virtual environment activated/source'd, the |
@jhaiduce - thanks for getting involved with Cylc 👍 Hopefully we'll see more of you. On this issue, like @kinow I'm a bit confused about why you tried to run cylc in the way described above. Virtual environments are normally supposed to be "activated" ( And, to my understanding at least, |
@kinow, @hjoliver - I could certainly update $PATH, either directly or using venv/bin/activate. It is certainly not difficult to do. I just tried it to make sure, and it indeed allows cylc to work correctly. Thanks for hearing me out on this one. Here's a (somewhat long-winded) answer to why I think it's better that a package such as cylc not rely on having its entry points in $PATH. It basically boils down to three factors: 1. Not all users 'activate' their venv's as a matter of course, and those who don't will be suprised that cylc expects it. 2. The venv documentation says that things should still work if you don't activate a venv. 3. There are some (admittedly uncommon) situations where reliance on $PATH can cause bugs even with the cylc executables accessible through $PATH. To elaborate on the first point, my own habit is to skip the activate step and either use relative paths into the virtualenv directory or use full paths with the help of an environment variable pointing to the venv directory. I've seen similar usage patterns in tutorials such as this one, so I'm reasonably confident that there a substantial subset of python users out there is using venv's without activating them. Cylc is the first package I've encountered up til now that did not work without activating the venv first, so my initial reaction was to perceive the behavior as a bug. If cylc doesn't rely on $PATH to find its components, that will shorten the learning curve for new users (such as myself) who don't usually activate their venv's. As for the second factor, the documentation of venv includes the following:
The third point is that relying on on $PATH internally to find internal components of a package result in other bugs in certain circumstances, even if the initial entry point is in the $PATH. For instance if a user created a script or program that was coincidentally named the same as one of cylc's entry points, and that script or program was located in the user's $PATH, then cylc would run that script or program rather than its own entry point. This is admittedly not very probable, but not entirely out of the realm of possibility. For instance, a user might create a custom script to run checks on their suite RC file and coincidentally call it cylc-validate, not realizing that cylc tries to execute it accidentally. If the user also happened to have '.' in their $PATH (which is widely discouraged, but nonetheless practiced by some), then the chances of a clash of this sort increase somewhat. All of that said, I acknowledge that avoiding reliance on $PATH may be more difficult with cylc than it is with other packages, given the need to run tasks on remote hosts that also have cylc installed. If you decide to close this with a WONTFIX or similar I won't have hard feelings about it. |
Hi @jhaiduce thanks a lot for the detailed response (again)! Now I'm not sure whether this should be closed or not. I am used to always activating environments, so I was probably biased in suggesting that you did that to fix the issue. But from your explanation, it sounds like this could happen in other cases. There could be some Python third party application that invokes workflow managers, for instance, and that doesn't activate environments. A contrived case, but if that happened they could be using the same argument, and I think that's a valid point. If your solution fixes this issue, without causing any regression in Cylc, I'd be +1 for that, though @oliver-sanders & @hjoliver know a lot more about Cylc internals, and their use cases, deployment, past issues, etc. So I'll leave it up to them to decide. Thanks a lot for the PR's/issues, and for your patience too. Cheers, Bruno |
Thanks @kinow. My draft PR #3920 obviously caused some regressions, but in the meantime PR #3899 has been merged and as far as I can tell it addresses my concerns. (Also thanks to @wxtim for working on that one) |
Describe the bug
If the cylc commands aren't in $PATH, most CLI commands fail with "No such file or directory" errors.
Release version(s) and/or repository branch(es) affected?
Current master
Steps to reproduce the bug
Install cylc in an environment where its executables are not in $PATH (for example a virtualenv or with pip install --user). Run a cylc command using the full path to executable (such as /full/path/to/cylc/binaries/cylc --help)
Expected behavior
Should print a help message. Instead the command fails with a "No such file or directory" error because "cylc-help" is not in $PATH.
The text was updated successfully, but these errors were encountered: