Skip to content
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

use current_dir() instead of $PWD in schema_from_filepaths() #41

Merged
merged 2 commits into from
Jan 7, 2024

Conversation

nitn3lav
Copy link
Contributor

@nitn3lav nitn3lav commented Jan 6, 2024

When I use rust-analyzer in VS Code on macOS I get this error:

proc-macro derive panicked
message: called `Result::unwrap()` on an `Err` value: WithPath { path: "/./usr/sbin/authserver", err: Io(Custom { kind: PermissionDenied, error: Error { depth: 3, inner: Io { path: Some("/./usr/sbin/authserver"), err: Os { code: 13, kind: PermissionDenied, message: "Permission denied" } } } }) }

This occurs because $PWD is not set which leads to ormlite scanning the entire filesystem in order to generate a schema. IMHO it is reasonable to use $CARGO_MANIFEST_DIR instead of $PWD

@kurtbuilds
Copy link
Owner

kurtbuilds commented Jan 6, 2024

Hey, thanks for submitting this. You're right that it env::var("PWD") is probably wrong, but I think CARGO_MANIFEST_DIR will be blank in cases when it's not called by a cargo command, e.g. anytime you run an ormlite command.

I think it should be using current_dir instead. Does that work for your situation?

It might make sense to have a cascade for exactly the Rust-analyzer situation you're encountering. CARGO_MANIFEST_DIR if it's set, otherwise fall back to current_dir().

@nitn3lav
Copy link
Contributor Author

nitn3lav commented Jan 7, 2024

current_dir() seems to work, thanks!

@kurtbuilds kurtbuilds changed the title use $CARGO_MANIFEST_DIR instead of $PWD in schema_from_filepaths() use current_dir() instead of $PWD in schema_from_filepaths() Jan 7, 2024
@kurtbuilds
Copy link
Owner

Thank you!

@kurtbuilds kurtbuilds merged commit 60928b6 into kurtbuilds:master Jan 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants