I get an error every time I run `op`.

TheSocialRecluse
TheSocialRecluse
Community Member
edited July 2022 in CLI

System Information
Macbook Pro 2021 (M1)
op version: 2.5.1

Every time I run op, I receive the following error:
couldn't start daemon: open /var/run/user/501/op-daemon.pid: no such file or directory

However, whatever flags I give the command, it seems to work (ie I can still get secrets, sign-in, etc...). After a little investigation, I find that I don't have the directory:
/var/run/user

I don't have $XDG_RUNTIME_DIR set, but I have defined $XDG_DATA_HOME and $XDG_CONFIG_HOME.

I could create the directory /var/run/user but that seems like a hack. How should I go about fixing this?


1Password Version: 8.7.3
Extension Version: Not Provided
OS Version: MacOS 12.4
Browser:_ Not Provided
Referrer: forum-search:couldn't start daemon: open /var/run/user/501/op-daemon.pid: no such file or directory

Comments

  • Hey there @TheSocialRecluse

    I could create the directory /var/run/user but that seems like a hack. How should I go about fixing this?

    Good call, it will certainly help us debug this issue in case it comes up for anyone else.

    Our cache opens a socket uses a file (op-daemon.pid) to determine whether the in-memory cache process that holds encrypted items (if the cache is enabled) is already running or not.

    The error message you are encountering pops up when that file cannot be located, but as you noticed, it does not affect the functionality of the command as the CLI can still run without a cache process attached to it.

    If you do not have $XDG_RUNTIME_DIR set, then the CLI should be using the following directory to locate the op-daemon.pid file in: $TMPDIR/com.agilebits.op.$USER_ID where user ID is the terminal user ID.

    I am curious how the directory in your error message does not contain the com.agilebits.op.$USER_ID portion of the directory path - that is likely the cause of the bug.

    Do you mind sharing what your $TMPDIR variable resolves to? If so, please redact any sensitive info by replacing them with var names, such as $USER_ID.

    Thanks!

  • TheSocialRecluse
    TheSocialRecluse
    Community Member

    when I echo'd $TMPDIR, I got back an entirely different directory:
    /var/folders/rr/4p_t05vx7q16xls8nsyx7hlh0000gn/T/
    (I imagine that the subdirectory of /var/folders/rr changes name with each session?)

    I did a bit more troubleshooting and decided to run rg. And lo, it would appear that $XDG_RUNTIME_DIR was actually set by a script then subsequently unset once another script had finished running. (Don't ask.) In the interim, op would get called.

    So, I fixed that.

    Now it works.

    User error..

    You devs? Did a great job. No debugging required, no hunting down. etc...

    Mea culpa.

    Have a great day!

  • And lo, it would appear that $XDG_RUNTIME_DIR was actually set by a script then subsequently unset once another script had finished running.

    Ah, that would certainly conflate things!

    Glad to know it's been fixed!

This discussion has been closed.