If you’re getting an error that reads “ERR wrong number of arguments for ‘smove’ command” in Redis, it’s because you’re calling the SMOVE
command with the wrong number of arguments.
To fix this issue, make sure you’re passing the correct number of arguments. At the time of writing, the correct number of arguments for this command is three.
Example of Error
Here’s an example of code that produces the above error:
SMOVE todo done Kate Ash
Result:
(error) ERR wrong number of arguments for 'smove' command
The error tells us what we did wrong. We passed four arguments, but the command only accepts three.
We get the same error if we call the command without any arguments:
SMOVE
Result:
(error) ERR wrong number of arguments for 'smove' command
Solution
To fix the issue, simply pass the correct number of arguments. The SMOVE
command accepts three arguments. The syntax goes like this:
SMOVE source destination member
So here’s an example of calling the command with the correct number of arguments:
SMOVE todo done Jim
Result:
(integer) 1
Here, I provided the correct number of arguments and we got the desired result without error. The member Jim
was moved from the key called todo
to the key called done
.
At the time of writing, SMOVE
accepts three arguments as shown above. See the Redis documentation to check the latest specification for this command (in case anything changes after this article is published).