Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

a way to give RLS environment settings #915

Closed
Geobert opened this issue Jun 20, 2018 · 7 comments
Closed

a way to give RLS environment settings #915

Geobert opened this issue Jun 20, 2018 · 7 comments

Comments

@Geobert
Copy link

Geobert commented Jun 20, 2018

Some month ago, I faced some weird bugs in VSCode with extension stop working (no reference, no completion, no occurrence). I don't know how it was possible that it has ever work before as the fix was to launch VSCode in a shell with the environment being set, via a batch file:

@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
start "" code %*

So RLS has the proper MS tools to work with.

It's not very convenient nor straightforward and I'm opening this issue to try to improve RLS on this matter.

Any thought?

Thank you for reading :)

@nrc
Copy link
Member

nrc commented Jun 21, 2018

To be clear, you want a way to set environment variables passed to the RLS from VSCode? If so that is a fairly easy change to the VSCode plugin. Happy to give instructions if you want to make a PR.

@Geobert
Copy link
Author

Geobert commented Jun 21, 2018

I don't know, is VSCode capable of loading a bat file to configure it's environment once it has been launched? As for a PR, I don't know Typescript nor Javascript at all (last time I've done something in JS was in the 90's to make stuff on mouse over… so you got an idea of my level in these languages ^^')

@nrc
Copy link
Member

nrc commented Jun 26, 2018

Would it be enough to take a list of env vars and values and set them in the extension, rather than running a bat file?

@Geobert
Copy link
Author

Geobert commented Jun 26, 2018

I may be enough, I'm not sure, the bat file is pretty big:
vcvarsall.zip

@vimmerru
Copy link

vimmerru commented Sep 6, 2018

My use case:

  • I need to build project that uses libsodium, openssl, zmq and similar native libraries
  • On windows -sys crates asks for environment variables with libraries placement like OPENSSL_DIR, SODIUM_DIR and etc

For now i don't have clear way how to provide this environment to RLS. It just says "Can't compile external crate" and no any features works

@ray-kast
Copy link

Here's a quick 'n' dirty fix for setting RLS environment variables on Linux:

(it's essentially just launching VSCode itself with the variables exported)

export OPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0
export OPENSSL_LIB_DIR=/usr/lib/openssl-1.0

code .

It's not a great fix (or a viable long-term solution by any means), but it works.

@Xanewok
Copy link
Member

Xanewok commented Mar 3, 2019

I don't think we should support an ad-hoc way to specify the environment inside the RLS itself - this doesn't solve the case of wrapper scripts (you wouldn't expect to run the vcvars and copy them over to some config file)

I believe how you invoke RLS should be configured by the editors with rls-vscode supporting rlsPath config (which I also use to run a custom RLS for development).

@Xanewok Xanewok closed this as completed Mar 3, 2019
rib added a commit to rib/cargo that referenced this issue Nov 7, 2020
Some custom build scripts (especially for -sys packages) expect to
query environment variables to locate build resources (such as
pre-built binaries) but these cause lots of trouble when considering
the numerous different ways in which cargo may be invoked.

For example each editor that invokes cargo as part of providing
development diagnostics needs to offer some way to configure environment
variables or users need to find their own way of controlling the environment
variables of these different tools which is burdensome and can lead
to an inconsistent duplication of state across tools.

This introduces support for reading an (optional) environment.json found
at the root of the current workspace that may contain a map of
environment variable key, value pairs. These variables will be exported
to all build scripts run under the workspace. The removes any need to
configure tools and editors independently.

The configuration is separate from any Config.toml since it's likely
that the state shouldn't be under version control in many situations
(generally locating resources for the project within a specific user's
development environment).

Fixes: rust-lang/issues/4121
Fixes: rust-lang/rls/issues/915
Fixes: rust-lang/vscode-rust/issues/791
Fixes: rust-lang/rust-analyzer/pull/6099
Fixes: intellij-rust/intellij-rust/issues/1569
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants