text:
Doubled-letter steganography
Steganography hides a given message inside a given carrier, producing a package that does not look suspicious. For this challenge, you will write a program that takes an ASCII message and an ASCII carrier as input, and return or print a package that is identical to the carrier except characters corresponding to the message are doubled, in the same order that they appear in the message.
Rules:

If the carrier already contains sequences of the same character more than once, and they are not used to encode a character of the message, the program will reduce them to a single character.
If the carrier does not contain the message characters in the right order, the program may return nothing, the carrier itself, or an error.
You may assume that the message and carrier are non-empty ASCII strings.
Capitalization matters: A is not equivalent to a.
When more than one package is valid, your program may output any or all of them.
Space is a character like any other character.

Test cases:

Message      Carrier              Package
"hi"         "has it arrived?"    "hhas iit arived?" OR "hhas it ariived?"
"sir"        "has it arrived?"    "hass iit arrived?"
"foo"        "has it arrived?"    "" OR "has it arrived?" OR an error.
"Car"        "Cats are cool."     "CCaats arre col."
"car"        "Cats are cool."     "" OR "Cats are cool." OR an error.
"Couch"      "Couch"              "CCoouucchh"
"oo"         "oooooooooo"         "oooo"
"o o"        "oooo oooa"          "oo  ooa"

This is code golf, so fewest bytes wins.

Not suspicious at all... :P

Is "oooo  oa" (with 2 spaces) a valid output for the last test case?

It is not a valid output because the order of doubled characters in the package must match the order of the characters in the message. In the message, we have an 'o', then an ' ', then an 'o', but your package has the space after the o's

Ah yes, that makes sense.

"If the carrier does not contain the message characters in the right order, the program may return nothing, the carrier itself, or an error." May it instead return the reduced carrier (with double characters converted to single characters)?

No. My reasoning behind this rule is that the program's output in the case of no solution should be unambiguous that no solution is possible. The three allowed outputs are unambiguous, but more extensive checking would be required for the deduplicated case.

Is "eerorr" a correct output for "er" "error"?

@tsh yes, "eerorr" is a valid output for message "er" and carrier "error" I.e. there is no requirement to use existing doubled characters when possible.

To be clear, "eerror" is also a valid output. Your program can produce either or both

Jelly, 28 bytes
ẹⱮŒp<ƝẠ$ƇṪ
nƝ+çṬ¥a⁸ḟ0Ḥç¦ð¹ç?

A full program taking carrier and message as command line arguments which prints the result
(For a non-packable message prints the unchanged carrier).
Try it online! Or see the test-suite.
How?
ẹⱮŒp<ƝẠ$ƇṪ - Link 1, helper function to find the indices to double: carrier, message
           -                               e.g. "programming", "rom"
 Ɱ         - map across message with:
ẹ          -   indices of                       [[2,5], [3], [7,8]]
  Œp       - Cartesian product                  [[2,3,7],[2,3,8],[5,3,7],[5,3,8]]
        Ƈ  - filter keep if:
       $   -   last two links as a monad:
     Ɲ     -     for neighbours:
    <      -       less than?                    [1,1]   [1,1]   [0,1]   [0,1]
      Ạ    -     all truthy?                     1       1       0       0
           -                                    [[2,3,7],[2,3,8]]
         Ṫ - tail (if empty yields 0)                    [2,3,8]

nƝ+çṬ¥a⁸ḟ0Ḥç¦ð¹ç? - Main Link: carrier, message
                ? - if...
               ç  - ...condition: last Link (the helper function) as a dyad
             ð    - ...then: perform the dyadic chain to the left (described below)
              ¹   - ...else: do nothing (yields carrier)
                  - (the then clause:)
 Ɲ                - for neighbours in the carrier
n                 - not equal?
     ¥            - last two links as a dyad:
   ç              -   call last Link (the helper function) as a dyad
    Ṭ             -   untruth (e.g. [2,5] -> [0,1,0,0,1])
  +               - add (vectorises)
      a⁸          - logical AND with carrier
        ḟ0        - filter out zeros
            ¦     - sparse application...
           ç      - ...to indices: call last Link (the helper function) as a dyad
          Ḥ       - ...do: double (e.g. 'x' -> 'xx')

JavaScript (ES6), 71 bytes
Takes input as (message)(carrier).
s=>g=([c,...C],p)=>c?(c==s[0]?(s=s.slice(1),c)+c:p==c?'':c)+g(C,c):s&&X

Try it online!

Alternate version, 66 bytes
If we can take the message as an array of characters:
s=>g=([c,...C],p)=>c?(c==s[0]?s.shift()+c:p==c?'':c)+g(C,c):s+s&&X

Try it online!

Edit: Thanks to @tsh for noticing that I forgot to remove some code when switching from non-recursive to recursive versions.

You could remove p= since p is passed by a parameter.

@tsh Oops. It's some residual code from the previous, non-recursive versions that I forgot to remove. Thank you!

Haskell, 124 121 107 101 97 95 90 bytes
(#).(++"ü")
"ü"#[]=[]
p@(m:n)#e@(c:d)|m/=c=c:p#snd(span(==c)d)|m==n!!0=m:m:n#d|1<2=m:n#e

Raises the "Non-exhaustive patterns" exception if the carrier does not contain the message.
Try it online!
Edit: -5 bytes thanks to @Laikoni.

I think switching the cases allows you to drop m==c: Try it online!

Retina 0.8.2, 67 bytes
+`(.)(\1*)\1*(.*¶)(?(\1)(\1(\2)))(.*)$(?!¶)
$1$4$5¶$3$6
M!s`.*¶$
¶

Try it online! Takes the carrier on the first line and the message on the second line. Explanation:
+`(.)(\1*)\1*(.*¶)(?(\1)(\1(\2)))(.*)$(?!¶)
$1$4$5¶$3$6

Process runs of 1 or more identical characters of the carrier. If there is also a run of 1 or more of the same characters in the message, then append the shorter of the two runs to the output in duplicate, otherwise append a single character of the carrier to the output. Each run of output characters is terminated with a newline to distinguish it from the input. The (?!¶) at the end prevents the regex from thinking the carrier is the message once the message is exhausted, as normally $ is allowed to match where ¶$ would match.
M!s`.*¶$

Delete everything if the message wasn't completely encoded.
¶

Remove the newlines from the output.

I think it does not pass the second to last test case (which, to be fair, I did not have in the initial post).

@jkpate Thanks for pointing that out; I've had to rewrite my approach slightly.

Clean, 118 bytes
import StdEnv,StdLib
$[][]=[]
$[u:v]b#(_,w)=span((==)u)v
|b%(0,0)==[u]=[u,u: $if(v%(0,0)<>b%(1,1))w v(tl b)]=[u: $w b]

Try it online!
Takes the carrier first, then the message.
Errors with Run time error, rule '$;2' in module 'main' does not match if message won't fit.

Ruby, 73 bytes
f=->m,c,b=p{x,*c=c;x ?(x==m[0]?x+m.shift: x==b ?'':x)+f[m,c,x]:m[0]?x:''}

Try it online!
Recursive function, takes inputs as array of characters.
For once I was hoping to make use of Ruby's built-in squeeze method that contracts consecutive runs of the same character to a single instance. But unfortunately, nope - the last two test cases screwed everything so badly, that I had to resort to a completely different approach, and this turned out to be basically a port of Arnauld's answer.

Powershell, 134 bytes
param($m,$c)$c-csplit"([$m])"|%{$i+=$o=$_-ceq$m[+$i]
if($o-or$_-cne"`0$h"[-1]){$h+=($_-replace'(.)(?=\1)')*($o+1)}}
$h*!($i-$m.Length)

The script returns the empty string if the carrier does not contain the message characters in the right order.
Less golfed test script:
$f = {

param($message,$carrier)
$carrier-csplit"([$message])"|%{                # split by chars of the message, chars itself included ([])
    $offset=$_-ceq$message[+$i]                 # 0 or 1 if current substring is a current message char (case-sensitive equality)
    $i+=$offset                                 # move to next message char if need it
    if($offset-or$_-cne"`0$h"[-1]){             # condition to remove redundant doubles after message char: arrrived -> arrived, ooo -> oo, etc
                                                # `0 to avoid exception error if $h is empty
        $h+=($_-replace'(.)(?=\1)')*($offset+1) # accumulate a double message char or a single substring without inner doubles: arried -> arived, anna -> ana, etc
    }
}
$h*!($i-$message.Length)                        # repeat 0 or 1 times to return '' if the carrier does not contain the message characters in the right order

}

@(
    ,('hi'         ,'has it arrived?'    ,'hhas iit arived?', 'hhas it ariived?')
    ,('hi?'        ,'has it arrived?'    ,'hhas iit arived??', 'hhas it ariived??')
    ,('sir'        ,'has it arrived?'    ,'hass iit arrived?')
    ,('foo'        ,'has it arrived?'    ,'')
    ,('Car'        ,'Cats are cool.'     ,'CCaats arre col.')
    ,('car'        ,'Cats are cool.'     ,'')
    ,('Couch'      ,'Couch'              ,'CCoouucchh')
    ,('oo'         ,'oooooooooo'         ,'oooo')
    ,('o o'        ,'oooo oooa'          ,'oo  ooa')
    ,('er'         ,'error'              ,'eerorr', 'eerror')
    ,('a+b'        ,'anna+bob'           ,'aana++bbob')
) | % {
    $message,$carrier,$expected = $_
    $result = &$f $message $carrier
    "$($result-in$expected): $result"
}

Output:
True: hhas iit arived?
True: hhas iit arived??
True: hass iit arrived?
True:
True: CCaats arre col.
True:
True: CCoouucchh
True: oooo
True: oo  ooa
True: eerror
True: aana++bbob

C (gcc), 69+12 = 81 bytes
g(char*m,char*_){for(;*_;++_)*m-*_?_[-1]-*_&&p*_):p p*m++));*m&&0/0;}

Compile with (12 bytes)
-Dp=putchar(

Try it online!
g(char*m,char*_){
    for(;*_;++_)        //step through _
        *m-*_?          //check if character should be encoded
            _[-1]-*_&&  //no? skip duplicates
                p*_)    //    print non-duplicates
        :p p*m++));     //print encoded character twice
    *m&&0/0;            //if m is not fully encoded, exit via Floating point exception
}


text:
String rotation - output string repeatedly moving first character to the end
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string:
john -> ohnj, hnjo, njoh, john

You may also cycle in the other direction, moving characters from the end:
john -> njoh, hnjo, ohnj, john

You should still output one rotation per letter even if the original word is reached before that:
heehee -> eeheeh, eheehe, heehee, eeheeh, eheehe, heehee

Character arrays are allowed, as long as the result works as shown above.
Shortest answer wins!

If a string like heehee returns to the original order in fewer cycles than its length, do we stop there? I expect this would make a big difference for many answers.

May we cycle in the other direction?

Is the first john shown the input or the first "inversion"?

@xnor, great points!  Thanks so much for the help!  See my edit.

@Jonathan Allan, the first string is the input, I've edited to clarify.  Thanks for pointing that out!

I edited the question including your clarifications, feel free to change it if it's not what you intended.

@xnor that looks much clearer than my original post, thanks so much!

Are we allowed to input/output character arrays? (The distinction can be important in some languages.)

@LegionMammal978 That's a good point, I hadn't considered that, but yes, that should be fine, as long as a given character array can still be cycled through in the prescribed manner.  I've edited to reflect this distinction.

Related but different challenge: https://codegolf.stackexchange.com/questions/165622/produce-a-list-of-rotonyms-2

Isn't this just a scrolly text?

Jelly, 2 bytes
ṙJ

A monadic Link accepting a list of characters which yields a list of lists of characters
Try it online! (footer pretty prints by calling the link and joining with newline characters)

Haskell, 27 bytes
scanl(\(a:b)_->b++[a])=<<id

Try it online!

JavaScript (ES6), 37 32 bytes
Returns an array of strings.
s=>[...s].map(c=>s=s.slice(1)+c)

Try it online!

Python 2, 38 bytes
s=input()
for c in s:s=s[1:]+c;print s

Try it online!

Python 3 is only 9 more bytes.

@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)

@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.

APL (Dyalog Unicode), 6 bytesSBCS
⍳∘≢⌽¨⊂

Try it online!
⍳ the indices
∘ of
≢ the tally
⌽¨ each rotate (to the left)
⊂ the entire string

Japt, 5 3 bytes
Takes input as a character array, outputs an array of character arrays
£=é

Try it here
£=é     :Implicit input of character array U
£       :Map
  é     :  Rotate U one element to the right
 =      :  Reassign to U for next iteration

MATL, 6 5 bytes
tf&+)

1 byte saved thanks to @luis!
Try it at MATL Online!
Explanation:
    # Implicitly grab input string
t   # Duplicate the input
f   # Create an array [1, ..., N] where N is the number of characters in the input
&+  # Add the transpose of this array to itself to create a 2D array of indices
    #
    #   +   1  2  3  4
    #       ----------
    #   1 | 2  3  4  5
    #   2 | 3  4  5  6
    #   3 | 4  5  6  7
    #   4 | 5  6  7  8
    #
)   # Use this 2D array to index into the original string using periodic indexing
    # Implicitly display the resulting character array

05AB1E, 3 bytes
ā._

Try it online!

J, 7 bytes
#\|."{]

Try it online!
Explanation:
  |."{    - rotate ( "{ is short for "0 1 - rank 0 1 )
      ]   - the input
#\        - lenght of the successive prefixes of the input

Using " like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank 1 0?

@Adám  I think it's "#:. I learnt this here from Frownyfrog

R, 58 bytes
function(s,`[`=substring)paste0(s[n<-nchar(s):1],s[1,n-1])

Try it online!

brainfuck, 59 bytes
,[>,]<[>>[>]+[<]<[<]>-[[>]>[>]<+[<]<[<]>-]>[.>]>[.>]<[<].<]

Try it online!
Outputs each string separated by null bytes.
Explanation:
,[>,]    # Get input
<[       # Start loop over input
  >>[>]       # Go to end of the string
  +           # Set it to one to mark it
  [<]<[<]>    # Move to the beginning of input
  -[[>]>[>]<+[<]<[<]>-]   # Transfer the first character to the end
  >[.>]>[.>]  # Print the rotated string
  <[<].       # Print a nul byte
<]       # Repeat loop while input

ForWhile 23 bytes
{:0$(.0@,0@(.0@,#:)9#)}
Input: a char array followed by its length (stored on stack)
Output: prints rotations of input separated by tab (newline would need an additional character)
online interpreter
Explanation
{          \ define anonymous procedure
:0$        \ store copy of string length at address 0
(.         \ start for-loop, ignore loop-counter
0@,        \ rotate top (string length) stack elements
0@(.0@,#:) \ print string but keep it on the stack
9#         \ print tab
)          \ end outer for-loop
}          \ end procedure

Calling the procedure:
{:0$(.0@,0@(.0@,#:)9#)} \ procedure
1$                      \ store procedure at address 1
"ForWhile"              \ procedure argument
1@?                     \ call procedure

prints:
orWhileF    rWhileFo    WhileFor    hileForW    ileForWh    leForWhi    eForWhil    ForWhile

Wolfram Language (Mathematica), 35 26 bytes
Partition[#,Tr[1^#],1,-1]&

Try it online!
Takes a list of characters as input.
Partition (but not its variant StringPartitionused below) has an optional fourth argument for treating its input as cyclic (and for specifying how exactly to do so), which makes this solution simpler than the string one - in addition to not having any 15-character built-in functions.
Wolfram Language (Mathematica), 44 bytes
Rest@StringPartition[#<>#,StringLength@#,1]&

Try it online!
The same, but takes a string as input.
Turns "john" into "johnjohn", then takes all the length-StringLength["john"] substrings of this string with offset 1, producing {"john","ohnj","hnjo","njoh","john"}, then drops the first of these with Rest.

Since character arrays are allowed, Rest@Partition[#~Join~#,Length@#,1]& would be 36 bytes.

@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.

Attache, 13 bytes
Rotate#{1:#_}

Try it online!
Explanation
Rotate#{1:#_}
      #          fork(f, g) = ${ f[x, g[x]] }; this forks:
Rotate               rotate's the input by
       {1:#_}        each number from 1 to the length of the input

Alternatives
15 bytes: {_&Rotate!1:#_}
16 bytes: {Rotate[_,1:#_]}
16 bytes: Rotate@Rotations
16 bytes: Rotate#(1&`:@`#)
17 bytes: Rotate#{1+Iota@_}
18 bytes: Rotate#(1&`+@Iota)
19 bytes: Rotate#(Succ=>Iota)

Python 2, 54 48 bytes
lambda i:[i[x:]+i[:x]for x in range(1,len(i)+1)]

Try it online!
Well beaten by xnor but posted as an alternative approach anyway.

C (32-bit), 58 51 50 bytes
-1 byte for a nice round number thanks to ceilingcat
i;f(s){for(i=0;i++<printf("%s%.*s\n",s+i,i,s)-2;);}

Try it online!
Degolf
i;           // "Global" i.
f(s){   // s is pointer to string, which conveniently fits in a 32 bit integer.
    for(i=0; // Initialize i.
        // Increment i and take its complement, and add it to the
        // return value of printf(); which just happens to be strlen(s)+1.
        // ~i + strlen(s) + 1 == strlen(s) + 1 - i - 1, so the last printed
        // string is the original string.
        ~++i + printf("%s%.*s\n",s+i,i,s);
        // The printf prints two strings: first until the terminating \0,
        // the second until a \0 or until i chars have been printed. It also
        // prints a linefeed.
}

Suggest ~++i+printf("%s%.*s\n",s+i,i,s) instead of i++<printf("%s%.*s\n",s+i,i,s)-2

@ceilingcat Thanks, as always!

@ceilingcat You really should be called flooringcat.

49 bytes

C# (Visual C# Interactive Compiler), 34 bytes
x=>x.Select(c=>x=x.Substring(1)+c)

Try it online!

JavaScript, 48 43 36 bytes
-5 bytes courtesy of @Bubbler
*-7 bytes courtesy of @Shaggy
Input is a character array and output is an array of character arrays.
s=>s.map(_=>([a,...b]=s,s=[...b,a]))

Try it online!

43 bytes.

36 bytes

@Shaggy Is that a valid byte count and entry? Does [..."john"] not count as manipulation of the input string to an array before the function call?

@guest271314, input is a character and output is an array of character arrays which are permitted by the challenge spec and our I/O defaults.

@Shaggy Updated. Can you kindly leave your above comment? Or should your comment be included at the answer to avoid confusion? Or is neither necessary?

Just specify the I/O methods in your solution (e.g.) - comments may not last forever.

@Shaggy Cannot yet explain that for the users here more clearly than you, quoted your language at the answer.

Ruby, 39 bytes
->s{a=s.chars.to_a;a.map{a.rotate!*''}}

Try it online!

Welcome to the site! It doesn't look like your TIO link corresponds to your answer.  It also seems your answer doesn't fit with our input/output requirements.  You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.

Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.

brainfuck, 38 bytes
,[>>,]<<<+>[[.>>]<<[<<]>-[+>.>-].<<+>]

Try it online!
Based on the idea of JoKing to use null-characters as space symbols. This code marks the current letters to print and loops until it reaches the left end.
,[>>,]<<    input string with empty cells in between
<+>         set first marker
[           main loop
  [.>>]     print remaining characters
  <<[<<]    return to start
  >-[+>.>-] print until marker (remove marker)
  .         print null
  <<+       set new marker
  >         restart loop with next character to the left
]           stop if there's no character to the left

Fig, \$13\log_{256}(96)\approx\$ 10.701 bytes
$#GLxWxO'+]xq

Try it online!
This is so long

Go, 105 bytes
func f(s[]rune)(o[][]rune){for i:=0;i<len(s);i++{o=append([][]rune{append(s[i:],s[:i]...)},o...)}
return}

Attempt This Online!
Without the requirement of the original being at the end, this saves 13 bytes:
92 bytes
func f(s[]rune)(o[][]rune){for i:=0;i<len(s);i++{o=append(o,append(s[i:],s[:i]...))}
return}

Attempt This Online!

Stax, 3 bytes
:(m

Run and debug it

Julia 1.0, 31 bytes
!s=(r=keys(s)).|>i->(s*s)[i.+r]

Try it online!

Ruby -nl, 26 bytes
$_.scan(/./){puts$'+$`+$&}

Attempt This Online!

Vyxal, 3 bytes
(Ǔ…

Explanation:
(   # For each char in the input
 Ǔ  # Rotate left
  … # Print without popping

Try it Online!

Thunno 2, 3 bytes
ż€Ỵ

Attempt This Online!
Explanation
ż€Ỵ  # Implicit input
ż    # Push the length range
 €   # For each number in this range:
  Ỵ  #  Rotate the input left that many times

Arturo, 30 bytes
$->s[0-1map s=>[rotate s<=1+]]

Try it!

JavaScript (Node.js), 41 bytes
Another JS answer, which doesn't beat any of the previous JS ones.
Input is an array of characters (as seen in other answers), and output is an array of strings.
Rotates the string the inverted way, as allowed by OP.
s=>[...s].map(_=>[...s]=s.pop()+s.join``)

Try it online!

Different approach that swaps each character with their corresponding one, obtained via calculation of its index (correct rotation direction, 58 bytes) :
s=>s.map((_,i)=>s.map((_,j)=>s[(i+j+1)%s.length]).join``)

Try it online!

V, 8 bytes
ýñx$pÙñd

Try it online!
Hexdump:
00000000: fdf1 7824 70d9 f164                      ..x$p..d

ýñx$pÙñd gives 8 by removing the need to H https://tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA

@Cowsquack Even better: ý<M-->ñx$pÙ

Doesn't that repeat the last line?

Tcl, 80 91 bytes
proc P s {time {puts [set s [string ra $s 1 e][string in $s 0]]} [string le $s]}

Try it online!

Reassign text at each time saves some bytes
proc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}

Got it down to 80 bytes, thanks to @david

Charcoal, 10 bytes
⮌Ｅθ⭆θ§θ⁻μκ

Try it online! Link is to verbose version of code. Explanation:
  θ         Input string
 Ｅ         Map over characters
    θ       Input string
   ⭆        Map over characters and join
      θ     Input string
     §      Circularly indexed by
       ⁻    Difference between
        μ   Inner index
         κ  Outer index
⮌           Reversed
            Implicitly print each string on its own line

To rotate in the opposite direction, replace Minus with Plus.

Red, 49 43 bytes
func[s][forall s[print move head s tail s]]

Try it online!

Perl 6, 32 bytes
{m:ex/^(.*)(.+)$/».&{[R~] @$_}}

Try it online!
m:ex/^(.*)(.+)$/ exhaustively matches the given regex, splitting the input string at every possible place, except that the second substring must have at least one character--that prevents the input string from showing up twice in the output.  Then each of the resulting Match objects' capture groups are reduced ([]) to a single string with R~, the reversed string concatenation operator.

Pushy, 4 bytes
L:{"

Try it online!
L:    \ Length of the string times do:
  {   \    Cyclically shift left once
   "  \    Print

Powershell, 44 bytes
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}

Test script:
$f = {

($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}

}

@(
    ,('john', 'ohnj', 'hnjo', 'njoh', 'john')
    ,('heehee', 'eeheeh', 'eheehe', 'heehee', 'eeheeh', 'eheehe', 'heehee')
) | % {
    $s,$expected = $_
    $result = &$f $s
    "$result"-eq"$expected"
    $result
}

output:
True
ohnj
hnjo
njoh
john
True
eeheeh
eheehe
heehee
eeheeh
eheehe
heehee

Pepe, 64 52 bytes
rEEEEeREEeRREeeeREEReREEEeeReReeeReeERREeeerEEEEERee

Try it online! Uses newlines for separation.

Java (JDK), 85 bytes
s->{for(int i=s.length();i-->0;)System.out.println(s.substring(i)+s.substring(0,i));}

Try it online!

SNOBOL4 (CSNOBOL4), 82 bytes
	S =INPUT
T	X =X + 1
	S LEN(1) . L REM . R
	OUTPUT =S =R L LE(X,SIZE(S))	:S(T)
END

Try it online!

MathGolf, 5 bytes
hÅ╫o;

Try it online!
Explanation
h       length of array/string without popping
 Å      start block of length 2
  ╫     left-rotate bits in int, list/str
   o    print TOS without popping
    ;   discard TOS

Lua, 61 bytes
function(s)for i=1,#s do print(s:sub(i+1)..s:sub(1,i))end end

Try it online!
Split string at successive indices from one to the length of the string (one-based indexing), concatenate the pieces in the reverse order, print.

perl 5, 18 (-n) bytes
Thanks to Xcali
s/./say$',$`,$&/ge

TIO
Original answer (23 bytes)
/^.+?(?{say$'.$&})(?!)/

TIO

18 bytes

Common Lisp, 88 bytes
(lambda(x)(loop for s from 1 to(length x)do(format t"~a~a "(subseq x s)(subseq x 0 s))))

Try it online!

MBASIC, 69 66 bytes
-3 bytes, thanks to Ørjan Johansen
1 INPUT S$:L=LEN(S$):FOR I=1 TO L:S$=MID$(S$+S$,2,L):PRINT S$:NEXT

I suspect you can shorten that to 1 INPUT S$:L=LEN(S$):FOR I=1 TO L:S$=MID$(S$+S$,2,L):PRINT S$:NEXT.

@Ørjan Johansen Very nice, thank you.

Factor, 25 bytes
[ all-rotations reverse ]

Try it online!
               ! "john"
all-rotations  ! { "john" "ohnj" "hnjo" "njoh" }
reverse        ! { "njoh" "hnjo" "ohnj" "john" }

Vyxal, 3 bytes
żvǓ

Try it Online!

APL (Dyalog Unicode), 13 bytes
{(↓,↑)∘⍵¨⍳≢⍵}

Try it online!
Over twice as long as the other APL answer, but uses a different more literal tactic. Test harness stolen from that answer.
{(↓,↑)∘⍵¨⍳≢⍵}
{           } ⍝ Define function
         ⍳≢   ⍝ Indexes of
           ⍵  ⍝ The input
        ¨     ⍝ For each item in ^
 (   )        ⍝ Apply the following function:
  ↓              ⍝ Drop n elements
    ↑            ⍝ Take n elements
   ,             ⍝ Concatenate the 2 above results
      ∘⍵      ⍝ Bind the right input of the above function to the input

Rockstar, 79 77 bytes
Listen to S
X's 0
While S at X
Cut S
Rock roll S in S
Join S
Say S
Let X be+1

Try it (Code will need to be pasted in)

JavaScript (Node.js), 32 bytes
s=>[...s].map(_=>s=s.slice(1)+_)

Try it online!
JavaScript (Node.js), 32 bytes
s=>s.map(_=>s=[...s.slice(1),_])

Try it online!
Found similarity

Nekomata, 3 bytes
x→Ř

Attempt This Online!
x       Enumerate; push [0, 1, ..., len(input) - 1]
 →      Increment
  Ř     Rotate right by that amount (automatically vectorized)

Unfortunately x is 0-indexed, so we have to increment it before rotating.

Racket - 179 bytes
#!racket
(let([s(read-line)][a string-append])(let g([r s][i(string-length s)])(display(a r(if(= i 0)""" -> ")))(if(= i 0)(void)(g(a(substring r 1)(~a(string-ref r 0)))(- i 1)))))

Try it online!

Explanation
On line one we have the required language expression. Yesterday, I learnt that #![language] is short for #lang [language], but it is discouraged in normal programs.
On line two, we define an immediately invoked function using let. The parent let receives a line of input from the user and passes it to it's child let called g. The child let acts as a recursive loop that uses the length of the parent string as an iterator. The first if check is in charge of pretty printing the rotated string. (While it would save some bytes to remove it, I like the way it looks.) The second check is used to determine whether the string should be rotated again or if the program should end.
To rotate the string, we split the string at index 1 and append the first character to the end of the string.
#lang racket

(let ([str (read-line)] [str-app string-append])
  (let loop ([rotated str] [idx (string-length str)])
    (display (str-app rotated (if (= idx 0) "" " -> ")))
    (if (= idx 0)
      (void)
      (loop (str-app (substring rotated 1)
                     (~a (string-ref rotated 0)))
            (- idx 1)))))

Output (Input: Heya!)
Heya! -> eya!H -> ya!He -> a!Hey -> !Heya -> Heya!

Lua, 52 bytes
s=...for i=1,#s do s=s:sub(2)..s:sub(1,1)print(s)end

Try it online!

Swift 5.9, 65 59 57 bytes
var s="",r={s=$0
s.map{$0
s+=[s.removeFirst()]
print(s)}}

r(_:) is the closure to call.

J-uby, 23 bytes
:*%[:& &:rotate,:+@|:+]

Attempt This Online!
Explanation
:* % [:& & :rotate, :+@ | :+]
                    :+@ | :+   # Range 1..(input length)
:* % [            ,         ]  # Map with...
      :& & :rotate             #   Rotate input chars

Uiua SBCS, 7 bytes
⇌≡↻⇡⊃⧻¤

Try it!
If it is allowed to start with the input rather than end with it, then remove the reverse for -1 byte.
⇌≡↻⇡⊃⧻¤
    ⊃⧻¤  # fix the input and get its length
   ⇡     # range
 ≡↻      # rotate input by each number in the range
⇌        # reverse

Brachylog, 8 bytes
l≥ℕ₁;?↺₍

Generator solution: takes a string as input, outputs one rotation at a time when called repeatedly. Try it online!
Explanation
l≥ℕ₁;?↺₍
l          Length of input string
 ≥         Get a number less than or equal to that
  ℕ₁       which is also an integer greater than or equal to 1
    ;?     Put it in a list with the input string
      ↺₍   Rotate the latter the former number of times

TI-Basic, 40 bytes
For(I,1,length(Ans)-1
sub(Ans,2,length(Ans)-1)+sub(Ans,1,1
Disp Ans
End
Ans

Takes input in Ans. Rotates to the left.

Wouldn't it be shorter to store length(Ans)-1 in a variable?

@MarcMush It wouldn't because you would have to store the input in a string variable.

PowerShell, 51 bytes
1..$s.Length|%{$s=$s[1..$s.Length]+$s[0]-join'';$s}

Try it online!

Pyth, 11 bytes
VSlQ+>QN<QN

Try it online!
Pretty much just a port of my Python answer
Explanation
==================================================
assign('Q',eval_input())
for N in num_to_range(Psorted(Plen(Q))):
 imp_print(plus(gt(Q,N),lt(Q,N)))
==================================================

V                    # for N in
 S                   # 1-indexed range
  lQ                 # length of evaluated input
    +                # concatanate
     >QN             # all characters after index N in Q (Q[N:])
        <QN          # and all characters before index N in Q (Q[:N])

Tcl, 78 bytes
proc R t {time {puts [set t [regsub -all (.?)(.*) $t {\2\1}]]} [string le $t]}

Try it online!

JavaScript, 36 bytes
Saved 3 bytes thanks to @Shaggy by using shift() instead of splice().
a=>a.map(x=>a.push(a.shift())&&a+"")

Try it online!

Perl 6, 20 bytes
{.rotate(all 1..$_)}

Try it online!
Anonymous code block that has input/output as a list of characters. The output is a Junction object that contains all the rotated arrays. I'm not sure how legal this is, since extracting values from a Junction is not normal.
Explanation:
{                  }   # Anonymous codeblock
 .rotate(         )    # Rotate the input list
         all 1..$_     # By all of the range 1 to length of the input array
                          # all creates a junction of values
                          # And it runs the function on each value

The all can be replaced by any of any, one, [&], [|], [^].
If the Junction isn't allowed, here's an alternate solution for 22 bytes:
{.&{.rotate(++$)xx$_}}

Try it online!
There's probably a better way to reset the anonymous variable ++$ than by wrapping the code in another code block...

C (clang), 57 54 bytes
i;f(int*a){for(i=0;a[i++];printf("%S%.*S ",a+i,i,a));}

Try it online!
Takes input as a wide string.

Loop until a[i++] to save 7 bytes.

Oh, no char*. You'd still save bytes, though (just make i global and f(char*a).

Clojure, 64 bytes
(fn[w](take(count w)(rest(iterate #(str(subs % 1)(first %))w))))

Try it online!
See the pre-golfed code below for an explanation. Returns a (lazy) list of strings.
(defn cycle-word [word]
  (->> ; Take the word
       word

       ; Create an infinite list of iterations of strings where
       ;   the first character is moved to the end of the subs(tring)
       (iterate #(str (subs % 1) (first %)))

       ; Drop the first result since we don't want it to start with the original word
       (rest)

       ; Then take as many iterations from the infinite list as the word has characters
       (take (count word))))

(cycle-word "john")
=> ("ohnj" "hnjo" "njoh" "john")

Pyth, 7 bytes
_.e.>Qk

Accepts input as a string or as a list of characters, output is a list of the same. Try it online here.

Ruby, 33 bytes
->s{s.chars.map{s=s[1..-1]+s[0]}}

Try it online!

Runic Enchantments, 59 bytes
>iu0l:1-}[{ R{:0=1\
/:$ak$0l1-[{U$:/?-/
\}?*2=0:-1{]{~ /;$~

Try it online!
Can handle inputs up to 8 characters (spaces need to be escaped, however).
Essentially just a bunch of stack manipulation, with integer 0 denoting the end of the stack and the original length used as a counter held at the end.
Without using the stack-of-stacks commands [ and ] the solution is slightly larger (63 bytes) but can handle strings up to 16 characters:
>iu0l1-}l1-sRl1-s:0 \
/s:$ak$0l1-sU$:/?-1=/
\-1l}?*5=0:-1{~/;${

Try it online!

Reticular, 56 38 bytes
iSL:%=@qB[:%`@d]:%`*[[o]:%`1-*p$]:%`*;

Try it online!
Explanation with input "Hee"
iS                # Read input string and put its chars into an array
L:%=              # Get length of string and save it as `%`
@qB               # Reverse array and push its items to the stack
                   Stack: [H, e, e]
[:%`@d]:%`*       # Duplicates the top length(str) items in the stack
                   a total of length(str) number of times
                   Stack before: [H, e, e]
                   Stack after: [H, e, e, H, e, e, H, e, e, H, e, e]
[[o]:%`1-*p$]:%`* # Output the top length(str) items from the stack
                    with a trailing newline, and then
                    pop the next item in the stack.
                    Iterate this `%` number of times
                    Stack before: [H, e, e, H, e, e, H, e, e, H, e, e]

                    Stack after 1st iteration: [e, e, H, e, e, H, e, e]
                    Output: Hee
                    Stack after 2nd iteration: [e, H, e, e]
                    Output: Hee
                            eeH
                    Stack after 3rd iteration: []
                    Output: Hee
                            eeH
                            eHe

;                 # Exit

PHP, 63 bytes
for($s=$argv[1];$x++<strlen($s);)echo$s=substr($s,1).$s[0]," ";

Try it online!
Output
$php strrot.php john
ohnj hnjo njoh john

$php strrot.php heehee
eeheeh eheehe heehee eeheeh eheehe heehee

C# (.NET Core), 103, 79 bytes
Without LINQ.
EDIT:  ASCII-only golfing -24 bytes with a better use of a for loop and substring return!
p=>{var s="";for(int j=0;j++<p.Length;s+=p+" ")p=p.Substring(1)+p[0];return s;}

Try it online!

79

cQuents, 11 bytes
=A#|LA)&_lZ

Try it online!
Explanation
=A#|LA)&_lZ

=A              first term in sequence is the input
  #|LA)         add second input n: length of input
       &        output first n terms in sequence
                each term equals:
        _l                        unary rotate left of
          Z                                            previous term

Replace _l with _r to rotate right instead of left.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Find the number of leading zeroes in a 64-bit integer
Problem:
Find the number of leading zeroes in a 64-bit signed integer
Rules:

The input cannot be treated as string; it can be anything where math and bitwise operations drive the algorithm
The output should be validated against the 64-bit signed integer representation of the number, regardless of language
Default code golf rules apply
Shortest code in bytes wins

Test cases:
These tests assume two's complement signed integers. If your language/solution lacks or uses a different representation of signed integers, please call that out and provide additional test cases that may be relevant. I've included some test cases that address double precision, but please feel free to suggest any others that should be listed.
input                output   64-bit binary representation of input (2's complement)
-1                   0        1111111111111111111111111111111111111111111111111111111111111111
-9223372036854775808 0        1000000000000000000000000000000000000000000000000000000000000000
9223372036854775807  1        0111111111111111111111111111111111111111111111111111111111111111
4611686018427387903  2        0011111111111111111111111111111111111111111111111111111111111111
1224979098644774911  3        0001000011111111111111111111111111111111111111111111111111111111
9007199254740992     10       0000000000100000000000000000000000000000000000000000000000000000
4503599627370496     11       0000000000010000000000000000000000000000000000000000000000000000
4503599627370495     12       0000000000001111111111111111111111111111111111111111111111111111
2147483648           32       0000000000000000000000000000000010000000000000000000000000000000
2147483647           33       0000000000000000000000000000000001111111111111111111111111111111
2                    62       0000000000000000000000000000000000000000000000000000000000000010
1                    63       0000000000000000000000000000000000000000000000000000000000000001
0                    64       0000000000000000000000000000000000000000000000000000000000000000

Welcome to PPCG! What's the reason behind "the input cannot be treated as string"? This disqualifies all languages that can't handle 64-bit integers and is unlikely to lead to more answers that take an integer, because this is the straightforward way when available anyway.

Can we return False instead of 0?

@Arnauld There are already similar questions here and on other sites that specifically call for string-based solutions, but nothing that opens the question to math and logical operations. My hope is to see a bunch of different approaches to this problem that are not already answered elsewhere.
Should this be opened to string solutions as well to be all-inclusive?

Several CPUs including x86 and ARM have specific instructions for this (x86 actually have several). I've always wondered why programming languages don't expose this feature since in most programming languages today you can't invoke assembly instructions.

It's 64 - log2.

@user202729 For positive input.

@Dave Unobservable requirements are discouraged, although it's ok to simply encourage using methods you want.

@user202729 I think I worded this poorly: 'The output should be validated against the 64-bit signed integer representation of the number, regardless of language'
What I mean by that is that this question defines the number of zeros as the number of zeros in a 64-bit signed integer. I guess I made that constraint to eliminate signed vs unsigned integers.

@slebetman I thought that built-ins were excluded as part of the default code golf rules, but I just saw that it's only a suggested rule.
I assume changing the requirements at this point is poor form, but I'll remember that in the future!

The equation for this is 64 if 0, 0 if -ve and 63-floor(log2(n)) otherwise

Don't "Do X without Y"

@slebetman: many languages do have builtins for this, almost to the point where C and C++ are notable for their failure to portably expose modern CPU features like popcnt and bit-scan.  (Especially given their use-case of low-overhead highly-optimized code).  Most C compilers have their own incompatible and/or arch-specific intrinsics and builtins for this stuff.  Rust is fantastic; all the primitive integer types have popcnt, bit-scan, rotate, endian, saturating add/sub, and wrapping vs. overflow-checked vs. non-overflowing add/sub/mul/div etc. https://doc.rust-lang.org/std/primitive.i32.html

x86_64 machine language on Linux, 6 bytes
0:       f3 48 0f bd c7          lzcnt  %rdi,%rax
5:       c3                      ret

Requires Haswell or K10 or higher processor with lzcnt instruction.
Try it online!

Builtins strike again /s

I recommend specifying the calling convention used (though you did say on Linux)

@qwr It looks like SysV calling convention because the parameter is passed in %rdi and it is returned in %rax.

Hexagony, 78 70 bytes
2"1"\.}/{}A=<\?>(<$\*}[_(A\".{}."&.'\&=/.."!=\2'%<..(@.>._.\=\{}:"<><$

Try it online!
Isn't this challenge too trivial for a practical language? ;)
side length 6. I can't fit it in a side length 5 hexagon.
Explanation

I laughed really hard at the "explanation". :D

I think you may have overcomplicated handling negative numbers/zero. I managed to fit a similar program into side length 5 by not doing that hefty 2^64 calculation. It clearly isn't well golfed yet, though!

@fry Ah right, negative numbers always have 0 leading zeroes... which definitely leads to shorter program because generates 2^64 is long.

Python, 31 bytes
lambda n:67-len(bin(-n))&~n>>64

Try it online!
The expresson is the bitwise & of two parts:
67-len(bin(-n)) & ~n>>64

The 67-len(bin(-n)) gives the correct answer for non-negative inputs. It takes the bit length, and subtracts from 67, which is 3 more than 64 to compensate for the -0b prefix. The negation is a trick to adjust for n==0 using that negating it doesn't produce a - sign in front.
The & ~n>>64 makes the answer instead be 0 for negative n. When n<0, ~n>>64 equals 0 (on 64-bit integers), so and-ing with it gives 0. When n>=0, the ~n>>64 evaluates to -1, and doing &-1 has no effect.

Python 2, 36 bytes
f=lambda n:n>0and~-f(n/2)or(n==0)*64

Try it online!
Arithmetical alternative.

C (gcc), 14 bytes
__builtin_clzl

Works fine on tio
C (gcc), 35 29 bytes
f(long n){n=n<0?0:f(n-~n)+1;}

Try it online!
Than Dennis for 6 bytes
C (gcc) compiler flags, 29 bytes by David Foerster
-Df(n)=n?__builtin_clzl(n):64
Try it online!

Worth noting that it's only for 64-bit machines (or any others with LP64/ILP64/etc. ABI)

Geez, that’s even shorter than any use of the GCC built-in __builtin_clzl with which I can come up.

@Ruslan: good point, on systems where long is 32 bits (including Windows x64), you need __builtin_clzll (unsigned long long).  https://godbolt.org/z/MACCKf.  (Unlike Intel intrinsics, GNU C builtins are supported regardless of the operation being doable with one machine instruction.  On 32-bit x86, clzll compiles to a branch or cmov to do lzcnt(low half)+32 or lzcnt(high half).  Or bsr if lzcnt isn't available.

The test cases include "0" but __builtin_clz(l)(l) is undefined behavior for zero: "If x is 0, the result is undefined."

@MCCCS If it works, it counts. That's also why I keep the last answer

Java 8, 32 26 bytes.
Long::numberOfLeadingZeros
Builtins FTW.
-6 bytes thanks to Kevin Cruijssen
Try it online!

Ah, completely forgot about numberOfLeadingZeros.. You can golf it to 28 bytes btw: n->n.numberOfLeadingZeros(n)

Actually, Long::numberOfLeadingZeros is even shorter (26 bytes).

Wow, it doesn't happen very often that Java beats Python. Congrats!

JavaScript (Node.js), 25 bytes
Takes input as a BigInt literal.
f=x=>x<0?0:x?f(x/2n)-1:64

Try it online!
Or 24 bytes by returning false instead of \$0\$.

Wouldn't n=>n<1?0:n.toString(2)-64 perform the same?

@IsmaelMiguel I suppose you meant n=>n<1?0:n.toString(2).length-64, but that would not work anyway. This would, I think.

You're right. Thank you :( I though I found an alternative for you :/

@IsmaelMiguel No worries. :) It's indeed possible to have the .toString() approach working, but we still need a BigInt literal as input. Otherwise, we only have 52 bits of mantissa, leading to invalid results when precision is lost.

The fact that the BigInt suffix is the same character as your parameter is very confusing...

@Neil Unreadable code on PPCG?? This can't be! Fixed! :p

Python 3, 34 bytes
f=lambda n:-1<n<2**63and-~f(2*n|1)

Try it online!

J, 18 bytes
0{[:I.1,~(64$2)#:]

Try it online!
J, 19 bytes
1#.[:*/\0=(64$2)#:]

Try it online!
Explanation:
                #:  - convert
                  ] - the input to
          (64$2)    - 64 binary digits
         =          - check if each digit equals
        0           - zero
   [:*/\            - find the running product
1#.                 - sum

1#.[:*/\1-_64{.#: (17) is close but doesn't work for negative numbers :(

@Conor O'Brien Nice approach too!

Perl 6, 18 bytes
-2 bytes thanks to Jo King
64-(*%2**64*2).msb

Try it online!

Ruby, 22 bytes
->n{/[^0]/=~"%064b"%n}

Try it online!

Could you explain?

Another one that counts chars in a string♀

Haskell, 56 bytes
Thanks xnor for spotting a mistake!
f n|n<0=0|1>0=sum.fst.span(>0)$mapM(pure[1,0])[1..64]!!n

Might allocate quite a lot of memory, try it online!
Maybe you want to test it with a smaller constant: Try 8-bit!
Explanation
Instead of using mapM(pure[0,1])[1..64] to convert the input to binary, we'll use mapM(pure[1,0])[1..64] which essentially generates the inverted strings \$\lbrace0,1\rbrace^{64}\$ in lexicographic order. So we can just sum the \$1\$s-prefix by using sum.fst.span(>0).

05AB1E, 10 9 bytes
·bg65αsd*

I/O are both integers
Try it online or verify all test cases.
Explanation:
·         # Double the (implicit) input
          #  i.e. -1 → -2
          #  i.e. 4503599627370496 → 9007199254740992
 b        # Convert it to binary
          #  i.e. -2 → "ÿ0"
          #  i.e. 9007199254740992 → 100000000000000000000000000000000000000000000000000000
  g       # Take its length
          #  i.e. "ÿ0" → 2
          #  i.e. 100000000000000000000000000000000000000000000000000000 → 54
   65α    # Take the absolute different with 65
          #  i.e. 65 and 2 → 63
          #  i.e. 65 and 54 → 11
      s   # Swap to take the (implicit) input again
       d  # Check if it's non-negative (>= 0): 0 if negative; 1 if 0 or positive
          #  i.e. -1 → 0
          #  i.e. 4503599627370496 → 1
        * # Multiply them (and output implicitly)
          #  i.e. 63 and 0 → 0
          #  i.e. 11 and 1 → 11

Jelly,  10  9 bytes
-1 thanks to a neat trick by Erik the Outgolfer (is-non-negative is now simply AƑ)
ḤBL65_×AƑ

A monadic Link accepting an integer (within range) which yields an integer.
Try it online! Or see the test-suite.

The 10 was ḤBL65_ɓ>-×
Here is another 10 byte solution, which I like since it says it is "BOSS"...
BoṠS»-~%65

Test-suite here
...BoṠS63r0¤i, BoṠS63ŻṚ¤i, or BoṠS64ḶṚ¤i would also work.

Another 10 byter (from Dennis) is æ»64ḶṚ¤Äċ0 (again æ»63r0¤Äċ0 and æ»63ŻṚ¤Äċ0 will also work)

9 bytes

@EriktheOutgolfer I thought to myself "there must be a golfier way to multiply by isNonNegative" and didn't think of the Ƒ quick at all, very nice work!

Actually, I've been theorizing about AƑ for quite some while now. Be warned that it doesn't vectorize! ;-) It's actually "flatten and then check if all elements are nonnegative".

Powershell, 51 bytes
param([long]$n)for(;$n-shl$i++-gt0){}($i,65)[!$n]-1

Test script:
$f = {

param([long]$n)for(;$n-shl$i++-gt0){}($i,65)[!$n]-1

}

@(
    ,(-1                   ,0 )
    ,(-9223372036854775808 ,0 )
    ,(9223372036854775807  ,1 )
    ,(4611686018427387903  ,2 )
    ,(1224979098644774911  ,3 )
    ,(9007199254740992     ,10)
    ,(4503599627370496     ,11)
    ,(4503599627370495     ,12)
    ,(2147483648           ,32)
    ,(2147483647           ,33)
    ,(2                    ,62)
    ,(1                    ,63)
    ,(0                    ,64)
) | % {
    $n,$expected = $_
    $result = &$f $n
    "$($result-eq$expected): $result"
}

Output:
True: 0
True: 0
True: 1
True: 2
True: 3
True: 10
True: 11
True: 12
True: 32
True: 33
True: 62
True: 63
True: 64

Java 8, 38 bytes
int f(long n){return n<0?0:f(n-~n)+1;}

Input as long (64-bit integer), output as int (32-bit integer).
Port of @l4m2's C (gcc) answer.
Try it online.
Explanation:
 int f(long n){       // Recursive method with long parameter and integer return-type
   return n<0?        //  If the input is negative:
           0          //   Return 0
          :           //  Else:
           f(n-~n)    //   Do a recursive call with n+n+1
                  +1  //   And add 1

EDIT: Can be 26 bytes by using the builtin Long::numberOfLeadingZeros as displayed in @lukeg's Java 8 answer.

APL+WIN, 34 bytes
+/×\0=(0>n),(63⍴2)⊤((2*63)××n)+n←⎕

Explanation:
n←⎕ Prompts for input of number as integer

((2*63)××n) If n is negative add 2 to power 63

(63⍴2)⊤ Convert to 63 bit binary

(0>n), Concatinate 1 to front of binary vector if n negative, 0 if positive

+/×\0= Identify zeros, isolate first contiguous group and sum if first element is zero

C# (Visual C# Interactive Compiler), 42 bytes
x=>x!=0?64-Convert.ToString(x,2).Length:64

Try it online!
C# (Visual C# Interactive Compiler), 31 bytes
int c(long x)=>x<0?0:c(x-~x)+1;

Even shorter, based off of  @l4m2's C (gcc) answer.
Never knew that you could declare functions like that, thanks @Dana!
Try it online!

I think this is valid? https://tio.run/##ZZA/T8QwDMVn8ik8tqI92UmaP1cOBlY2BgbEcIoCRLpLpaZCRQi@ekmvFBB48fN79m@wS7VLYZpCHMAVhy4@wVjuLscLvMKtK8b6YyzPqZ0Ym7P7Bxh8GnyfYAdvNVWstpwLoTkKZRqpdWPQVPBV7H@oYU2ZVETKKCQjuRZGWxRQMeJc2qytUTKfSEsEv4CImqzlmSYx99msZlaDorFWZZBGadXi/7WbdZ1TvjdCSbNwqx9HLyOsAX0rfG8Ze@x6v3fPxcu@P70iQYjrT0p2dvua1XFz3cXUHfzmrg@DvwnRF644bZdlO30C

Swift (on a 64-bit platform), 41 bytes
Declares a closure called f which accepts and returns an Int.   This solution only works correctly 64-bit platforms, where Int is typealiased to Int64.  (On a 32-bit platform, Int64 can be used explicitly for the closure’s parameter type, adding 2 bytes.)
let f:(Int)->Int={$0.leadingZeroBitCount}

In Swift, even the fundamental integer type is an ordinary object declared in the standard library.  This means Int can have methods and properties, such as leadingZeroBitCount (which is required on all types conforming to the standard library’s FixedWidthInteger protocol).

interesting. reminds me of Rust. i think it should count as 20 bytes, .leadingZeroBitCount

Perl 5, 37 bytes
sub{sprintf("%064b",@_)=~/^0*/;$+[0]}

Try it online!
Or this 46 bytes if the "stringification" is not allowed: sub z
sub{my$i=0;$_[0]>>64-$_?last:$i++for 1..64;$i}

s/length$&/$+[0]/ (-3 bytes) ;)

IMO, you're not allowed to remove the sub keyword from answers containing Perl 5 functions.

I've seen whats similar to removing sub in answers for other languages, perl6, powershell and more.

In Perl6, I think you don't need sub{} to make a (anonymous?) sub, which explain why it's omitted from Perl6 answers. I agree with @nwellnhof that you shouldn't be allowed to remove sub. (when I was still active, like a year ago or so, that was the rule)

changed now. And included $+[0].

Haskell, 24 bytes
f n|n<0=0
f n=1+f(2*n+1)

Try it online!
This is basically the same as Kevin Cruijssen's Java solution, but I found it independently.
The argument should have type Int for a 64-bit build, or Int64 for anything.
Explanation
If the argument is negative, the result is immediately 0. Otherwise, we shift left, filling in with ones, until we reach a negative number. That filling lets us avoid a special case for 0.
Just for reference, here's the obvious/efficient way:
34 bytes
import Data.Bits
countLeadingZeros

Clean, 103 bytes
Uses the same "builtin" as ceilingcat's answer.
f::!Int->Int
f _=code {
instruction 243
instruction 72
instruction 15
instruction 189
instruction 192
}

Try it online!
Clean, 58 bytes
import StdEnv
$0=64
$i=until(\e=(2^63>>e)bitand i<>0)inc 0

Try it online!

Stax, 10 bytes
în»╧3(∞┼⌠g

Run and debug it
It's a port of Kevin's 05AB1E solution.

Wolfram Language (Mathematica), 41 bytes
The formula for positive numbers is just 63-Floor@Log2@#&.  Replacement rules are used for the special cases of zero and negative input.
The input need not be a 64-bit signed integer.  This will effectively take the floor of the input to turn it into an integer.  If you input a number outside of the normal bounds for a 64-bit integer, it will tell return a negative number indicating how many more bits would be needed to store this integer.
63-Floor@Log2[#/.{_?(#<0&):>2^63,0:>.5}]&

Try it online!
@LegionMammal978's solution is quite a bit shorter at 28 bytes.  The input must be an integer.  Per the documentation: "BitLength[n] is effectively an efficient version of Floor[Log[2,n]]+1. "  It automatically handles the case of zero correctly reporting 0 rather than -∞.
Wolfram Language (Mathematica), 28 bytes
Boole[#>=0](64-BitLength@#)&

Try it online!

Boole[#>=0](64-BitLength@#)& is a good bit shorter at 28 bytes. It uses the same basic concept as yours, but applies BitLength and Boole.

I totally forgot about BitLength!

Perl 5 -p, 42 bytes
1while$_>0&&2**++$a-1<$_;$_=0|$_>=0&&64-$a

Try it online!
Longer than a bitstring based solution, but a decent math based solution.

Doesn't really work if I'm not mistaken

@Dada I see that there are a few cases where the floating point division doesn't quite work out properly.  I put in an int call that should solve the issue.

Sorry, I failed my copy-past it would seem. This is what I wanted to send ;)

APL(NARS), 15 chars, 30 bytes
{¯1+1⍳⍨⍵⊤⍨64⍴2}

test for few numbers for see how to use:
  f←{¯1+1⍳⍨⍵⊤⍨64⍴2}
  f ¯9223372036854775808
0
  f 9223372036854775807
1

Rust, 18 bytes
i64::leading_zeros

Try it online!

K (ngn/k), 12 bytes
+/&\~(64#2)\

Try it online!
(64#2)\ encode the argument as 64 bits
~ bitwise not
&\ cumulative boolean and
+/ sum

# = length ... looks string based

@Titus 2\  gives a list of integers and # finds its length. no strings are involved here.

PHP, 50 46 bytes
for(;0<$n=&$argn;$n>>=1)$i++;echo$n<0?0:64-$i;

Run as pipe with -R or try it online,
<?=$argn<0?0:0|64-log($argn+1,2); has rounding issues; so I took the long way.

bitNumber - math.ceil (math.log(number) / math.log(2))
e.g
64 bit
NUMBER : 9223372036854775807
math.ceil (math.log(9223372036854775807) / math.log(2))
ANS:  63

If you could add the language name to this, that would be great,as people are likely to down vote answers that don't have the language name included

Charcoal, 15 bytes
Ｉ⁻⁶⁴Ｌ↨﹪ＮＸ²¦⁶⁴¦²

Try it online! Link is to verbose version of code. Explanation:
    Ｌ           Length of
       Ｎ        Input as a number
      ﹪         Modulo
         ²      Literal 2
        Ｘ       To the power
           ⁶⁴   Literal 64
     ↨          Converted to base
              ² Literal 2
 ⁻              Subtracted from
  ⁶⁴            Literal 64
Ｉ               Cast to string
                Implicitly print

The ¦s serve to separate adjacent integer literals. Conveniently, Charcoal's arbitrary numeric base conversion converts 0 into an empty list, however for negative numbers it simply inverts the sign of each digit, so the number is converted to the equivalent unsigned 64-bit integer first.

Java 8, 49 bytes (broken)
I misread the problem, check back later for a new solution
n->{int i=0;while(n%10==0){n/=10;i++;}return i;};

Try it online!
I opted for a loop-based solution instead of recursion or built-ins.

This doesn't work for some of the test cases, for example it returns 0 for 2 and 2147483647. But if it did work, something you could golf is to replace the while loop with for(;n%10==0;i++)n/=10; to save 3 bytes

I didn't realize I was counting zeros of the binary form of the number. Mega oof

MMIX, 36 bytes (9 instructions)
Hexdump (jelly code page):
00000000: e3ff4080 e6ff1020 e5ff0408 e4ff0102  ẉ”@⁰ȧ”Ñ ẓ”¥®ỵ”¢£
00000010: dc0000ff dc00ff00 27ff0001 da00ff00  ṇ¡¡”ṇ¡”¡'”¡¢ḷ¡”¡
00000020: f8010000                             ẏ¢¡¡

Disassembled:
clz SETL  $255,#4080
    INCML $255,#1020
    INCMH $255,#0408
    INCH  $255,#0102
    MOR   $0,$0,$255    // reverse byte order of input
    MOR   $0,$255,$0    // reverse bit order of input within bytes
    SUBU  $255,$0,1     // y = x - 1
    SADD  $0,$255,$0    // x = popcnt(y & ~x)
    POP   1,0           // return x

```

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Golf Paterson's Worms
Paterson's worms are a kind of cellular automaton that exist on an infinite triangular grid and, every step, they turn in some direction and move one unit. Their defining properties are that they can never go over the same spot twice, and whenever they encounter the same surroundings, they make the same decision. A worm always "sees" from its own perspective with its tail located at 3 and its head located in the center of this hexagon:

For example, consider the worm with the rules:

If 0, 1, 2, 4, and 5 are all blank, move in direction 2
If 0, 1, 4, and 5 are blank, and 2 is filled, move in direction 0
If 0, 1, and 5 are blank, and 2 and 4 are filled, move in direction 0

This results in the following path (from Wikipedia):

If the worm finds itself in a situation where all surroundings are filled, it terminates.
Input
A list of numbers. The nth number indicates what decision the worm should make on the nth new situation it encounters where it has to make a decision. Note that if all but one of its surroundings are filled, it must move in the only direction that is empty. This does not count as a "decision" and does not consume a number. To generate the example worm shown above, the input would be [2, 0, 0]. The input is guaranteed to produce a worm that terminates and does not retrace its path, and the input will never be too short.
Output
Output a list of coordinates indicating where the head of the worm is, starting at (1, 0). We will consider moving up and to the right to be a decrease in only the y-value, but moving up and to the left to be a decrease in the x-value and a decrease in the y-value. For example, the output of the path for the example input is
(1, 0), (1, 1), (0, 0), (-1, -1), (0, -1), (0, 0), (0, 1), (-1, 0), (0, 0)

Test cases
You can use the javascript snippet to run tests as well.
[2,0,0]: (1,0),(1,1),(0,0),(-1,-1),(0,-1),(0,0),(0,1),(-1,0),(0,0)
[1,0,4,0,1,5]: (1,0),(2,1),(2,2),(1,2),(0,1),(0,0),(0,-1),(1,-1),(2,0),(2,1),(3,1),(4,2),(4,3),(3,3),(2,2),(1,1),(1,0),(2,0),(3,1),(3,0),(4,0),(5,1),(5,2),(4,2),(3,2),(2,1),(1,1),(0,0),(-1,0),(-2,-1),(-2,-2),(-1,-2),(0,-1),(1,0),(1,-1),(2,-1),(3,0),(4,1),(4,2),(5,3),(5,4),(4,4),(3,3),(3,4),(2,4),(1,3),(1,2),(1,1),(0,1),(-1,0),(-1,1),(-2,1),(-3,0),(-3,-1),(-2,-1),(-1,-1),(0,0)
[1,0,5,1]: (1,0),(2,1),(2,2),(1,2),(0,1),(0,0),(0,-1),(1,-1),(2,0),(2,1),(3,2),(3,3),(2,3),(1,2),(0,2),(-1,1),(-1,0),(0,0),(1,1),(1,2),(1,3),(0,3),(-1,2),(-1,1),(-2,0),(-2,-1),(-1,-1),(0,0)
[2,0,1,0]: (1,0),(1,1),(0,0),(-1,-1),(0,-1),(0,0),(-1,0),(-1,-1),(-1,-2),(0,-1),(1,0),(2,1),(1,1),(0,1),(0,0)

The following hastily assembled (possibly buggy) program will display the worms:

var canvas = document.querySelector("canvas");
var ctx = canvas.getContext("2d");

var input, memory;

var log = str => {
  console.log(str);
  document.querySelector("textarea").value += str + "\n";
};

var orientations = [
  [1, 0],
  [1, 1],
  [0, 1],
  [-1, 0],
  [-1, -1],
  [0, -1]
];

var arena = {
  grid: [[[1, 0, 0]]],
  maxX: 1,
  maxY: 0,
  expandGrid: function() {
    var grid = this.grid;
    var newWidth = grid[0].length + 2,
      newHeight = grid.length + 2;
    var createRow = () => {
      var result = [];
      for (let i = 0; i < newWidth; ++i) result.push([0, 0, 0]);
      return result;
    };
    for (let row of grid) {
      row.push([0, 0, 0]);
      row.unshift([0, 0, 0]);
    };
    grid.push(createRow());
    grid.unshift(createRow());
  },

  gridWidth: function() {
    return this.grid[0].length
  },
  gridHeight: function() {
    return this.grid.length
  },
  get: function(x, y) {
    var colOffset = Math.floor(this.gridWidth() / 2),
      rowOffset = Math.floor(this.gridHeight() / 2);
    return this.grid[y + rowOffset][x + colOffset];
  },
  isAtEnd: function(x, y) {
    var colOffset = Math.floor(this.gridWidth() / 2),
      rowOffset = Math.floor(this.gridHeight() / 2);
    return x === -colOffset || x + colOffset + 1 === this.gridWidth() ||
      y === -rowOffset || y + rowOffset + 1 === this.gridHeight();
  },
  getEdge: function(x, y, o) {
    if (o % 2 === 0) return this.get(x, y)[o / 2];
    else {
      let a, b;
      [a, b] = orientations[(o + 3) % 6];
      return this.get(x - a, y - b)[((o + 3) % 6) / 2];
    }
  },
  setEdge: function(x, y, o) {
    if (Math.abs(x) > this.maxX) this.maxX = Math.abs(x);
    if (Math.abs(y) > this.maxY) this.maxY = Math.abs(y);
    if (o % 2 === 0) {
      if (this.get(x, y)[o / 2]) throw new Error("Path already taken");
      this.get(x, y)[o / 2] = 1;
    } else {
      let a, b;
      [a, b] = orientations[(o + 3) % 6];
      if (this.get(x - a, y - b)[((o + 3) % 6) / 2]) throw new Error("Path already taken");
      this.get(x - a, y - b)[((o + 3) % 6) / 2] = 1;
    }
  }
};

var drawGrid = function(area) {
  var width = canvas.width,
    height = canvas.height;
  ctx.clearRect(0, 0, width, height);
  var gridWidth = arena.gridWidth(),
    gridHeight = arena.gridHeight();
  var triangleLen = Math.floor(Math.min(
    width / (arena.maxX * 2 + arena.maxY),
    height / (arena.maxY * Math.sqrt(3)),
    width / 4
  ));
  var convert = (x, y) => [(x - y / 2) * triangleLen, triangleLen * y * Math.sqrt(3) / 2];
  var drawCirc = function(x, y) {
    var a, b;
    ctx.beginPath();
    [a, b] = convert(x, y);
    ctx.arc(a, b, 5, 0, 2 * Math.PI);
    ctx.fill();
  };
  ctx.fillStyle = "black";
  for (let y = 0; triangleLen * y * Math.sqrt(3) / 2 < height; ++y) {
    for (let x = Math.floor(y / 2); triangleLen * (x - y / 2) < width; ++x) {
      drawCirc(x, y);
    }
  };

  var drawLine = function(a, b, c, d) {
    var x, y;
    ctx.beginPath();
    [x, y] = convert(a, b);
    ctx.moveTo(x, y);
    [x, y] = convert(a + c, b + d);
    ctx.lineTo(x, y);
    ctx.stroke();
  };

  var centerY = Math.round(height / (triangleLen * Math.sqrt(3)));
  var centerX = Math.round(width / (2 * triangleLen) + centerY / 2);
  ctx.fillStyle = "red";
  drawCirc(centerX, centerY);

  for (let row = -(gridHeight - 1) / 2; row < (gridHeight + 1) / 2; ++row) {
    for (let col = -(gridWidth - 1) / 2; col < (gridWidth + 1) / 2; ++col) {
      let lines = arena.get(col, row);
      for (let j = 0; j < lines.length; ++j) {
        if (lines[j]) {
          let or = orientations[2 * j];
          drawLine(col + centerX, row + centerY, or[0], or[1]);
        }
      }
    }
  }
};

var step = function(x, y, absoluteOrientation) {
  log('(' + x + ',' +  y + ')');
  var surroundings = 0;
  for (let i = 0; i < 6; ++i) {
    if (arena.getEdge(x, y, (absoluteOrientation + i) % 6)) {
      surroundings |= (1 << i);
    }
  }
  if (surroundings == 63) {
    console.log("Done!");
    return;
  }
  var action;
  if (memory[surroundings] !== undefined)
    action = memory[surroundings];
  else {
    action = input.shift();
    memory[surroundings] = action;
  }
  absoluteOrientation = (absoluteOrientation + action) % 6;
  arena.setEdge(x, y, absoluteOrientation);
  var or = orientations[absoluteOrientation];
  x += or[0];
  y += or[1];
  if (arena.isAtEnd(x, y)) arena.expandGrid();
  drawGrid(arena);
  setTimeout(function() {
    step(x, y, absoluteOrientation);
  }, parseFloat(document.querySelector("input[type=number]").value));
};

var go = function() {
  input = document.querySelector("input[type=text]").value.split(",").map(x => parseInt(x, 10));
  arena.grid = [[[1, 0, 0]]];
  arena.maxX = 1;
  arena.maxY = 0;
  memory = {};

  for (let i = 0; i < 6; ++i) {
    memory[(~(1 << i)) & 63] = i;
  }

  arena.expandGrid();
  arena.expandGrid();

  step(1, 0, 0);
};

document.querySelector("button").onclick = go;
canvas {
  border: 1px solid black;
}
Input: <input type="text" placeholder="Comma separated input">

Delay (ms): <input type="number" placeholder="delay" value="500"/><button>Go</button>

<canvas width="500" height="400"></canvas>

<textarea></textarea>

Suggested test case :p (This is [1,0,4,2,0,1,5].)

Can we take the input in reverse order?

@Arnauld sure that seems ok

JavaScript (ES6),  261 250  249 bytes
Takes the input list in reverse order. Returns a list of \$[x,y]\$ pairs.
a=>(G=[[[x=1]]],v=[0,1,1,0,-1,-1],F=y=>[[x,y],...v.every((_,i)=>k^=g(o+i)[q%3]<(r=G[Y=y-o%2*v[q=(o+3)%6]]=G[Y]||[])[X=x-o%2*v[-~q%6]]=r[X]||[])?F(y+v[g(o+=F[k]|=1/F[k]?0:k&~-k?a.pop():31-Math.clz32(k))[q%3]=1,o%6],x+=v[-~o%6]):[]])(o=0)

Try it online!
This is essentially a port of the demo snippet.

K (ngn/k), 115 bytes
D,:-D:2\6 3;f:{d::0;m::2/=6;X::(!6),x;{m::?m,p:2/^(+':x)?(2*h:*|x)+/:D 6!d+!6;$[(~p)|^c:X m?p;x;x,,h+D 6!d+:c]}/,1 0}

(not counting the function naming part, f:)
Try it online!
D,:-D:2\6 3 generates the six cardinal directions (1 0;1 1;0 1;-1 0;-1 -1;0 -1)
d::0 is the current direction, used as an index mod 6 in D
m::2/=6 generates the initial worm memory 32 16 8 4 2 1. the bits of each number encode the surroundings (0=visited segment; 1=unvisited). initially m contains only unambiguous surroundings - those in which a single exit is available.
X::(!6),x are the worm's rules. we prepend 0 1 2 3 4 5 to match the intial unambiguous surroundings in m.
{...}/,1 0 apply until convergence the function { } starting with a 1-element list containing 1 0. the list will contain pairs of coordinates visited by the worm.
D 6!d+!6 the six cardinal directions starting from d and going around clockwise
h:*|x last of the argument, i.e. the position of the worm's head
(2*h:*|x)+/:D 6!d+!6 multiply the head's coordinates by 2 and add the cardinal directions. this is our way to represent the segments between points.
+':x add pairs of adjacent visited points - this gives us the representations of segments between them
^(...)?... find out which of the head's surrounding segments haven't been visited yet
p:2/ binary encode and assign to p
m::?m,p append to m and keep the distinct, i.e. append p to m only if p doesn't occur in m
$[...;...;...] if-then-else
c:X m?p find the index of p in m and use it as an index in X. out-of-bounds indexing results in 0N ("null")
$[(~p)|^c:X m?p;x;...] if p is 0 (no exit path) or c is 0N, then return x which will force convergence and stop the loop
x,,h+D 6!d+:c else append the new head to x and repeat


text:
Trifid Cipher (without keyword)
Introduction:
I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post all of them, or only a few. Here is the second one (the Computer Cipher was the first one I posted).

For the Trifid Cipher (without using a keyword) the alphabet (and an additional wildcard) is divided into three 3 by 3 tables:
table 1:     table 2:     table 3:
 |1 2 3       |1 2 3       |1 2 3
-+-----      -+-----      -+-----
1|a b c      1|j k l      1|s t u
2|d e f      2|m n o      2|v w x
3|g h i      3|p q r      3|y z

A text we want to encipher is first character by character encoded into table-row-column numbers. For example, the text this is a trifid cipher becomes:
        t h i s   i s   a   t r i f i d   c i p h e r
table:  3 1 1 3 3 1 3 3 1 3 3 2 1 1 1 1 3 1 1 2 1 1 2
row:    1 3 3 1 3 3 1 3 1 3 1 3 3 2 3 2 3 1 3 3 3 2 3
column: 2 2 3 1 3 3 1 3 1 3 2 3 3 3 3 1 3 3 3 1 2 2 3

We then put everything after one another row by row in the table above in groups of three:
311 331 331 332 111 131 121 121 331 331 313 133 232 313 332 322 313 313 132 333 313 331 223

And those are transformed back to characters using the same tables:
s   y   y   z   a   g   d   d   y   y   u   i   q   u   z   w   u   u   h       u   y   o

One thing to note, the input-length should be coprime to 3. So if the length is a multiple of 3, we append one or two trailing spaces to make the input-length not a multiple 3 anymore.
Challenge:
Given a string sentence_to_encipher, encipher it as described above.
You only have to encipher given the sentence_to_encipher, so no need to create a deciphering program/function as well. I might make a part 2 challenge for the deciphering in the future however (although I have the feeling it's to trivial/similar to the enciphering process).
Challenge rules:

You can assume the sentence_to_encipher will only contain letters and spaces.
You can use either full lowercase or full uppercase (please state which one you've used in your answer).
You can choose to append either one or two trailing spaces when the input-length is 3 to make it not a multiple of 3 anymore.
I/O is flexible. Both input and output can be a string, list/array/stream of characters, etc.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:
Input:            "this is a trifid cipher"
Output:           "syyzagddyyuiquzwuuh uyo"

Input:            "test"
Output:           "utbk"

Input:            "output"
Possible outputs: "rrvgivx" (one space) or "rrzcc lr" (two spaces)

Input:            "trifidcipher"
Possible output:  "vabbuxlzz utr" (one space) or "vabbyzv rx ie " (two spaces)

I read that as "without keyboard".  That was going to be a delightful challenge!

Why should the input's length be coprime to 3? I don't see how that matters here.

The coprime requirement isn't necessary to make the cipher work, but it does make it very slightly more secure by ensuring the groups of three digits will not line up with the row divisions of the initial digit list.

@NicHartley You're indeed right that even if the input is divisible by 3 you can still transpose the table. I initially didn't had that rule in the Sandbox, but someone said to me the Wikipedia for Trifid shows it should add one or two spaces to make the enciphering slightly more secure. So I added it as part of the challenge, and to make it more in sync with the Wikipedia page (apart from the Keyword that I removed).

@KevinCruijssen I... really don't see how that'd make it more secure (if anything, forcing the input to be not of a certain length would make it less secure, as you could guess that the last character is encoding a space) but I do agree that keeping the cipher description here in line with Wikipedia is a good idea. Thanks for explaining!

Jelly, 29 26 25 bytes
⁶Øa;3ṗ¤,©Ṛy;⁶$L3ḍƊ¡ZFs3®y

Try it online!
How it works
⁶Øa;3ṗ¤,©Ṛy;⁶$L3ḍƊ¡ZFs3®y  Main link. Argument: s (string)

⁶                          Set the return value to space.
 Øa;                       Append it to "a...z".
    3ṗ¤                    Yield the third Cartesian power of [1, 2, 3].
       ,©                  Pair the results and store the pair in the register.
                           The register now holds
                           [[[1, 1, 1], ..., [3, 3, 3]], ['a', ... ,'z', ' '].
         Ṛ                 Reverse the outer array.
           ;⁶$             Append a space to s...
              L3ḍƊ¡        if the length is divisible by 3.
          y                Transliterate according to the mapping to the left.
                   ZFs3    Zip/transpose, flatten, split into chunks of length 3.
                       ®y  Transliterate according to the mapping in the register.

I never know the rules about side-effect outputs... but the arrangement ;L3ḍƊ¡⁶µ⁶Øa;3ṗ¤,ðṚyZFs3⁸y can do away with the µ if it's acceptable for 24.

We have a weak consensus (+6/-1) that this is allowed, so thanks!

The output appears to be incorrect. I don't think the appended space "sticks".

Charcoal, 39 bytes
≔Ｅ⁺θ× ¬﹪Ｌθ³⌕βιθ⭆⪪Ｅ⁺÷θ⁹⁺÷θ³θ﹪ι³¦³§⁺β ↨³ι

Try it online! Link is to verbose version of code. Explanation:
≔               Assign
   θ            Input string
  ⁺             Concatenated with
                Literal space
    ×           Repeated
         θ      Input string
        Ｌ       Length
       ﹪        Modulo
          ³     Literal 3
      ¬         Logical not
 Ｅ              Mapped over characters
             ι  Current character
           ⌕    Position found in
            β   Lowercase alphabet
              θ To variable

     θ                      List of positions
    ÷                       Vectorised integer divide by
      ⁹                     Literal 9
   ⁺                        Concatenated with
         θ                  List of positions
        ÷                   Vectorised integer divide by
          ³                 Literal 3
       ⁺                    Concatenated with
           θ                List of positions
  Ｅ                         Map over values
             ι              Current value
            ﹪               Modulo
              ³             Literal 3
 ⪪                          Split into
                ³           Groups of 3
⭆                           Map over groups and join
                   β        Lowercase alphabet
                  ⁺         Concatenated with
                            Literal space
                 §          Cyclically indexed by
                       ι    Current group
                     ↨      Converted from
                      ³     Base 3
                            Implicitly print

Python 2, 180 176 174 165 163 bytes
lambda s:''.join(chr(32+(33+a*9+3*b+c)%59)for a,b,c in zip(*[iter(sum(zip(*[(c/9,c/3%3,c%3)for c in map(o,s+' '[len(s)%3:])]),()))]*3))
o=lambda c:(ord(c)%32-1)%27

Try it online!
Input can be upper or lower. Output is uppercase

Pyth, 34 33 bytes
m@+G;id3csCmtj+27x+G;d3+W!%lz3zd3

Full program. Input is expected as lowercase, output is a character array. Try it online here, or verify all test cases at once here.
m@+G;id3csCmtj+27x+G;d3+W!%lz3zd3   Implicit: z=input(), d=" ", G=lowercase alphabet
                           lz       Length of z
                          %  3      The above, mod 3
                        W!          If the above != 3...
                       +      zd    ... append a space to z
           m                        Map the elements of the above, as d, using:
                  +G;                 Append a space to the lowercase alphabet
                 x   d                Find the 0-based index of d in the above
              +27                     Add 27 to the above
             j        3               Convert to base 3
            t                         Discard first element (undoes the +27, ensures result is 3 digits long)
          C                         Transpose the result of the map
         s                          Flatten
        c                       3   Split into chunks of length 3
m                                   Map the elements of the above, as d, using:
     id3                              Convert to decimal from base 3
 @+G;                                 Index the above number into the alphabet + space
                                    Implicit print

Alternative 34 byte solution: sm@+G;id3csCm.[03jx+G;d3+W!%lz3zd3 - rather than +27 and tail, uses .[03 to pad with 0 to length 3. Can be 33 if the leading s is dropped.
Edit: saved a byte by dropping leading s as character arrays are valid output

Ruby, 153 145 138 131 bytes
->a{a<<" "if a.size%3<1;a.map{|c|[(b=(c.ord%32-1)%27)/9,b%9/3,b%3]}.transpose.join.scan(/.{3}/).map{|x|((x.to_i(3)+65)%91+32).chr}}

Try it online!
A quick and naive approach, works with lowercase text. Inputs and outputs arrays of characters.

Java (JDK), 192 bytes
s->{String T="",R=T,C=T,r=T;for(int c:s){c-=c<33?6:97;T+=c/9;R+=c%9/3;C+=c%3;}for(var S:(s.length%3<1?T+2+R+2+C+2:T+R+C).split("(?<=\\G...)"))r+=(char)((Byte.valueOf(S,3)+65)%91+32);return r;}

Try it online!
Very naive approach. Takes a lowercase char[] as input but outputs a String.
Explanations
s->{                                       // char[]-accepting lambda
 String T="",                              //  declare variables Table as an empty string,
        R=T,                               //                    Row as an empty string,
        C=T,                               //                    Column as an empty string,
        r=T;                               //                    result as an empty string.
 for(int c:s){                             //  for each character
  c-=c<33?6:97;                            //   map each letter to a number from 0 to 25, space to 26.
  T+=c/9;                                  //   append the table-value to Table
  R+=c%9/3;                                //   append the row-value to Row
  C+=c%3;                                  //   append the column-value to Column
 }                                         //
 for(var S:                                //  For each token of...
     (s.length%3<1?T+2+R+2+C+2:T+R+C)      //    a single string out of table, row and column and take the space into account if the length is not coprime to 3...
      .split("(?<=\\G...)"))               //    split every 3 characters
  r+=(char)((Byte.valueOf(S,3)+65)%91+32); //   Parses each 3-characters token into a number, using base 3,
                                           //  and make it a letter or a space
 return r;                                 //  return the result
}

Credits

-14 bytes thanks to Kevin Cruijssen

R, 145 bytes
function(s,K=array(c(97:122,32),rep(3,3)))intToUtf8(K[matrix(arrayInd(match(c(utf8ToInt(s),32[!nchar(s)%%3]),K),dim(K))[,3:1],,3,byrow=T)[,3:1]])

Try it online!
I/O as strings; adds one space. The strange repetition of [,3:1] is because R's natural array indexing is somewhat different.

Dang, you beat me by over 200 bytes. I'm always impressed by your coding, @Giuseppe. I shouldn't even bother trying sometimes

@Sumner18 well thanks! I usually try to let a day or two pass before answering challenges since I know there are plenty of other R golfers here now, but I couldn't resist this one since I saw it in the Sandbox. You're always welcome to bounce ideas for golfing off us in the R golfing chatroom. :-)

@Sumner18 also there's no shame in trying and coming up short, my first submission here was horrible and I've only gotten better! Please continue to post, I think it's always good to get feedback so you can improve :-)

APL+WIN, 102 bytes
⎕av[n[c⍳(⊂[2]((⍴t),3)⍴,⍉⊃(c←⊂[2]c,(,⍉9 3⍴c←9/⍳3),[1.1]27⍴⍳3)[(⎕av[n←(97+⍳26),33])⍳t←t,(3|⍴t←⎕)↓' '])]]

Explanation:
t←t,(3|⍴t←⎕)↓' ' Prompts for input and applies coprime condition

(⎕av[n←(97+⍳26),33]⍳ Indices of characters in APL atomic vector

c←⊂[2]c,(,⍉9 3⍴c←9/⍳3),[1.1]27⍴⍳3) Create a matrix of table, row column for 27 characters

⊂[2]((⍴t),3)⍴,⍉⊃ Extract columns of c corresponding to input and re-order

c⍳ Identify Column indices of re-ordered columns

⎕av[.....] Use indices back in atomic vector to give enciphered text

Example of screen shot of test case:
⎕av[n[c⍳(⊂[2]((⍴t),3)⍴,⍉⊃(c←⊂[2]c,(,⍉9 3⍴c←9/⍳3),[1.1]27⍴⍳3)[(⎕av[n←(97+⍳26),33])⍳t←t,(3|⍴t←⎕)↓' '])]]
⎕:
'output'
rrvgivx

Would you mind adding a screenshot of (one or multiple of) the test cases? I know  the WIN APL version isn't available on TIO, but I'd still like to see some kind of verification, since I barely know how to interpret APL code by just reading it, let alone verifying it without running. :)

Not quite sure how to do that but this is what it would look like. I will add something to entry above

Normally I can use Dyalog Classic in TIO but in this case its atomic vector is in a different order so the indexing will not work.

JavaScript (Node.js),  146 141 139  136 bytes
I/O is in lowercase.
s=>'931'.replace(/./g,d=>Buffer(s.length%3?s:s+0).map(c=>(o=(c>48?c-16:26)/d%3+o*3%27|0,++i)%3?0:(o+97)%123||32),i=o=0).split`\0`.join``

Try it online!
Commented
s =>                       // s = input string
  '931'.replace(/./g, d => // for each digit d = 9, 3 and 1:
    Buffer(                //   create a buffer from:
      s.length % 3 ?       //     if the length of s is coprime with 3:
        s                  //       the original input string
      :                    //     else:
        s + 0              //       the input string + an extra '0'
    )                      //
    .map(c =>              //   for each ASCII code c from this Buffer:
      ( o =                //     update o:
        ( c > 48 ?         //       if c is neither a space nor the extra '0':
            c - 16         //         yield c - 16 (which gives 81 .. 106)
          :                //       else:
            26             //         this is the 26th character (space)
        ) / d % 3 +        //       divide by d and apply modulo 3
        o * 3 % 27 | 0,    //       add o * 3, apply modulo 27, coerce to integer
        ++i                //       increment i
      ) % 3 ?              //     if i mod 3 is not equal to 0:
        0                  //       yield 0 (NUL character)
      :                    //     else:
        (o + 97) % 123     //       convert o to the ASCII code of the output letter
        || 32              //       or force 32 (space) for the 26th character
    ),                     //   end of map()
    i = o = 0              //   start with i = o = 0
  ).split`\0`.join``       // end of replace(); remove the NUL characters

I think you've explained it once before, but how does (o=...,++i)%3 work in JS again? Is (o,i) a tuple or something, and both inner integers are converted to their modulo-3? As a Java developer, it still confuses me a bit to see (a,b)%c. Nice answer though! I like how you convert every third digit, and then remove the first two null-bytes. +1 from me.

@KevinCruijssen Quoting MDN: "The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand." So, the modulo is only applied to ++i.

SAS, 305 bytes
A hearty 'oof' for this SAS monstrosity. There's a lot of random string formatting that I thought I could avoid going into this; I'm sure there are better ways of doing some of this.
data;input n:&$99.;n=tranwrd(trim(n)," ","{");if mod(length(n),3)=0then n=cats(n,'{');f=n;l=length(n);array a(999);do i=1to l;v=rank(substr(n,i,1))-97;a{i}=int(v/9);a{i+l}=mod(int(v/3),3);a{i+l*2}=mod(v,3);end;f='';do i=1to l*3by 3;f=cats(f,byte(a{i}*9+a{i+1}*3+a{i+2}+97));end;f=tranwrd(f,"{"," ");cards;

Input is entered on newlines after the cards statement, like so:
data;input n:&$99.;n=tranwrd(trim(n)," ","{");if mod(length(n),3)=0then n=cats(n,'{');f=n;l=length(n);array a(999);do i=1to l;v=rank(substr(n,i,1))-97;a{i}=int(v/9);a{i+l}=mod(int(v/3),3);a{i+l*2}=mod(v,3);end;f='';do i=1to l*3by 3;f=cats(f,byte(a{i}*9+a{i+1}*3+a{i+2}+97));end;f=tranwrd(f,"{"," ");cards;
this is a trifid cipher
test
output
trifidcipher

Outputs a dataset containing the output in the variable f, along with a bunch of helper variables/array values.

Ungolfed/explanation:
data;
input n : & $99.; /* Read a line of input, maximum 99 characters */

n=tranwrd(trim(n)," ","{"); /* Replace spaces with '{' (this is the ASCII character following 'z', so it makes it easy to do byte conversions, and lets us not have to deal with spaces, which SAS does not like) */
if mod(length(n),3)=0then n=cats(n,'{'); /* If length of n is not coprime with 3, add an extra "space" to the end */

f=n; /* Set output = input, so that the string will have the same length */
l=length(n);    /* Get the length of the input */
array a(999);   /* Array of values to store intermediate results */

do i = 1 to l; /* For each character in the input... */
    v = rank(substr(n,i,1))-97; /* Get the value of the current character, from 0-26 */

    a{i}=int(v/9);          /* Get the table of the current character and store at appropriate index, from 0-2  */
    a{i+l}=mod(int(v/3),3); /* Get the row of the current character, from 0-2 */
    a{i+l*2}=mod(v,3);      /* Get the column of the current character, from 0-2  */
end;

f='';

do i = 1 to l*3 by 3; /* For each character in the output... */
    f=cats(f,byte(a{i}*9+a{i+1}*3+a{i+2}+97)); /* Convert values back from base 3 to base 10, and convert back into ASCII value */
end;

f = tranwrd(f,"{"," "); /* Replaces our "spaces" with actual spaces for final output */

/* Test cases */
cards;
this is a trifid cipher
test
output
trifidcipher

05AB1E, 25 bytes
g3Öð×«SAð«3L3ã©‡ø˜3ô®Að«‡

Since no one posted a 05AB1E answer yet, I figured I'd post my own solution. I see now it's very similar to @Dennis♦' Jelly answer, even though I came up with it independently before I posted the challenge.
Input as string, output as a list of characters. Adds one space if the length is divisible by 3.
Try it online or verify all test cases.
Explanation:
g3Ö         # Check if the length of the (implicit) input is divisible by 3
            # (results in 1 for truthy or 0 for falsey)
            #  i.e. "out" → 1
            #  i.e. "test" → 0
   ð×       # Repeat a space that many times
            #  i.e. 1 → " "
            #  i.e. 0 → ""
     «      # And append it to the (implicit) input
            #  i.e. "out" and " " → "out "
            #  i.e. "test" and "" → "test"
      S     # Then make the string a list of characters
            #  i.e. "out " → ["o","u","t"," "]
            #  i.e. "test" → ["t","e","s","t"]
A           # Push the lowercase alphabet
 ð«         # Appended with a space ("abcdefghijklmnopqrstuvwxyz ")
   3L       # Push list [1,2,3]
     3ã     # Cartesian repeated 3 times: [[1,1,1],[1,1,2],...,[3,3,2],[3,3,3]]
       ©    # Save that list of triplets in the registry (without popping)
        ‡   # Transliterate, mapping the letters or space to the triplet at the same index
            #  i.e. ["o","u","t"," "] → [[2,2,3],[3,1,3],[3,1,2],[3,3,3]]
            #  i.e. ["t","e","s","t"] → [[3,1,2],[1,2,2],[3,1,1],[3,1,2]]
ø           # Zip, swapping all rows/columns
            #  i.e. [[2,2,3],[3,1,3],[3,1,2],[3,3,3]] → [[2,3,3,3],[2,1,1,3],[3,3,2,3]]
            #  i.e. [[3,1,2],[1,2,2],[3,1,1],[3,1,2]] → [[3,1,3,3],[1,2,1,1],[2,2,1,2]]
 ˜          # Flatten the list
            #  i.e. [[2,3,3,3],[2,1,1,3],[3,3,2,3]] → [2,3,3,3,2,1,1,3,3,3,2,3]
            #  i.e. [[3,1,3,3],[1,2,1,1],[2,2,1,2]] → [3,1,3,3,1,2,1,1,2,2,1,2]
  3ô        # Split it into parts of size 3
            #  i.e. [2,3,3,3,2,1,1,3,3,3,2,3] → [[2,3,3],[3,2,1],[1,3,3],[3,2,3]]
            #  i.e. [3,1,3,3,1,2,1,1,2,2,1,2] → [[3,1,3],[3,1,2],[1,1,2],[2,1,2]]
®           # Push the triplets from the registry again
 Að«        # Push the lowercase alphabet appended with a space again
    ‡       # Transliterate again, mapping the triplets back to letters (or a space)
            # (and output the result implicitly)
            #  i.e. [[2,3,3],[3,2,1],[1,3,3],[3,2,3]] → ["r","v","i","x"]
            #  i.e. [[3,1,3],[3,1,2],[1,1,2],[2,1,2]] → ["u","t","b","k"]

Japt, 42 bytes
;Êv3 ?UpS:U
m!bS=iC)®+27 ì3 ÅÃÕc ò3 £SgXì3

Try it online!
The core of this answer comes from a deleted answer by Shaggy, but he never came back to handle inputs of length divisible by 3 so this is a fixed version.
Explanation:
;                                 #Set C to the string "abcdefghijklmnopqrstuvwxyz"

 Ê                                #Get the length of the input
  v3 ?                            #If it is divisible by 3:
      UpS                         # Add a space
         :U                       #Otherwise don't add a space
                                  #Store the result in U

   S=iC)                          #Set S to C plus a space
m                                 #For each character in U:
 !bS                              # Get the position of that character in S
        ®        Ã                #For each resulting index:
             ì3                   # Convert to base 3
         +27    Å                 # Including leading 0s up to 3 places
                  Õ               #Transpose rows and columns
                   c              #Flatten
                     ò3           #Cut into segments of length 3
                        £         #For each segment:
                           Xì3    # Read it as a base 3 number
                         Sg       # Get the letter from S with that index

C# (Visual C# Interactive Compiler), 178 bytes
s=>{int[]a={9,3,1},b=(s.Length%3>0?s:s+0).Select(c=>c<97?26:c-97).ToArray();s="";for(int i=0,k,l=b.Length;i<l*3;s+=(char)(k>25?32:97+k))k=a.Sum(p=>b[i%l]/a[i++/l]%3*p);return s;}

Try it online!
Less golfed... It's still confusing :)
// s is an input string
s=>{
  // powers of 3
  int[]a={9,3,1},
  // ensure the length of s is coprime to 3
  // and convert to numbers from 0-26
  b=(s.Length%3>0?s:s+0).Select(c=>c<97?26:c-97).ToArray();
  // reset s to collect result
  s="";
  // main loop
  for(
    // i is the main index variable
    // k is the value of the encoded character
    // l is the length
    int i=0,k,l=b.Length;
    // i continues until it is 3x the length of the string
    i<l*3;
    // convert k to a character and append
    s+=(char)(k>25?32:97+k)
  )
    // compute the trifid
    // (this is the confusing part :)
    k=a.Sum(p=>b[i%l]/a[i++/l]%3*p);
  // return the result
  return s;
}


text:
Regex only base64 decoder
Write a regular expression substitution string which can base64 decode a string using only a regular expression engine built into the language. Eg:
# Example in python
import re

print(re.sub(..., ..., "SGVsbG8gd29ybGQK"))  # "Hello world\n"
#            ^^^  ^^^
#            These count towards your byte count, the rest doesn't

Rules:

No libraries
No tools like base64 in bash
Must be a regular expression
Must decode RFC 4648 based base64
Any programming language (eg: Python, JavaScript, PHP, Ruby, Awk, Sed)
Length of your find string + Length of your replace string = Byte count
Shortest byte count wins

I'm pretty sure this isn't even possible with a single regular-expression-based replacement.

@JoKing my bad, didn't even realise, updated it to say RFC 4648 standard

Although it's possible to do this using multiple regex replacement.

Would it be possible to change this to regex golf somehow?

Hello, I closed this as unclear because you have defined the exact form of base64 to be used, but you haven't clearly defined what constitutes single regex replacement and what would be illegal (the most logical definition based on your scoring would make this an impossible challenge).

Perl 6, 4 + 87 = 91 bytes
S/(.)*/{:64[first(.ord,:k,flat 65..90,97..122,48..57,43,47)for $0].polymod(256 xx*).chrs.flip}/

Try it online!
Assumes that the input is padded with ending =s and uses + and / as 62 and 63. Really, the first half selects everything while the second half is just a code block to translate base64...

Although impressive, I'm not sure it's valid according to "using only a regular expression engine": It executes perl code inside the replacement part... That said, I'm pretty sure the task can't be done with "pure" RE.