Search code examples
rubygemsbundleryank

gem yank (<3.1.0) returns "You have enabled multifactor authentication but no OTP code provided" but you can't provide one on the command line


error:

You have enabled multifactor authentication but no OTP code provided. Please fill in an retry.

this happens if your Gem is < 3.9.0 and you try to yank

enter image description here

As you can see, if you provide the option --opt, it still doesn't work, because it tells you that --otp is an invalid option

invalid option: --otp=112914

Solution

  • this happens if your gem version is < 3.1.0

    it has been fixed in rubygems 3.1.0

    note that as it is a self-updating binary, the way to update it is with

    gem update --system
    

    to check your version use

    gem -v
    

    This is a known-issue has been fixed in Gem version 3.1.0

    if you have gem < 3.1.0 and for some reason, you can't update, there is no work-around. The counter-intuitive thing here is that for the gem push with OTP, if you fail to specify an OTP you get a little interactive OTP input on the command line. Confusingly, if you suffer from this problem, gem yank tells you you didn't supply an OTP and also tells you that --otp isn't a valid option.