[solana-install-init] Optimize error message for Windows user permission installation#234
[solana-install-init] Optimize error message for Windows user permission installation#234joncinque merged 4 commits intoanza-xyz:masterfrom
Conversation
|
I'd appreciate some assistance, such as which approach is better, or both are equally good. Thank you very much. |
joncinque
left a comment
There was a problem hiding this comment.
Thanks for your contribution! I like the approach of catching the error. I've added a little suggestion to help document the behavior a bit more
joncinque
left a comment
There was a problem hiding this comment.
Just two more little things -- this is very close!
| #[cfg(windows)] | ||
| Some(os_err) => if os_err == winapi::shared::winerror::ERROR_PRIVILEGE_NOT_HELD { | ||
| "You need to run this command with administrator privileges.".to_string() | ||
| } else { | ||
| format!( | ||
| "Unable to symlink {:?} to {:?}: {}", | ||
| release_dir, | ||
| config.active_release_dir(), | ||
| err | ||
| ) | ||
| }, |
There was a problem hiding this comment.
You can do match with a conditional avoid the copying of the fallback error, ie:
| #[cfg(windows)] | |
| Some(os_err) => if os_err == winapi::shared::winerror::ERROR_PRIVILEGE_NOT_HELD { | |
| "You need to run this command with administrator privileges.".to_string() | |
| } else { | |
| format!( | |
| "Unable to symlink {:?} to {:?}: {}", | |
| release_dir, | |
| config.active_release_dir(), | |
| err | |
| ) | |
| }, | |
| #[cfg(windows)] | |
| Some(os_err) if os_err == winapi::shared::winerror::ERROR_PRIVILEGE_NOT_HELD => { | |
| "You need to run this command with administrator privileges.".to_string() | |
| }, |
More info at https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards
There was a problem hiding this comment.
Thank you very much, this is so important.
In fact, I started developing with windows, but I found that these codes could not be compiled correctly on windows because some build.rs would report errors.
…ion installation (anza-xyz#234) * feat: check user's permissions in Windows * feat: Remove check fun and check os_err * fmt and optimize code

Problem
When users attempt to execute this command without administrator privileges, it results in error code 1314.
Most users find it challenging to promptly recognize that this issue stems from permission limitations.
Summary of Changes
Therefore, I propose two possible solutions:
Your valuable feedback on these proposed solutions would be greatly appreciated.