I am creating a plugin for swc. It fails and I was told to add an environment variable for debugging. RUST_LOG=trace and SWC_DEBUG=1 Where should I put these variables? To what file? If I write them before "cargo test" - an error, an unrecognized command. help me please
Asked
Active
Viewed 302 times
0
-
1Environment variables are the responsibility of the operating system. If you're in a standard Bash shell, you can just write the environment variable assignment on the same line as your command and it'll work. On Windows, I believe you'll have to do the assignment on a different line in the same terminal (been awhile since I did any dev work on Windows). – Silvio Mayolo May 09 '23 at 04:31
1 Answers
2
If you are running your code on Unix, you need to add them in terminal right before execution command.
E.g.: RUST_LOG=trace SWC_DEBUG=1 cargo test
or RUST_LOG=trace SWC_DEBUG=1 ./my_program_name
.
If you running your code from Powershell on Windows, it is not so easy and requires 2 commands:
> $env:RUST_LOG=trace
> $env:SWC_DEBUG=1
> cargo test
You may read more about them on wiki.

Angelicos Phosphoros
- 2,469
- 9
- 24
-
Thank you! I set a variable in windows. Can you please tell me where are the logs? Are they saved to a file or written to the console? I do not see anything – Roman May 09 '23 at 05:14
-
@Roman I don't really know, I just shown how to work with environmental variables in general but I don't know anything `swc` specific. – Angelicos Phosphoros May 09 '23 at 08:24