This forum has been archived. All content is frozen. Please use KDE Discuss instead.

kioclient(2812): couldn't create slave: "Unable to create io

Tags: None
(comma "," separated)
fluca1978
Registered Member
Posts
81
Karma
0
OS
Hi all,
I'm trying to experiment with kio slaves and so I created a clone of the official hello example http://techbase.kde.org/Development/Tutorials/KIO_Slaves/Hello_World with the only differences that (1) all my files are called test (including the slave class) and that (2) the protocol I use is called myprotocol as reported by the test.protocol file below:

Code: Select all
[Protocol]
DocPath=kioslave/kio_test.html
exec=kio_test
input=none
output=filesystem
protocol=myprotocol
reading=true


I can compile and install the project:

Code: Select all
$ sudo make install
[  0%] Built target kio_test_automoc
[100%] Built target kio_test
Install the project...
-- Install configuration: "Debug"                                                         
-- Installing: /usr/local/lib/kde4/kio_test.so
-- Set runtime path of "/usr/local/lib/kde4/kio_test.so" to "/usr/local/lib"
-- Up-to-date: /usr/local/share/kde4/services/test.protocol



but when I try to run the example I got the following error:

Code: Select all
$ kioclient 'cat' 'myprotocol:///'
kioclient(2812): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol 'myprotocol'.
"


What am I missing here? I've tried different protocols and naming schema to see if I can figure out what is wrong with this simple example, but the error is always the same. Is there a way to list the installed/known protocols? Because the kinfocenter does not present me a protocols tab.

I attach the source code of all the files in the case they can help:

Code: Select all
// test.h
#ifndef TEST_H
#define TEST_H

#include <kio/slavebase.h>

/**
 T his* class implements a hello-world kioslave
 */
class test : public KIO::SlaveBase
{
public:
  test( const QByteArray &pool, const QByteArray &app );
  void get( const KUrl &url );
};

#endif


Code: Select all
// test.cpp
#include "test.h"


#include <kdebug.h>
#include <kcomponentdata.h>


extern "C" int KDE_EXPORT kdemain( int argc, char **argv )
{                                   
  kDebug(7000) << "Entering function";
  KComponentData instance( "kio_test" );
 
  if (argc != 4)
  {
    fprintf( stderr, "Usage: kio_test protocol domain-socket1 domain-socket2\n");
    exit( -1 );
  }
  test slave( argv[2], argv[3] );
  slave.dispatchLoop();
  return 0;
}

void test::get( const KUrl &url )
{
  kDebug(7000) << "Entering function with url " << url;
  mimeType( "text/plain" );
  QByteArray str( "Hello KDESLAVE world" );
  data( str );
  finished();
  kDebug(7000) << "Leaving function get()";
}

test::test( const QByteArray &pool, const QByteArray &app )
: SlaveBase( "test", pool, app ) {}



Code: Select all
// CMakeList.txt
PROJECT( test )
FIND_PACKAGE(KDE4 REQUIRED)
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} . )

set(kio_test_PART_SRCS test.cpp)

kde4_add_plugin(kio_test ${kio_test_PART_SRCS})

target_link_libraries(kio_test ${KDE4_KIO_LIBS})

install(TARGETS kio_test  DESTINATION ${PLUGIN_INSTALL_DIR})


########### install files ###############

install(FILES test.protocol DESTINATION ${SERVICES_INSTALL_DIR})



Thanks anyone.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Did you run "kbuildsycoca4" after installing it? Also, did you install it into a directory covered by "kde4-config --path lib"? (less the /lib parts)


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
fluca1978
Registered Member
Posts
81
Karma
0
OS
bcooksley wrote:Did you run "kbuildsycoca4" after installing it? Also, did you install it into a directory covered by "kde4-config --path lib"? (less the /lib parts)


The kde4-config reports the following output:

Code: Select all
$ kde4-config --path lib
/home/luca/.kde/lib/:/usr/lib/


so I changed the CMakeLists.txt to the following in order to get the installation in the right directory ( I don't understand why it was getting /usr/local/lib instead of /usr/lib as reported by kde4-config):

Code: Select all
PROJECT( test )
FIND_PACKAGE(KDE4 REQUIRED)
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} . )

set(kio_test_PART_SRCS test.cpp)

kde4_add_plugin(kio_test ${kio_test_PART_SRCS})

target_link_libraries(kio_test ${KDE4_KIO_LIBS})

install(TARGETS kio_test  DESTINATION /home/luca/.kde/lib/ )


########### install files ###############

