close

Slick­Stack

June 2025 promo! Join our Discord free of charge.

Slick­Stack
Lightning-fast WordPress on Nginx

cp: warning: behavior of -n is non-portable and may change in future

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #24958
    Catherine
    Guest

    seeing this on new installs

    cp: warning: behavior of -n is non-portable and may change in future; use --update=none instead

    #24960
    Juan
    Guest

    I think -n is for GNU, since cp was ported from POSIX. But pretty sure Ubuntu and Debian have supported that flag for many years already?

    #24961
    Judith
    Guest

    According to mailing lists,

    https://www.mail-archive.com/[email protected]/msg33577.html

    The new --update=none doesn’t even work correctly and is overwriting files so I don’t think it’s a good idea to use that flag either!

    #24962
    Gregory
    Guest

    weird, as cp has been around forever…

    #24963
    Juan
    Guest

    Some of the Debian maintainers discussed this on Reddit a few months ago. They are saying it seems to be a bug and should be fixed in future versions. I don’t know how such a verbose warning message could be a bug, but if I understand correctly that’s what they are saying:

    Warning on cp when upgrading
    byu/AdbekunkusMX indebian

    #24964
    Jacqueline
    Guest

    Some of the Debian maintainers discussed this on Reddit a few months ago. They are saying it seems to be a bug and should be fixed in future versions.

    On second reading, I’m not sure they are saying it’s a bug.

    But maybe just that apt using cp -n is a bug. It’s not really clear.

    #25079
    Frank
    Guest

    what are they asking for? cp --update=none instead of cp -n is that?

    #26694
    Wayne
    Guest

    DO NOT DO WHAT THIS WARNING TELLS YOU TO DO!!!

    YOU MIGHT BREAK YOUR STACK OR LOSE DATA THIS WARNING IS A BUG

    #27511
    Cynthia
    Guest

    The warning is NOT a bug. The -n or --no-clobber really is deprecated with planned removal from cp in the future. However, their suggested fix with --update=none has been reported as having bugs.

    For this reason, and the fact that --update=none is NOT backwards compatible (it is not recognized on Ubuntu 22.04, 20.04, 18.04 etc) SlickStack has taken another route:

    
    ## ss_cp_if_not_exists (avoids deprecated -n option) ##
    function ss_cp_if_not_exists {
        command mkdir -p "$(dirname "$2")" && command test ! -e "$2" && command cp "$1" "$2"
    }

    This approach simply avoids the problems altogether 😉

    Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-functions.txt

    Because if you try to use --update=none on those older Ubuntu versions, well it will fail and you will see this error:

    cp: option ‘–update’ doesn’t allow an argument
    Try ‘cp –help’ for more information.

    #27512
    Russell
    Guest
    #27513
    Tyler
    Guest
Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: cp: warning: behavior of -n is non-portable and may change in future

Thanks to our generous sponsors for their support!