{"record":{"id":"23c3338fd6313141","repo":"shadowsocks/shadowsocks-rust","slug":"cannot-get-absolute-path-to-working-directory-er","errorCode":null,"errorMessage":"cannot get absolute path to working directory, {err:?}","messagePattern":"cannot get absolute path to working directory, (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/daemonize/unix.rs","lineNumber":14,"sourceCode":"use std::{env::current_dir, path::Path};\n\nuse super::daemonize::Daemonize;\nuse log::error;\n\n/// Daemonize a server process in a *nix standard way\n///\n/// This function will redirect `stdout`, `stderr` to `/dev/null`,\n/// and follow the exact behavior in shadowsocks-libev\npub fn daemonize<F: AsRef<Path>>(pid_path: Option<F>) {\n    let pwd = current_dir()\n        .unwrap_or_else(|err| panic!(\"cannot get current working directory, {err:?}\"))\n        .canonicalize()\n        .unwrap_or_else(|err| panic!(\"cannot get absolute path to working directory, {err:?}\"));\n    let mut d = Daemonize::new().umask(0).working_directory(pwd);\n\n    if let Some(p) = pid_path {\n        d = d.pid_file(p);\n    }\n\n    if let Err(err) = d.start() {\n        error!(\"failed to daemonize, {:?} ({})\", err, err);\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/daemonize/unix.rs#L1-L25","documentation":"After fetching the current directory, `daemonize` calls `.canonicalize()` to obtain the absolute path and panics if that fails. Canonicalization fails if the path does not exist, is a broken symlink chain, or the process lacks permission to traverse a component. Like the previous error, it is a fail-fast startup guard for daemon mode.","triggerScenarios":"Calling public `daemonize(pid_path)` when `current_dir().canonicalize()` returns Err — the cwd path contains a broken symlink, was unmounted, or traversal permission is denied at startup time.","commonSituations":"Running from a symlinked directory whose target was deleted; cwd on an unmounted/removable filesystem; restricted permissions on a parent directory when starting the daemon.","solutions":["Start the server from a stable, existing directory (cd /tmp or / first)","Remove or fix broken symlinks in the working directory path","Ensure the process user can traverse all path components of the cwd","Skip daemon mode and use a service manager (systemd) with its own WorkingDirectory"],"exampleFix":"// before\nExecStart=/usr/bin/shadowsocks-local -c /etc/ss/config.json -d\nWorkingDirectory=/opt/deleted-dir\n// after\nExecStart=/usr/bin/shadowsocks-local -c /etc/ss/config.json -d\nWorkingDirectory=/var/lib/shadowsocks","handlingStrategy":"validation","validationCode":"let pwd = std::env::current_dir()?.canonicalize()?; // precheck before calling daemonize()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fix broken symlinks in the startup directory","Set an explicit WorkingDirectory in service units","Ensure the daemon user can traverse the cwd path","Start daemons from static filesystems, not removable mounts"],"tags":["panic","daemonize","unix","filesystem"],"backgroundTag":"directory-not-found","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}