Giter Club home page Giter Club logo

Comments (26)

wincent avatar wincent commented on August 22, 2024

Did you perform the installation inside of a tmux session, by any chance? Doing that can prevent the clipper process from correctly opening.

from clipper.

pdoak avatar pdoak commented on August 22, 2024

I don't think that I did originally but if that were the case I have uninstalled and reinstalled clipper outside of tmux.

I am also noticing that when using nvim, I get a clipboard error message whenever I try to yank some text. This only started happening after I installed your dotfiles and I am wondering if it has to do with clipper. Regarding my installation of nvim, I am continuing to use my own init.vim not your symlinked init.vim file. Theoretically, nothing should have changed regarding nvim during your installation.

I did have problems with the original installation of the your dotfiles regarding the homebrew section. It failed but deleted a number of my installed applications which I had to manually install eg Alfred, Bartender, Skype etc. Would that have something to do with why Clipper is not working properly?

Many thanks for your help.

Paul

from clipper.

wincent avatar wincent commented on August 22, 2024

I am also noticing that when using nvim, I get a clipboard error message whenever I try to yank some text.

What is the error message you're seeing? Clipper doesn't integrate with Vim in that way because Vim doesn't provide any post-yank hooks (I wish it did; in the absence of such a feature this is why it requires that you use a manual <Leader>y to move the last-yanked text over to Clipper), so I doubt that's related.

The main thing is to check:

  • Is Clipper actually running? (ie. inspect ps auxww | grep clipper)
  • If it is running, what happens when you try to connect to it directly on the command-line? (eg. echo foo | nc localhost 8377)
  • Is there anything in the log? (~/Library/Logs/com.wincent.clipper.log).

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Thanks for getting back to me.

  • Is Clipper actually running?
    Yes, the output is:
    pdd 568 0.0 0.0 556633576 3764 ?? S 8:26am 0:00.03 /usr/local/opt/clipper/bin/clipper
    pdd 7039 0.0 0.0 2424020 1220 s002 R+ 1:53pm 0:00.00 grep clipper

  • If it is running, what happens when you try to connect to it directly on the command-line?
    Nothing happens. foo does not end up in my system clipboard.

  • Is there anything in the log? (~/Library/Logs/com.wincent.clipper.log).
    There aren't any logfiles. The directory ~/Library/Logs/com.wincent.clipper.log does not exist.

Please let me know if there are any other things that I need to check.

Thanks again for your help. It is much appreciated.

Regards

Paul

from clipper.

wincent avatar wincent commented on August 22, 2024

Cool, good to see it's running. Did you install via Homebrew? If so, it is probably configured via the file at ~/Library/LaunchAgents/homebrew.mxcl.clipper.plist; have a look at that and see if a custom path to the log file is configured (or any other custom arguments). Another place you might find overrides is the ~/.clipper.json config file.

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Greg

I did instll via homebrew. The ~/Library/LaunchAgents/homebrew.mxcl.clipper.plist has this:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>homebrew.mxcl.clipper</string>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/usr/local</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/clipper/bin/clipper</string>
  </array>
  <key>EnvironmentVariables</key>
  <dict>
    <key>LANG</key>
    <string>en_US.UTF-8</string>
  </dict>
</dict>
</plist>

It doesn't look like any custom path is included.

There is not a file at ~/.clipper.json

Any other ideas?

Many Thanks

Paul

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Greg

I must have missed it but there is a file ~/.clipper.json but it just has address: ~/.clipper.sock.

Can you think of anything else I might try to get it working properly?

Many thanks

Paul

from clipper.

pdoak avatar pdoak commented on August 22, 2024

I am at a bit of a loss as to how to get this working at this point. Is there anything else I can do to troubleshoot the problem?

Thanks for your help.

Regards

Paul

from clipper.

wincent avatar wincent commented on August 22, 2024

You can verify that a simple command like echo foo | pbcopy works. If that does, then try running Clipper as a foreground process in one window: clipper --port 9999 --logfile /tmp/clipper.log (ie. a random port) and in another windoas, echo bar | nc localhost 9000.

If that doesn't work the log may contain something useful. It may be that you have a non-standard version of netcat (eg. installed via Homebrew, GNU vs the BSD one that comes from Apple); just guessing.

