@@ -15,16 +15,9 @@ const {
15
15
/** @type {number } interval between toolchain update checks, milliseconds */
16
16
const PERIODIC_UPDATE_CHECK_MILLIS = 6 * 60 * 60 * 1000
17
17
18
- function getPath ( ) {
19
- // Make sure the cargo directory is in PATH
20
- let { PATH } = process . env
21
- PATH = PATH + ":" + path . join ( os . homedir ( ) , ".cargo/bin" )
22
- return PATH
23
- }
24
-
25
18
async function exec ( command ) {
26
19
return new Promise ( ( resolve , reject ) => {
27
- cp . exec ( command , { env : { PATH : getPath ( ) } } , ( err , stdout , stderr ) => {
20
+ cp . exec ( command , { env : { PATH : envPath ( ) } } , ( err , stdout , stderr ) => {
28
21
if ( err != null ) {
29
22
reject ( err )
30
23
return
@@ -101,16 +94,23 @@ async function rustcSysroot(toolchain) {
101
94
return stdout . trim ( )
102
95
}
103
96
97
+ /** @return {string } environment variable path */
98
+ let envPath = ( ) => {
99
+ // Make sure the cargo directory is in PATH
100
+ let envPath = process . env . PATH || ''
101
+ if ( ! envPath . includes ( ".cargo/bin" ) )
102
+ envPath += `:${ path . join ( os . homedir ( ) , ".cargo/bin" ) } `
103
+ return envPath
104
+ }
105
+
104
106
/**
105
107
* @param {string } [toolchain]
106
108
* @return {Promise<object> } environment vars
107
109
*/
108
110
async function serverEnv ( toolchain ) {
109
- const env = {
110
- PATH : getPath ( ) ,
111
- RUST_BACKTRACE : '1' ,
112
- RUST_LOG : process . env . RUST_LOG ,
113
- }
111
+ const env = process . env
112
+ env . PATH = envPath ( )
113
+ env . RUST_BACKTRACE = env . RUST_BACKTRACE || "1"
114
114
115
115
if ( ! env . RUST_LOG && atom . config . get ( 'core.debugLSP' ) ) {
116
116
env . RUST_LOG = 'rls=warn'
@@ -631,6 +631,15 @@ if (process.platform === "win32") {
631
631
! filePath . includes ( '\\target\\release\\' )
632
632
}
633
633
634
+ // handle different slashes & path separator
635
+ envPath = ( ) => {
636
+ // Make sure the cargo directory is in PATH
637
+ let envPath = process . env . PATH || ''
638
+ if ( ! envPath . includes ( ".cargo\\bin" ) )
639
+ envPath += `;${ path . join ( os . homedir ( ) , ".cargo" , "bin" ) } `
640
+ return envPath
641
+ }
642
+
634
643
// curl | sh is not valid for windows, users must install rustup manually
635
644
RustLanguageClient . prototype . _handleMissingRustup = ( ) => {
636
645
atomPrompt ( "`rustup` is not available" , {
0 commit comments