-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(tauri-plugin): do not modify src #13597
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
base: dev
Are you sure you want to change the base?
Conversation
Package Changes Through 7525e6cThere are 8 changes which include tauri-bundler with minor, tauri-cli with minor, tauri-codegen with minor, tauri-utils with minor, @tauri-apps/cli with minor, tauri with minor, @tauri-apps/api with minor, tauri-runtime-wry with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly get this is a bad practice but I don't have a good idea about how to fix it
I am thinking, maybe we can put the schema and command permission auto gen behind a feature flag, and let people enable it through dev-dependencies
so that it's only used in dev, this should somewhat mitigate the problem, but honestly, there're many more places where we modify things outside of OUT_DIR
that are kinda necessary, so I don't know how much would it help
crates/tauri-plugin/src/build/mod.rs
Outdated
let permissions = acl::build::define_permissions( | ||
&format!("{}/permissions/**/*.*", out_dir.display()), | ||
&name, | ||
&out_dir, | ||
|_| true, | ||
)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have 2 types of permissions, the auto generated ones from the commands (e.g. in your build script, you defined a command ping
, it will generate allow-ping
and deny ping
), and the ones you write yourself, we will need to keep this path
crates/tauri-plugin/src/build/mod.rs
Outdated
acl::PERMISSION_SCHEMAS_FOLDER_NAME, | ||
acl::PERMISSION_SCHEMA_FILE_NAME | ||
)); | ||
let _ = std::fs::remove_file(autogenerated.join(acl::build::PERMISSION_DOCS_FILE_NAME)); | ||
} else { | ||
acl::schema::generate_permissions_schema(&permissions, "./permissions")?; | ||
acl::schema::generate_permissions_schema(&permissions, out_dir.join("permissions"))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The schema are there to help you write your own permissions, putting it the OUT_DIR
makes it impossible to use since the location of it is not fixed
i also wasn't involved in most things that write into src-tauri instead of out_dir but in other places we later changed the logic to first check if the content actually changed before writing to disk, would that help for the linked issue? |
I would say that it is necessary for I have a crate that depends on I'm not sure if I'm correct, but I think the only things being modified outside of For
I think that could help? at least in resolving the issue on BTW, is it possible to resolve this issue soon? Or would Tauri be okay with me temporarily mitigating the error on |
Seems like the error was that it's trying to write the schema, I'm not sure why though since we do publish the schemas as well as having
I recently discovered that the android build script will put tauri's android files to plugin's android folder (which I don't understand why), I'm not entirely sure how many more things are not written to the |
The generated permission schema may be different from the one published on crates.io. If a plugin is built as a dependency, we do not want to (or cannot) modify the source directory. Skip writing the file in that case.
Thanks for the quick review. I changed this patch to instead rely on |
According to tauri-apps/plugins-workspace#2771 (comment), I suspect that the versions of This explains why updating Using Finally, regarding this PR, why don't we apply |
This is true though
That wouldn't work, there're a lot more stuffs going on than just generating permission files (e.g. telling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll also need to guard generate_docs
, autogenerate_command_permissions
calls, basically, anything that would potentially change things outside of OUT_DIR
And as @WSH032 mentioned, this might be a breaking change if the plugin author didn't ship the automatically generated permission files before, so maybe we need to push the output of autogenerate_command_permissions
to define_permissions
as well (honestly I feel like we might need some reworks around this but I don't have much ideas about how right now)
I have to say, this is a bit confusing 🤐—if you're not familiar enough with Tauri, it's hard to figure out all the places that need to be handled.
Personally, I don't think we should continue supporting this use case. In my opinion, the drawbacks far outweigh the benefits of semantic compatibility. (You'll get rejected by When I mentioned breaking change, I just meant we should update the documentation accordingly. In fact, even if we don't make this breaking change, we should still recommend in the docs that users track their |
Indeed, this part of tauri is quite hard to follow
I'm fine with either ways, don't mind the breaking either to be honest, also looking at the plugins at https://github.com/tauri-apps/awesome-tauri?tab=readme-ov-file#plugins, it seems like people do commit them in (probably because of the plugin template) I think for now, just guarding these parts with tauri/crates/tauri-plugin/src/build/mod.rs Lines 114 to 116 in 2212547
tauri/crates/tauri-plugin/src/build/mod.rs Lines 122 to 136 in 2212547
|
Write temporary permission files to out_dir instead of current directory. The current directory is the source directory and it should not be modified by the build.
Fixes #11187