Closed wxiaoguang closed 2 years ago
It seems that this bug is caused the 'PWD' in launchctl is '/'
If I use this script as launchctl:
#!/bin/sh
cd
/Applications/PydioSync.app/Contents/Resources/pydio-agent
everything works
Could you give me a bit more details about your setup? Did you simply install from pydio.com? Can you give the exact path to the file that's causing the problem?
I just downloaded the PydioSync-MacOSX-Installer-v1.2.7.dmg from website and do install. Then I found that the pydio-agent couldn't start.It seems that this bug is caused the 'PWD' in launchctl is '/' (the root dir).
How I debug the problem: I changed the ProgramArguments
in /Library/LaunchAgents/io.pyd.sync.launcher.plist
to my script, eg: /Applications/PydioSync.app/Contents/Resources/pydio-agent-launch
then in /Applications/PydioSync.app/Contents/Resources/pydio-agent-launch
I export env variables to /tmp: export > /tmp/a.log
and export stderr to /tmp /Applications/PydioSync.app/Contents/Resources/pydio-agent 2>/tmp/err.log
It is clear that if pydio-agent-launch is executed by shell, the agent starts. If pydio-agent-launch is executed by launchctl/launchd, the agent fails.
Then I change the pydio-agent-lanuch
to
#!/bin/sh
cd
/Applications/PydioSync.app/Contents/Resources/pydio-agent
Then the launchctl can start the agent correctly.
More detail: in the shell, if you do cd /
first, /Applications/PydioSync.app/Contents/Resources/pydio-agent
fails as it is in launchd.
How do you use launchctl ?
We use something like this
launchctl bsexec $PID chroot -u $UID / launchctl load /Library/LaunchAgents/io.pyd.sync.launcher.plist
1 . At first, I just installed the PydioSync-MacOSX-Installer-v1.2.7.dmg and do nothing else .... PydioSync keeps saying failed to connect pydio-agent
$ /Applications/PydioSync.app/Contents/MacOS/pydio-ui
Starting agent via launchctl command.
SETTING ICON normal
libpng warning: iCCP: known incorrect sRGB profile
-- HTTPMANAGER -- : "Server set to http://127.0.0.1:5556"
-- HTTPMANAGER -- : "Username set to ZXU2iRdCKL9LA2Fx"
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
Starting MacOS extension
Extension started.
""
-- HTTPMANAGER -- : "HTTP Poller Reply : Connection refused"
$ tail /var/log/system.log
Aug 29 21:59:05 XiaoguangdeMBP pydioswiftsync[10901]: No jobs found, reloading credentials...
Aug 29 21:59:05 XiaoguangdeMBP pydioswiftsync[10901]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
Aug 29 21:59:05 XiaoguangdeMBP pydioswiftsync[10901]: No jobs found, reloading credentials...
Aug 29 21:59:05 XiaoguangdeMBP pydioswiftsync[10901]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
Aug 29 21:59:06 XiaoguangdeMBP pydioswiftsync[10901]: No jobs found, reloading credentials...
Aug 29 21:59:06 XiaoguangdeMBP pydioswiftsync[10901]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
Aug 29 21:59:06 XiaoguangdeMBP pydioswiftsync[10901]: No jobs found, reloading credentials...
Aug 29 21:59:06 XiaoguangdeMBP pydioswiftsync[10901]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
Aug 29 21:59:06 XiaoguangdeMBP pydioswiftsync[10901]: No jobs found, reloading credentials...
Aug 29 21:59:06 XiaoguangdeMBP pydioswiftsync[10901]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
The PydioSync should work with simple installation.
2 . I have checked the exported env variables when debugging, when using launchctl to start service, current user is correct (is my mac account).
If I change the working directory of pydio-agent in launchd, everything works.
And again: in the shell, if you do cd /
first, /Applications/PydioSync.app/Contents/Resources/pydio-agent fails as it is in launchd. This should be the bug: "pydio-agent" fails to start when working directory is not correct
Sorry for the delay. I've been testing many things on different machines. Launching PydioSync via launchpad or via /Applications/PydioSync.app/Contents/MacOS/pydio-ui worked fine everytime.
This is the command that corresponds to "Starting agent via launchctl command." launchctl load -w /Library/LaunchAgents/io.pyd.sync.launcher.plist
On my Mac it works fine. I think the problem is we don't wait long enough for the agent to start.
The real problem here is why do you get IOError: [Errno 13] Permission denied: 'data/ports_config'
Thank you for your reply :)
Can you try these steps?
cd /
/Applications/PydioSync.app/Contents/Resources/pydio-agent
These steps reports IOError: [Errno 13] Permission denied: 'data/ports_config'
everytime.
For me this launches pydio-agent fine.
Can you run this?
ls -l /Users/wxiaoguang/Library/Application Support/Pydio/ports_config
(care the username)
-rw-r--r-- 1 thomas staff 70 Sep 6 12:04 /Users/thomas/Library/Application Support/Pydio/ports_config
I deleted everything related to Pydio and do a clean installation.
The first time to install from PydioSync-MacOSX-Installer-v1.2.7
, there is NO ports_config
$ ls -lh "/Users/xiaoguang/Library/Application Support/Pydio/"
total 8.0K
-rw-r--r-- 1 xiaoguang staff 1.5K Sep 6 18:09 general_config.json
-rw-r--r-- 1 xiaoguang staff 690 Sep 6 18:09 pydio.log
$ cat /Library/LaunchAgents/io.pyd.sync.launcher.plist
<!--?xml version="1.0" encoding="UTF-8"?-->
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>PydioSync</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/PydioSync.app/Contents/Resources/pydio-agent</string>
</array>
<key>OnDemand</key>
<false/>
</dict>
</plist>
in system.log:
/var/log/system.log:18160:Sep 6 18:09:14 192 pydioswiftsync[2810]: Loaded pydioswiftsync
/var/log/system.log:18161:Sep 6 18:09:14 192 pydioswiftsync[2810]: Failed to read /Users/xiaoguang/Library/Application Support/Pydio/ports_config
/var/log/system.log:18162:Sep 6 18:09:14 192 pydioswiftsync[2810]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
/var/log/system.log:18163:Sep 6 18:09:16 192 pydioswiftsync[2810]: No jobs found, reloading credentials...
/var/log/system.log:18164:Sep 6 18:09:16 192 pydioswiftsync[2810]: Failed to read /Users/xiaoguang/Library/Application Support/Pydio/ports_config
/var/log/system.log:18165:Sep 6 18:09:16 192 pydioswiftsync[2810]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
/var/log/system.log:18166:Sep 6 18:09:16 192 pydioswiftsync[2810]: No jobs found, reloading credentials...
/var/log/system.log:18167:Sep 6 18:09:16 192 pydioswiftsync[2810]: Failed to read /Users/xiaoguang/Library/Application Support/Pydio/ports_config
/var/log/system.log:18168:Sep 6 18:09:16 192 pydioswiftsync[2810]: Failed to parse JSON to loadFolders... Make sure your PydioSync supports /stat
/var/log/system.log:18169:Sep 6 18:09:17 192 pydioswiftsync[2810]: No jobs found, reloading credentials...
Change to '/', fails:
~$ cd /
/$ /Applications/PydioSync.app/Contents/Resources/pydio-agent
DEBUG:root:sys.path: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEIlGkc0U
/Applications/PydioSync.app/Contents/Resources
DEBUG:root:PYTHONPATH: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEIlGkc0U
DEBUG:root:sys.getdefaultencoding(): ascii
DEBUG:root:sys.getfilesystemencoding(): utf-8
DEBUG:root:os.environ:
ANDROID_HOME: /Applications/AndroidDeveloperTools/sdk
ANDROID_NDK_HOME: /Applications/AndroidDeveloperTools/ndk
ANDROID_SDK_ROOT: /Applications/AndroidDeveloperTools/sdk
ANT_ROOT: /usr/local/bin
Apple_PubSub_Socket_Render: /private/tmp/com.apple.launchd.l4RZ9IN0EY/Render
COCOS_CONSOLE_ROOT: /Users/xiaoguang/work/dev/cocos2d-js-v3.3/tools/cocos2d-console/bin
COLORFGBG: 7;0
EDITOR: vim
GOHOME: /usr/local/go
GOPATH: /Users/xiaoguang/go
HOME: /Users/xiaoguang
ITERM_PROFILE: Default
ITERM_SESSION_ID: w0t2p1:19D2B04D-D8FD-422C-B09E-2EA95460E11F
LANG: en_US.UTF-8
LC_CTYPE: zh_CN.UTF-8
LESS: -R
LOGNAME: xiaoguang
LSCOLORS: Gxfxcxdxbxegedabagacad
NDK_ROOT: /Applications/AndroidDeveloperTools/ndk
OLDPWD: /Users/xiaoguang
PAGER: less
PATH: /usr/local/bin:/Applications/AndroidDeveloperTools/sdk/tools:/Applications/AndroidDeveloperTools/sdk/platform-tools:/Applications/AndroidDeveloperTools/sdk:/Applications/AndroidDeveloperTools/ndk:/Users/xiaoguang/work/dev/cocos2d-js-v3.3/tools/cocos2d-console/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/opt/X11/bin:/Applications/AndroidDeveloperTools/ndk:/Applications/AndroidDeveloperTools/sdk/tools:/Applications/AndroidDeveloperTools/sdk/platform-tools:/usr/local/go/bin:/Users/xiaoguang/go/bin
PWD: /
PYTHONPATH: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEIlGkc0U
QUICK_V3_ROOT: /Users/xiaoguang/Documents/quick-3.3
REQUESTS_CA_BUNDLE: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEIlGkc0U/res/cacert.pem
SHELL: /bin/zsh
SHLVL: 1
SSH_AUTH_SOCK: /private/tmp/com.apple.launchd.AtfBZs8NdE/Listeners
TERM: xterm-256color
TERM_PROGRAM: iTerm.app
TERM_PROGRAM_VERSION: 3.0.8
TERM_SESSION_ID: w0t2p1:19D2B04D-D8FD-422C-B09E-2EA95460E11F
TMPDIR: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/
USER: xiaoguang
XPC_FLAGS: 0x0
XPC_SERVICE_NAME: 0
ZSH: /Users/xiaoguang/.oh-my-zsh
_: /Applications/PydioSync.app/Contents/Resources/pydio-agent
__CF_USER_TEXT_ENCODING: 0x1F5:0x19:0x34
DEBUG:root:sys.platform: darwin
DEBUG:root:pydio_module: /
18:14:15 INFO 140735104016384 MainThread Product Version Number 1.2.7 and Version Date July 27 2016
Traceback (most recent call last):
File "<string>", line 319, in <module>
File "<string>", line 265, in main
File "/Users/charles/Desktop/TeamCity/buildAgent/work/a00136d723583ad3/build/pydio-agent/out01-PYZ.pyz/pydio.utils.config_ports", line 76, in create_config_file
IOError: [Errno 13] Permission denied: 'data/ports_config'
Change to my home dir, works:
/$ cd ~
~$ /Applications/PydioSync.app/Contents/Resources/pydio-agent
DEBUG:root:sys.path: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEI5wESmY
/Applications/PydioSync.app/Contents/Resources
DEBUG:root:PYTHONPATH: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEI5wESmY
DEBUG:root:sys.getdefaultencoding(): ascii
DEBUG:root:sys.getfilesystemencoding(): utf-8
DEBUG:root:os.environ:
ANDROID_HOME: /Applications/AndroidDeveloperTools/sdk
ANDROID_NDK_HOME: /Applications/AndroidDeveloperTools/ndk
ANDROID_SDK_ROOT: /Applications/AndroidDeveloperTools/sdk
ANT_ROOT: /usr/local/bin
Apple_PubSub_Socket_Render: /private/tmp/com.apple.launchd.l4RZ9IN0EY/Render
COCOS_CONSOLE_ROOT: /Users/xiaoguang/work/dev/cocos2d-js-v3.3/tools/cocos2d-console/bin
COLORFGBG: 7;0
EDITOR: vim
GOHOME: /usr/local/go
GOPATH: /Users/xiaoguang/go
HOME: /Users/xiaoguang
ITERM_PROFILE: Default
ITERM_SESSION_ID: w0t2p1:19D2B04D-D8FD-422C-B09E-2EA95460E11F
LANG: en_US.UTF-8
LC_CTYPE: zh_CN.UTF-8
LESS: -R
LOGNAME: xiaoguang
LSCOLORS: Gxfxcxdxbxegedabagacad
NDK_ROOT: /Applications/AndroidDeveloperTools/ndk
OLDPWD: /
PAGER: less
PATH: /usr/local/bin:/Applications/AndroidDeveloperTools/sdk/tools:/Applications/AndroidDeveloperTools/sdk/platform-tools:/Applications/AndroidDeveloperTools/sdk:/Applications/AndroidDeveloperTools/ndk:/Users/xiaoguang/work/dev/cocos2d-js-v3.3/tools/cocos2d-console/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/opt/X11/bin:/Applications/AndroidDeveloperTools/ndk:/Applications/AndroidDeveloperTools/sdk/tools:/Applications/AndroidDeveloperTools/sdk/platform-tools:/usr/local/go/bin:/Users/xiaoguang/go/bin
PWD: /Users/xiaoguang
PYTHONPATH: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEI5wESmY
QUICK_V3_ROOT: /Users/xiaoguang/Documents/quick-3.3
REQUESTS_CA_BUNDLE: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/_MEI5wESmY/res/cacert.pem
SHELL: /bin/zsh
SHLVL: 1
SSH_AUTH_SOCK: /private/tmp/com.apple.launchd.AtfBZs8NdE/Listeners
TERM: xterm-256color
TERM_PROGRAM: iTerm.app
TERM_PROGRAM_VERSION: 3.0.8
TERM_SESSION_ID: w0t2p1:19D2B04D-D8FD-422C-B09E-2EA95460E11F
TMPDIR: /var/folders/dm/nv292sbn0wd6klyx75_x0dcw0000gn/T/
USER: xiaoguang
XPC_FLAGS: 0x0
XPC_SERVICE_NAME: 0
ZSH: /Users/xiaoguang/.oh-my-zsh
_: /Applications/PydioSync.app/Contents/Resources/pydio-agent
__CF_USER_TEXT_ENCODING: 0x1F5:0x19:0x34
DEBUG:root:sys.platform: darwin
DEBUG:root:pydio_module: /Users/xiaoguang
18:16:14 INFO 140735104016384 MainThread Product Version Number 1.2.7 and Version Date July 27 2016
18:16:14 INFO 140735104016384 MainThread -----------------------------------------------
18:16:14 INFO 140735104016384 MainThread Starting agent locally on http://localhost:5556/
18:16:14 INFO 140735104016384 MainThread ------------------------------------------------
Some more information, I am using zsh, and using homebrew's gnu coreutils (ls, find, etc) to replace osx's system command, so my ls
is /usr/local/opt/coreutils/libexec/gnubin/ls
-> /usr/local/opt/coreutils/bin/gls
, see my PATH env var.
I have a similar set up, except for the gnu coreutils. Is there any chance you launched pydio-agent with sudo at some point?
In the end it works? Or should I change something?
Concerning the fail-like messages in system.log: I hoped nobody would ever find them :) They aren't error log per-se, it's to inform the user than no icons can be displayed because no jobs were found.
After sudo in root ( '/' )
~$ cd /
/$ sudo /Applications/PydioSync.app/Contents/Resources/pydio-agent
...
...
01:21:12 INFO 140735104016384 MainThread -----------------------------------------------
01:21:12 INFO 140735104016384 MainThread Starting agent locally on http://localhost:5556/
01:21:12 INFO 140735104016384 MainThread ------------------------------------------------
/$ pwd
/
/$ ls -lh /data/
total 4.0K
drwxr-xr-x 9 xiaoguang staff 306 Mar 31 2015 db/
-rw-r--r-- 1 root wheel 69 Sep 7 01:21 ports_config
/$
You wrote the data
to my root dir ...... :-(
ps: the /data/db
is my mongodb's dir
I think the bug is caused by you are trying to detect whether there is a data
dir in PWD, if there is one, you will use the data
dir in PWD, otherwise you will use the data
dir in user's Library
.
I have the data
dir in my root('/'), so when the agent is launched from launchd, its PWD is '/' and trying to use the wrong data
dir in my root.
I see... I managed to reproduce that... Indeed /Applications/PydioSync.app/Contents/Resources/pydio-agent
cannot start if there is a /data folder...
I'm not sure why exactly that happens yet. It's annoying to debug because this happens only with the "built" package, pydio_module
path seems to be wrong.
Out-dated
15:03:37 INFO 140735161815040 MainThread Product Version Number 1.2.7 and Version Date July 27 2016 Traceback (most recent call last): File "", line 319, in
File "", line 265, in main
File "/Users/charles/Desktop/TeamCity/buildAgent/work/a00136d723583ad3/build/pydio-agent/out01-PYZ.pyz/pydio.utils.config_ports", line 76, in create_config_file
IOError: [Errno 13] Permission denied: 'data/ports_config'