script-commands icon indicating copy to clipboard operation
script-commands copied to clipboard

Why the new version of Raycast script cannot send text to clipboard?

Open baker221 opened this issue 3 years ago • 14 comments

I write a Python script of OCR. The beginning part of script:

#!/usr/bin/env python3

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title ocr
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 

The clipboard operation part:

    import pyperclip
    pyperclip.copy(content)
    print("Success!")

In the old version, this works well. But now (version 1.51.3) after running it, the clipboard is still empty.

But when I run it in console, this works well.

The bash command of pbcopy or something cannot operate correctly now

baker221 avatar May 22 '23 17:05 baker221

This is weird, in this version of Raycast, if the content is Chinese, it cannot work. But if I use this script in terminal, both can work well.

    # pyperclip.copy("你好") # not work
    pyperclip.copy("hello") # work
    print("Success!")

baker221 avatar May 22 '23 17:05 baker221

I also test the following:

    import pyperclip
    pyperclip.copy(content)
    print(pyperclip.paste())

The output is empty if the content has Chinese.

But if I just print it:

    print("你好")

This can work and display.

baker221 avatar May 22 '23 17:05 baker221

I write a new simple script and I am confirmed that this is the problem of new version Raycast.

#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title mytest
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 📋

# Documentation:
# @raycast.description hello

#echo "haha" | pbcopy # works
echo "你好" | pbcopy # do not work
echo "Clipboard emptied"

baker221 avatar May 22 '23 17:05 baker221

same problem for me

YHsilver avatar May 25 '23 03:05 YHsilver

Hey @baker221 and @YHsilver,

Thank you for writing and sorry this took long to answer. I just tried your script and everything works as expected (see below).

Terminal

It looks like it has something to do with the terminal environment. Can you think of anyway I can replicate?

dehesa avatar May 30 '23 10:05 dehesa

In my computer, this doesn't work, the result is as below: Snipaste_2023-05-30_18-46-46 Now my Raycast version is 1.52.1. My macOS version is 12.6.5. I changed the first line into /bin/sh, but it cannot work either. I will try to find a way for you to reproduce it.

baker221 avatar May 30 '23 10:05 baker221

Hey @baker221 and @YHsilver,

Thank you for writing and sorry this took long to answer. I just tried your script and everything works as expected (see below).

Terminal It looks like it has something to do with the terminal environment. Can you think of anyway I can replicate?

I see that the "character" is 3. But "你好" just have 2 characters. If I copy "你好" directly, the character is 2. (But even if I added a space before this string, the script still cannot work) Snipaste_2023-05-30_18-53-25

baker221 avatar May 30 '23 10:05 baker221

same problem

alejgr avatar May 30 '23 13:05 alejgr

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

stale[bot] avatar Jun 29 '23 17:06 stale[bot]

Do you have any idea solving this issue until now? This version (1.54.1) still cannot work.

baker221 avatar Jun 30 '23 06:06 baker221

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

stale[bot] avatar Jul 30 '23 11:07 stale[bot]

Still no solution? @dehesa

baker221 avatar Aug 02 '23 08:08 baker221

Still no solution? @dehesa

I found that. The Raycast's locale somehow changed in a new version.

Change the pbcopy into below:

echo "你好" | LANG=zh_CN.UTF-8 pbcopy

baker221 avatar Aug 02 '23 09:08 baker221

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

stale[bot] avatar Sep 04 '23 23:09 stale[bot]