from clipper.

wincent avatar wincent commented on August 22, 2024

And of course, use matching port numbers, not 9999 and 9000.

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Hi Greg

Thank you for the suggestions.

echo foo | pbcopy does work outside tmux but within does not.

If I run clipper --port 9999 --logfile /tmp/clipper.log inside a tmux window, I get the following message:
clipper: 207/01/13 09:19:39 -- port option ignored when listening on UNIX domain socket

Issuing echo bar | nc localhost 9999 in another tmux pane does not copy bar to the clipboard.

The log file looks like this:
clipper: 2017/01/13 09:19:39 listen unix /Users/pdd/.clipper.sock: bind: address already in use

Note: I had installed netcat via Homebrew. I have now uninstalled it and nothing changed.

I also did the exact process but in two iTerm windows and got the same result i.e it didn't work.

Thanks again for your continued help.

Regards

Paul

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Do you have any other suggestions for me to try so that I can get this working?

Many Thanks

Paul

from clipper.

wincent avatar wincent commented on August 22, 2024

If I run clipper --port 9999 --logfile /tmp/clipper.log inside a tmux window, I get the following message:
clipper: 207/01/13 09:19:39 -- port option ignored when listening on UNIX domain socket

Interesting. It is supposed to listen to localhost by default, not a UNIX domain socket. Try that test again but adding --address localhost.

If that works, then that's the problem. You'd need to add an --address argument into the ProgramArguments of the launch agent property list, or otherwise configure your editor/terminal etc to instead talk over the UNIX domain socket, as described in the docs. If you can be bothered doing that, it is more secure.

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Thanks Greg.

When I ran clipper --port 9999 --address localhost --logfile /tmp/clipper.log and then echo bar | nc localhost 9999, it produced this log:

clipper: 2017/01/18 09:27:52 Starting TCP server on localhost
clipper: 2017/01/18 09:29:28 Echoed 4 bytes
clipper: 2017/01/18 09:29:28 [ERROR] wait: exit status 1
clipper: 2017/01/18 09:29:28 Connection closed

I am slightly confused as to how to fix it though. I have read the docs but I am out of my depth. this is my plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>homebrew.mxcl.clipper</string>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/usr/local</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/clipper/bin/clipper</string>
  </array>
  <key>EnvironmentVariables</key>
  <dict>
    <key>LANG</key>
    <string>en_US.UTF-8</string>
  </dict>
</dict>
</plist>

How exactly should this change to incorporate the --address argument?

I have changed my ~/.clipper.json to be:

{
  "address": "localhost"
}

You mentioned that I could also configure iTerm/vim to instead talk over the UNIX domain socket. If that is a better solution, how do I do that?

Many thanks for your help.

from clipper.

wincent avatar wincent commented on August 22, 2024

it produced this log:

The exit status 1 suggests that the pbcopy process is exiting with an error status (1) for some reason. That's what I would expect to see inside of tmux on most versions of macOS (for the reasons described in the docs), unless clipper is launched in the so-called "user namespace". You can verify that for yourself as follows:

$ tmux # start a tmux session
$ echo foo | pbcopy # errors
$ brew install reattach-to-user-namespace # if you haven't already got this tool
$ echo foo | reattach-to-user-namespace # see that it works

So, one reason why your test may have failed is that you did it inside tmux. When clipper is launched as a launch agent, it already is supposed to wind up in the correct context, so you should be shielded from any of these errors. But if you run any of the launchctl commands in the docs from inside an existing tmux session (ie. to start or stop the agent) then you'll be back in the same situation of not running in the right context any more).

One way to isolate yourself from these issues is with more settings in your ~/.clipper.json:

{
  "address": "localhost",
  "executable": "reattach-to-user-namespace",
  "flags": "pbcopy"
}

I haven't tried this myself, but I expect that it will work. Normally, pbcopy is the executable, and it is invoked with no flags. Here, we abuse those two settings to instead use reattach-to-user-namespace as the executable and have it invoke pbcopy.

How exactly should this change to incorporate the --address argument?

