Summary
Passing a relative path on the command line opens the welcome screen instead of
the document. An absolute path works.
cd /some/dir
markview notes.md # -> "Welcome to MarkView", file ignored
markview /some/dir/notes.md # -> renders correctly
This also breaks file-manager / mc integration, where the file name is usually
passed relative to the current directory.
Where it likely comes from
src-tauri/src/lib.rs stores std::env::args()[1] as-is:
let args: Vec<String> = std::env::args().collect();
if args.len() > 1 {
let path = &args[1];
if is_markdown(path) { /* stored verbatim */ }
}
commands::read_file then does fs::read_to_string(&path), which resolves a
relative path against the process CWD. I did not confirm what the CWD ends up
being inside the AppImage, but since an absolute path is the only thing that
works, I suspect it is not the directory the user launched from.
The same applies to the single_instance handler, which ignores the cwd
argument it is given:
.plugin(tauri_plugin_single_instance::init(|app, argv, _cwd| {
Suggested fix
Resolve the argument to an absolute path at startup, e.g.
std::fs::canonicalize(path), or join it with the captured CWD before storing
it. In the single-instance handler, use the provided cwd instead of ignoring it.
Environment
- MarkView 1.0.5, Linux (AppImage), also reproducible after the EGL workaround
from issue #<other>, so the two are unrelated.
Summary
Passing a relative path on the command line opens the welcome screen instead of
the document. An absolute path works.
This also breaks file-manager / mc integration, where the file name is usually
passed relative to the current directory.
Where it likely comes from
src-tauri/src/lib.rsstoresstd::env::args()[1]as-is: