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"
1919libloading = " 0.8"
2020cargo_metadata = " 0.20"
2121semver = " 1.0"
22+ sudo = " 0.6.0"
2223
2324[lints .rust ]
2425missing_docs = " warn"
Original file line number Diff line number Diff line change @@ -221,9 +221,16 @@ impl Install {
221221 ext_dir. push ( ext_name) ;
222222 }
223223
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+ }
227234
228235 if let Some ( php_ini) = php_ini {
229236 let mut file = OpenOptions :: new ( )
You can’t perform that action at this time.
0 commit comments