install(FILES test.protocol DESTINATION /home/luca/.kde/lib/)


and the project gets installed into
Code: Select all
/home/luca/.kde/lib
:

Code: Select all
$ sudo make install
[  0%] Built target kio_test_automoc
[100%] Built target kio_test
Install the project...
-- Install configuration: "Debug"                                                         
-- Up-to-date: /home/luca/.kde/lib/kio_test.so
-- Installing: /home/luca/.kde/lib/test.protocol



After that I ran kbuilsycoca4 (which reports it is running) and then invoked the slave with the same error:

Code: Select all
$ kioclient 'cat' 'myprotocol:///'
kioclient(6460): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol 'myprotocol'.
"



I tried to strace the process to see if it is opening the test.protocol file and I was unable to see such an entry, but this could be right if kbuildsycoca4 loads the known protocols in memory as a separate thread 8right?). The only thing I can find in the strace output is:

Code: Select all
stat("myprotocol:///", 0x2243b28)       = -1 ENOENT (No such file or directory)           
lstat("myprotocol:///", 0x7fff07e4c020) = -1 ENOENT (No such file or directory)


which means that the kioslave really does not know how to interpret the protocol (I think I discovered hot water here ;D ).
Is there a way to see what the kde cache knows about protocols and handlers?
Thanks,
Luca
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You can't simply install into ~/.kde4/lib/ that won't work.
I suggest adding a file into ~/.kde4/env/ with the following contents:
Code: Select all
export KDEDIRS=/usr:$HOME/kde-install


Ensure that file is executable with .sh as it's ending then logout and back in again.

Now reverse the changes you made to CMakeLists.txt, and run cmake as follows:
Code: Select all
cmake . -DCMAKE_INSTALL_PREFIX=$HOME/kde-install/


Then make && make install as usual, run kbuildsycoca4 and you should be able to use your new KIO slave.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
fluca1978
Registered Member
Posts
81
Karma
0
OS
No way, sgrunt! :'(

This is the ~/.kde/env/kde-dev.sh file content:

Code: Select all
#!/bin/bash
export KDEDIRS=/usr:$HOME/kde-install