If you are already using a ~/.clipper.json file, then I think you don't need to worry about changing the plist, as it will pull the setting from there instead. If you did want to do it in the plist it would look like this:

  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/clipper/bin/clipper</string>
    <string>--address</string>
    <string>localhost</string>
  </array>

You mentioned that I could also configure iTerm/vim to instead talk over the UNIX domain socket. If that is a better solution, how do I do that?

That's all in the documentation. Note that it is a "better" solution in the sense that it is more secure, but it is affected by context issues just like the non-domain-socket configuration, so switching to it wouldn't solve those problems for you.

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Thanks Greg but I still can't get it working.

echo foo | reattach-to-user-namespace inside a tmux session gives this message:`

fatal:usage: reattach-to-user-namespace [-l] <program> [args...]
Reattach to the per-user bootstrap namespace in its "Background" session then exec the porgram with args. If "-l" is given, rewire the program's argv[0] so that is starts with a '-'

I have changed my clipper.json to:

{
  "address": "localhost",
  "executable": "reattach-to-user-namespace",
  "flags": "pbcopy"
}

I have also tried putting:

  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/clipper/bin/clipper</string>
    <string>--address</string>
    <string>localhost</string>
  </array>

in the plist file but it still does not work.

Sorry to keep bothering you but do you have any other suggestions.

Many thanks

Paul

from clipper.

wincent avatar wincent commented on August 22, 2024

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Greg

You are right, executing clipper --address localhost --port 8377 --executable reattach-to-user-namespace --flags pbcopy in one tmux window and then echo foo | nc localhost 8377 in another works.

I have changed my clipper.json to:

{
  "address": "localhost",
  "executable": "reattach-to-user-namespace",
  "flags": "pbcopy"
}

and my plist includes these lines:

  <array>
    <string>/usr/local/opt/clipper/bin/clipper</string>
    <string>--address</string>
    <string>localhost</string>
  </array>

and my tmux includes these line:

bind-key y run-shell "tmux save-buffer - | nc localhost 8377"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "nc localhost 8377"

I have also rebooted but it still does not work. Is there anything else that you can think of that can be causing it to talk over the UNIX domain socket?

Thanks for your continued - I really appreciate it.

from clipper.

wincent avatar wincent commented on August 22, 2024

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Greg, this is the log for today:

clipper: 2017/01/20 22:01:03 Starting TCP server on localhost
clipper: 2017/01/20 22:01:03 listen tcp 127.0.0.1:8377: bind: address already in use
clipper: 2017/01/20 22:01:34 Echoed 4 bytes
clipper: 2017/01/20 22:01:34 Connection closed
clipper: 2017/01/20 22:03:27 Got signal terminated
clipper: 2017/01/20 22:22:28 Starting TCP server on localhost

what is interesting is that I just tried echo foo | pbcopy and it did not write anything to the log.

Regards

Paul

from clipper.

wincent avatar wincent commented on August 22, 2024

bind: address already in use

Well, that is interesting. I wonder what is bound to that port, and whether you somehow have two instances of Clipper getting launched from somewhere.

from clipper.

pdoak avatar pdoak commented on August 22, 2024

I have looked at Activity monitor and I only have one process of clipper running. Do you have any suggestions as to how I can track down the problem?

from clipper.

wincent avatar wincent commented on August 22, 2024

from clipper.

pdoak avatar pdoak commented on August 22, 2024

Thanks Greg.

I have done a little investigating and I'm not sure whether I have found something significant or not.

I have uninstalled clipper and rebooted and reinstalled clipper. Now when I look in the logs, I see:

clipper: 2017/01/22 19:21:40 exec: "reattach-to-user-namespace": executable file not found in $PATH

I have uninstalled reattach-to-user-namespace and reinstalled. which reattach-to-user-namespace shows /usr/local/bin/reattach-to-user-namespace and my $PATH shows

/Users/xxx/.composer/vendor/bin:/Documents/Ruby:/usr/texbin:/Users/xxx/.rbenv/shims:/Users/xxx/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Library/TeX/texbin:/Users/xxx/.fzf/bin

usr/local/bin is in my $PATH. Do you have any suggestions/thoughts?

from clipper.

wincent avatar wincent commented on August 22, 2024

from clipper.

wincent avatar wincent commented on August 22, 2024

Closing due to inactivity.

from clipper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.