File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ dialoguer = "0.11"
19
19
libloading = " 0.8"
20
20
cargo_metadata = " 0.20"
21
21
semver = " 1.0"
22
+ sudo = " 0.6.0"
22
23
23
24
[lints .rust ]
24
25
missing_docs = " warn"
Original file line number Diff line number Diff line change @@ -221,9 +221,16 @@ impl Install {
221
221
ext_dir. push ( ext_name) ;
222
222
}
223
223
224
- std:: fs:: copy ( & ext_path, & ext_dir) . with_context ( || {
225
- "Failed to copy extension from target directory to extension directory"
226
- } ) ?;
224
+ // We copying of file fails, escalate the privilege and try again.
225
+ if let Err ( _) = std:: fs:: copy ( & ext_path, & ext_dir) {
226
+ // failed to copy. escalate the privileges and try again.
227
+ #[ cfg( unix) ]
228
+ let _ = sudo:: escalate_if_needed ( ) . ok ( ) ;
229
+
230
+ std:: fs:: copy ( & ext_path, & ext_dir) . with_context ( || {
231
+ "Failed to copy extension from target directory to extension directory"
232
+ } ) ?;
233
+ }
227
234
228
235
if let Some ( php_ini) = php_ini {
229
236
let mut file = OpenOptions :: new ( )
You can’t perform that action at this time.
0 commit comments