The file is executable and in fact, after logging out and loggin in again I can see the environment variable set.
Then I changed working directory to the build one and did the following steps (I'm reporting the output of each command):

Code: Select all
luca:~/projects/test/build$ cmake .. -DCMAKE_INSTALL_PREFIX=~/kde-install

-- Found Qt-Version 4.7.0 (using /usr/bin/qmake-qt4)
-- Found X11: /usr/lib/libX11.so
-- Found KDE 4.6 include dir: /usr/include
-- Found KDE 4.6 library dir: /usr/lib
-- Found the KDE4 kconfig_compiler preprocessor: /usr/bin/kconfig_compiler
-- Found automoc4: /usr/bin/automoc4
-- Configuring done
-- Generating done
-- Build files have been written to: /home/luca/projects/test/build

luca:~/projects/test/build$ make

[  0%] Built target kio_test_automoc
[100%] Built target kio_test

luca:~/projects/test/build$ sudo make install

[  0%] Built target kio_test_automoc
[100%] Built target kio_test
Install the project...
-- Install configuration: "Debug"                                                         
-- Up-to-date: /home/luca/kde-install/lib/kde4/kio_test.so
-- Up-to-date: /home/luca/kde-install/lib/kde4/test.protocol

luca:~/projects/test/build$ kbuildsycoca4

kbuildsycoca4 running...

luca:~/projects/test/build$ kioclient 'cat' 'myprotocol:///'

kioclient(2222): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol 'myprotocol'.
"



I'm sure I'm missing a little thing somewhere, it cannot be so difficult after all....
pinotree
KDE Developer
Posts
222
Karma
7
OS
kioslaves are spanwed by kdeinit4/klauncher, which is run at the very beginning of the KDE session (or by the first appplication using kioslaves in non-KE environments) and lasts until the logout.
To make it use a different KDEDIRS (or others) environment variable, you have to do one of
  • logout and relogin
  • run "kdeinit4" in a console

Also,
fluca1978 wrote:This is the ~/.kde/env/kde-dev.sh file content:
Code: Select all
#!/bin/bash
export KDEDIRS=/usr:$HOME/kde-install


please note the order of the prefixes specified in KDEDIRS has the same meaning as in e.g. $PATH, i.e. you must specify first what you want to ue first (so in your local prefix you can install stuff "overriding" the version in the KDE installation).


Pino Toscano
fluca1978
Registered Member
Posts
81
Karma
0
OS
No way! :'( :'( :'(
I've already tried to logout and login again, and I've also switched the KDEDIRS path order to place my private install as first, but kioclient still reports the same error about unknown protocol myprotocol.
Is there any check tool I can run to see what is wrong with my configuration? Anyone can try my files to see if there's an error somewhere?

Thanks
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
When I installed it on my trunk system, it operated ok, so your sources are fine.

Did you ensure that ~/.kde/env/kde-dev.sh is executable?

Also, ensure that "echo $KDEDIRS" returns the correct result in a terminal after logging in and out again.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
fluca1978
Registered Member
Posts
81
Karma
0
OS
Sigh, let get is straight.
After a login I run in a terminal the following:

Code: Select all
luca ~ $ echo $KDEDIRS

/home/luca/kde-install:/usr

luca ~ $ ls -lR /home/luca/kde-install/

/home/luca/kde-install/:
total 4
drwxr-xr-x 3 luca luca 4096 2011-05-03 12:37 lib

/home/luca/kde-install/lib:
total 4
drwxr-xr-x 2 luca luca 4096 2011-05-03 12:37 kde4

/home/luca/kde-install/lib/kde4:
total 248
-rw-r--r-- 1 luca luca 247488 2011-05-03 12:37 kio_test.so
-rw-r--r-- 1 luca luca    119 2011-05-03 08:04 test.protocol

luca ~ $ cat /home/luca/kde-install/lib/kde4/test.protocol

[Protocol]
DocPath=kioslave/kio_test.html
exec=kio_test
input=none
output=filesystem
protocol=myprotocol
reading=true



then I tried again to run kioclient:

Code: Select all
luca ~ $ kioclient 'cat' 'myprotocol:///'

kioclient(2258): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol 'myprotocol'.
"



Ok, time for panic here!

Code: Select all
luca ~ $ kbuildsycoca4

kbuildsycoca4 running...

luca ~ $ kioclient 'cat' 'myprotocol:///'

kioclient(2272): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol 'myprotocol'.
"


luca ~ $ kioclient exec 'myprotocol:///'

kioclient(2289)/kio (KRun): #### NO SUPPORT FOR READING!


luca ~ $ kioclient openProperties 'myprotocol:///'

kioclient(2376): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol 'myprotocol'.
"
"/usr/bin/kioclient(2376)" Soprano: "org.freedesktop.DBus.Error.ServiceUnknown - The name org.kde.nepomuk.services.nepomukstorage was not provided by any .service files"
"/usr/bin/kioclient(2376)" Soprano: "QLocalSocket::connectToServer: Invalid name"
"/usr/bin/kioclient(2376)" Soprano: "org.freedesktop.DBus.Error.ServiceUnknown - The name org.kde.nepomuk.services.nepomukstorage was not provided by any .service files"
"/usr/bin/kioclient(2376)" Soprano: "QLocalSocket::connectToServer: Invalid name"
"/usr/bin/kioclient(2376)" Soprano: "org.freedesktop.DBus.Error.ServiceUnknown - The name org.kde.nepomuk.services.nepomukstorage was not provided by any .service files"
"/usr/bin/kioclient(2376)" Soprano: "QLocalSocket::connectToServer: Invalid name"




I guess there is some problem here with my installation of kde (or kioclient), but how can I check it and discover the problem?

Thanks a lot.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
On your system it seems that the test.protocol file is being installed into the wrong directory. Make sure that your CMakeLists.txt reads the following on the line in question:
Code: Select all
install(FILES test.protocol DESTINATION ${SERVICES_INSTALL_DIR})


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
fluca1978
Registered Member
Posts
81
Karma
0
OS
I changed the CMakeLists.txt according to your suggestion and ran the build phase again after a whole uninstall:

Code: Select all
luca ~/projects/test/build $ sudo make install

[sudo] password for luca:
[  0%] Built target kio_test_automoc
[100%] Built target kio_test
Install the project...
-- Install configuration: "Debug"                                                         
-- Up-to-date: /home/luca/kde-install/lib/kde4/kio_test.so
-- Up-to-date: /home/luca/kde-install/share/kde4/services/test.protocol


and after a kdebuildsycoca4 it runs!

Code: Select all
luca ~/projects/test/build $ kbuildsycoca4

kbuildsycoca4 running...

luca ~/projects/test/build $ kioclient cat 'myprotocol:///'

Hello KDESLAVE world



Thanks a lot everybody. Now I can move on on more complex concepts!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft