-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Grammar file not found on workspace #325
Comments
The question is, how does one solve this? It makes sense for the grammar file to be in |
I've been using pest in a workspace, and this hasn't been a problem for me. What I might see being a problem is a binary crate using Could you provide an exact reproduction steps? (Also, OS may play a role here, unfortunately.) |
I think he means that it will not work where no |
I have created an example repository that reproduces the bug. https://github.com/librelois/workspace_use_pest |
My opinion is that the path should start from the root folder of the crate, and not from the sub-folder |
Oh, that project is set up in a very unconventional manner. Most workspaces are set up where each subcrate has a Your problem isn't that you're in a workspace, but that you've defined a different A common workspace layout
Any change to where the One solution is to change the path to instead of being relative from Another is to take a page from the JS world and use "anchored" paths: And another (poor?) solution is just to make the path |
It's worth mentioning that #360 was necessary because not all users are using cargo (and are missing the env vars relied upon here). IMO what this really wants is the ability to use |
@cramertj, expending |
Where the macro resides? What are you referring to here? The path of file that invokes the macro? The reason I suggested |
Sorry, yes, I meant the invocation. The API can be as simple as to only resolve the |
I'd think you'd still want a |
Just want to leave a message here: Would be really nice to be able to use a path that does not start from the src/ dir. Use case: I'm using pest from a build.rs and thus don't really want my grammar file(s) be located in src/, which should contain only runtime code. |
I've hit this problem as well in a project where I'm not using the default cargo I'm guessing its the way it is because plugins don't have access to the source location. |
It also initially surprised and confused me that relative paths in I am using Pest in a project with a non-Cargo build system: Bazel (with Fortunately, similar to others, I can easily work around the issue by moving my grammar file to an otherwise empty |
Hey :) I just stumbled upon this issue and wanted to put in my 2 cents. One of my projects has the issue at hand. Cargo also fully supports this scenario and using I would really like to have the possibility to set the path to the parser file, without having to restructure the whole project. In case you don't want to change the root of the path to What do you think about adding a new parameter which discovers from the root path: |
closes #325. The new logic looks for the [grammar = "$path"] path in CARGO_MANIFEST_DIR/ before using the fallback of CARGO_MANIFEST_DIR/src. This allows projects that don't have a src folder to use a grammar file, while staying backward compatible.
I use pest in a crate of a workspace, so this crate has no
src
folder. I was forced to create an emptysrc
subfolder in my crate so that pest could find my file, it's not clean.It's easy to reproduce this bug, create a new workspace project and try to import pest grammar file from a crate of workspace.
The text was updated successfully, but these errors were encountered: