File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -159,9 +159,14 @@ pub fn get_or_default_sysroot() -> PathBuf {
159159 } )
160160 }
161161
162- match canonicalize ( env:: current_exe ( ) . ok ( ) ) {
163- Some ( mut p) => { p. pop ( ) ; p. pop ( ) ; p }
164- None => bug ! ( "can't determine value for sysroot" )
162+ match env:: current_exe ( ) {
163+ Ok ( exe) => {
164+ match canonicalize ( Some ( exe) ) {
165+ Some ( mut p) => { p. pop ( ) ; p. pop ( ) ; return p; } ,
166+ None => bug ! ( "can't determine value for sysroot" )
167+ }
168+ }
169+ Err ( ref e) => panic ! ( format!( "failed to get current_exe: {}" , e) )
165170 }
166171}
167172
Original file line number Diff line number Diff line change @@ -253,7 +253,12 @@ pub fn current_exe() -> io::Result<PathBuf> {
253253
254254#[ cfg( any( target_os = "linux" , target_os = "android" , target_os = "emscripten" ) ) ]
255255pub fn current_exe ( ) -> io:: Result < PathBuf > {
256- :: fs:: read_link ( "/proc/self/exe" )
256+ let selfexe = PathBuf :: from ( "/proc/self/exe" ) ;
257+ if selfexe. exists ( ) {
258+ :: fs:: read_link ( selfexe)
259+ } else {
260+ Err ( io:: Error :: new ( io:: ErrorKind :: Other , "no /proc/self/exe available. Is /proc mounted?" ) )
261+ }
257262}
258263
259264#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
You can’t perform that action at this time.
0 commit comments