shadowsocks/shadowsocks-rust · error
`method` is required
Error message
`method` is required
What it means
After mapping the optional `ENCRYPT_METHOD` value, the code calls `.expect("`method` is required")`. This panics when `--server-addr` was given on the CLI but `--encrypt-method` was not — the inner map produced None. The server requires a cipher method when a server is defined via command-line arguments.
Source
Thrown at src/service/server.rs:337
}
None => {
logging::init_with_config("ssserver", &service_config.log);
}
}
trace!("{:?}", service_config);
let mut config = match config_path_opt {
Some(cpath) => Config::load_from_file(&cpath, ConfigType::Server)
.map_err(|err| ShadowsocksError::LoadConfigFailure(format!("loading config {cpath:?}, {err}")))?,
None => Config::new(ConfigType::Server),
};
if let Some(svr_addr) = matches.get_one::<String>("SERVER_ADDR") {
let method = matches
.get_one::<String>("ENCRYPT_METHOD")
.map(|x| x.parse::<CipherKind>().expect("method"))
.expect("`method` is required");
let password = match matches.get_one::<String>("PASSWORD") {
Some(pwd) => read_variable_field_value(pwd).into(),
None => {
// NOTE: svr_addr should have been checked by crate::vparser
if method.is_none() {
// If method doesn't need a key (none, plain), then we can leave it empty
String::new()
} else {
match crate::password::read_server_password(svr_addr) {
Ok(pwd) => pwd,
Err(..) => panic!("`password` is required for server {svr_addr}"),
}
}
}
};
let svr_addr = svr_addr.parse::<ServerAddr>().expect("server-addr");View on GitHub (pinned to 8eb0f0a65b)
Solutions
- Add `--encrypt-method aes-256-gcm` (or another supported cipher) to the command line
- Or use a config file with the `method` field instead of CLI flags
- In scripts, assert the method variable is non-empty before invoking ssserver
Example fix
// before ssserver -s "0.0.0.0:8388" -p "pass" // after ssserver -s "0.0.0.0:8388" -p "pass" -m aes-256-gcm
Defensive patterns
Strategy: validation
Validate before calling
// enforce method presence when server-addr is used
if cli.server_addr.is_some() {
assert!(cli.method.is_some(), "--encrypt-method is required with --server-addr");
} Type guard
fn method_present(addr: Option<&str>, method: Option<&str>) -> bool {
addr.is_none() || method.is_some()
} Try / catch
null
Prevention
- Always pair -s with -m when defining a server via CLI
- Prefer config files, which enforce required fields with clearer errors
- Add the pair check to deployment scripts
When it happens
Trigger: Running `ssserver -s 0.0.0.0:8388 -p password` without `--encrypt-method`/-m; the server address path is taken but no method was supplied.
Common situations: New users omitting `-m` because a config file normally supplies it; scripts that pass the server address but forget the method; migrating from tools with implicit default ciphers.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- method
- method
- not supported `protocol` "{p}"
- `local-addr` is required for protocol {}
- `password` is required for server {svr_addr}
AI-assisted analysis of shadowsocks/shadowsocks-rust@8eb0f0a65b (2026-09-09).
Data as JSON: /api/errors/b781f6012dd4ccb3.
Report an issue: GitHub.