`Plot::show()` panics when no opener binary exists, and silently no-ops when it fails
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Rust
- Estrellas
- 1.5k
- Forks
- 128
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Plot::show() offers no way for a caller to handle a failed browser handoff.
Running it on a headless server causes a panic, but the panic message is misleading.
How to reproduce
use plotly::{Plot, Scatter};
fn main() {
let mut plot = Plot::new();
plot.add_trace(Scatter::new(vec![0, 1, 2], vec![0.0, 1.5, 3.0]));
plot.show();
}
Run on a headless Linux host with no xdg-open on PATH 👍
thread 'main' panicked at .../plotly-0.14.1/src/plot.rs:789:14:
Could not find default application for HTML files.
[...]
: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Environment
- plotly 0.14.1
- rustc 1.98.0
- AlmaLinux 9.8
Expected
A library call should not abort the process over a missing external binary. The caller should have
some way to detect this and potentially fall back to write_html() or write_image() on its own or
show a clear error message.
Cause
There are two problems with it:
-
Missing binary panics:
.output()returnsErronly when the process cannot be
spawned, i.e.xdg-openis not onPATH..expect()turns that into a panic, and
show()returns(), so a caller has nothing to match on.
The resulting error message is very misleading here: https://github.com/plotly/plotly.rs/blob/00fe0512e9f924bd0fc2edfc6cc617a1604f4e0d/plotly/src/plot.rs#L57-L65 -
Return code of the xdg-open is ignored: If
xdg-openis installed but exits non-zero
(e.g. when no application is registered for HTML) it still returnsOk, carrying
the failure insideOutput::status, but status is never read.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en plotly/src/plot.rs, en la implementación referenciada de Plot::show(), e inspecciona las ramas de Linux, macOS y Windows, incluidas las definiciones de errores cerca de las líneas 57-65. Reproduce el caso de Linux headless y, después, verifica que los binarios opener ausentes y los estados de opener distintos de cero se comuniquen a los llamadores en lugar de provocar un panic o ignorarse silenciosamente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 62/100