Skip to content

Don't leak RUST_LOG into supervisor #8541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2025
Merged

Don't leak RUST_LOG into supervisor #8541

merged 3 commits into from
Jul 16, 2025

Conversation

jmcphers
Copy link
Collaborator

This change removes the RUST_LOG environment variable from the kernel supervisor's environment. It is (now) unnecessary since we already use a command-line argument to set the log level, and because kernels inherit the supervisor's environment, it can affect the log level of Rust-based programs invoked from the kernels (such as uv).

Addresses #8538.

Release Notes

New Features

  • N/A

Bug Fixes

  • Remove superfluous RUST_LOG environment variable from R and Python sessions

QA Notes

  • It should still be possible to specify RUST_LOG manually via e.g. the Environment Variables feature
  • The R extension sets a value for RUST_LOG as well, so you'll see that value in R sessions
  • The main thing to verify here, in addition to RUST_LOG no longer being overridden, is that the kernel's log level setting still works

@jmcphers jmcphers requested a review from sharon-wang July 15, 2025 23:59
Copy link

github-actions bot commented Jul 15, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

Copy link
Member

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python

>>> import os
>>> os.getenv("RUST_LOG")
# nothing returned ✅ 

R

> Sys.getenv("RUST_LOG")
[1] "warn,ark=warn"
  • this looks to be in line with
    // Check the R kernel log level setting
    const config = vscode.workspace.getConfiguration('positron.r');
    const logLevel = config.get<string>('kernel.logLevel') ?? 'warn';
    const logLevelForeign = config.get<string>('kernel.logLevelExternal') ?? 'warn';
    const userEnv = config.get<object>('kernel.env') ?? {};
    const profile = config.get<string>('kernel.profile');
    /* eslint-disable */
    const env = <Record<string, string>>{
    'RUST_BACKTRACE': '1',
    'RUST_LOG': logLevelForeign + ',ark=' + logLevel,

Kernel Supervisor

"kernelSupervisor.logLevel": "error"

2025-07-15 18:10:27.111 [info] Positron Kernel Supervisor activated
2025-07-15 18:10:27.111 [info] 01:10:27 [Positron] Generated connection file path: /var/folders/07/9qwx1rk15rjd0mly1bjwycgc0000gp/T/kallichore-51c34b02-89346.json
2025-07-15 18:10:27.111 [info] 01:10:27 [Positron] Using native IPC transport: unix sockets
2025-07-15 18:10:27.111 [info] 01:10:27 [Positron] Starting Kallichore server /Users/sashimi/dev/positron-dev/extensions/positron-supervisor/resources/kallichore/kcserver with connection file /var/folders/07/9qwx1rk15rjd0mly1bjwycgc0000gp/T/kallichore-51c34b02-89346.json
01:10:30 [Positron] Read domain socket connection information from /var/folders/07/9qwx1rk15rjd0mly1bjwycgc0000gp/T/kallichore-51c34b02-89346.json: /var/folders/07/9qwx1rk15rjd0mly1bjwycgc0000gp/T/kc-89411.sock, constructed base path: http://unix:/var/folders/07/9qwx1rk15rjd0mly1bjwycgc0000gp/T/kc-89411.sock:
01:10:30 [Positron] Kallichore 0.1.51 server online with 0 sessions
01:10:30 [Positron] Running as pid 89411 (terminal pid 89357)
01:10:30 [Positron] Kallichore server started in 2953ms
01:10:30 [Positron] Streaming Kallichore server logs from /var/folders/07/9qwx1rk15rjd0mly1bjwycgc0000gp/T/kallichore-51c34b02-89346.log (log level: error)
01:10:30 [Positron] Creating session: {"sessionId":"r-31d848ad","sessionMode":"console","createdTimestamp":1752628227673,"startReason":"Affiliated R runtime for workspace"}

"kernelSupervisor.logLevel": "info"

...
01:12:21 [INFO] Server set to shut down after 1 hours of inactivity
01:12:22 [INFO] new_session("r-8b94a031") - X-Span-ID: "9e505a79-a5fb-43f3-bc2b-3d1990e7aef6"
01:12:22 [INFO] start_session("r-8b94a031") - X-Span-ID: "fc6b5ec8-5649-4532-827d-872b2a57d1b1"
01:12:22 [INFO] [session r-8b94a031] Kernel supports JEP 66 (protocol version 5.5) - creating registration socket for handshake
01:12:22 [INFO] [session r-8b94a031] Waiting for JEP 66 handshake
...

"kernelSupervisor.logLevel": "trace"

...
01:13:48 [INFO] [session r-ca992a61] Waiting for JEP 66 handshake
01:13:48 [DEBUG] (8) kcserver::kernel_session: End of output stream (kind: Stdout)
01:13:48 [DEBUG] (8) kcserver::kernel_session: End of output stream (kind: Stderr)
01:13:48 [INFO] Received handshake request from kernel
01:13:48 [INFO] [session r-ca992a61] Sending successful handshake reply to kernel
01:13:48 [INFO] [session r-ca992a61] Handshake completed successfully
01:13:48 [INFO] [session r-ca992a61] JEP 66 handshake completed successfully
01:13:48 [TRACE] (8) kcserver::kernel_session: [crates/kcserver/src/kernel_session.rs:715] [session r-ca992a61] Waiting for kernel sockets to connect
...

@sharon-wang
Copy link
Member

Pulling in main should resolve the unit test failure!

@jmcphers jmcphers merged commit b8a8e83 into main Jul 16, 2025
10 checks passed
@jmcphers jmcphers deleted the feature/rust-log-leak branch July 16, 2025 22:54
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants