File tree 2 files changed +14
-4
lines changed
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 {
159
159
} )
160
160
}
161
161
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) )
165
170
}
166
171
}
167
172
Original file line number Diff line number Diff line change @@ -253,7 +253,12 @@ pub fn current_exe() -> io::Result<PathBuf> {
253
253
254
254
#[ cfg( any( target_os = "linux" , target_os = "android" , target_os = "emscripten" ) ) ]
255
255
pub 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
+ }
257
262
}
258
263
259
264
#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
You can’t perform that action at this time.
0 commit comments