tomasguisasola / luasoap

LuaSOAP provides a very simple API that convert Lua tables to and from XML documents
57 stars 18 forks source link

soap.lua installed to wrong place wrt. require name #7

Closed fabled closed 4 years ago

fabled commented 11 years ago

After "make install", I have program doing require'soap.client' and with fails with the following error:

lua: /usr/share/lua/5.1/soap/client.lua:13: module 'soap' not found:
    no field package.preload['soap']
    no file './soap.lua'
    no file '/usr/local/share/lua/5.1/soap.lua'
    no file '/usr/local/share/lua/5.1/soap/init.lua'
    no file '/usr/local/lib/lua/5.1/soap.lua'
    no file '/usr/local/lib/lua/5.1/soap/init.lua'
    no file '/usr/share/lua/5.1/soap.lua'
    no file '/usr/share/lua/5.1/soap/init.lua'
    no file './soap.so'
    no file '/usr/local/lib/lua/5.1/soap.so'
    no file '/usr/lib/lua/5.1/soap.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'require'
    /usr/share/lua/5.1/soap/client.lua:13: in main chunk
    [C]: in function 'require'
    mycode.lua:1: in main chunk
    [C]: ?

This is because client.lua does require'soap' but the soap.lua is installed to soap/soap.lua instead.

Should change all require'soap' to require'soap.soap' or change makefile to install soap.lua to proper path.

tomasguisasola commented 11 years ago
Hi Timo

On Tue, 27 Aug 2013, Timo Teräs wrote:

After "make install", I have program doing require'soap.client' and with fails with the following error:

lua: /usr/share/lua/5.1/soap/client.lua:13: module 'soap' not found:
  no field package.preload['soap']
  no file './soap.lua'
  no file '/usr/local/share/lua/5.1/soap.lua'
  no file '/usr/local/share/lua/5.1/soap/init.lua'
  no file '/usr/local/lib/lua/5.1/soap.lua'
  no file '/usr/local/lib/lua/5.1/soap/init.lua'
  no file '/usr/share/lua/5.1/soap.lua'
  no file '/usr/share/lua/5.1/soap/init.lua'
  no file './soap.so'
  no file '/usr/local/lib/lua/5.1/soap.so'
  no file '/usr/lib/lua/5.1/soap.so'
  no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
  [C]: in function 'require'
  /usr/share/lua/5.1/soap/client.lua:13: in main chunk
  [C]: in function 'require'
  mycode.lua:1: in main chunk
  [C]: ?

This is because client.lua does require'soap' but the soap.lua is installed to soap/soap.lua instead.

Should change all require'soap' to require'soap.soap' or change makefile to install soap.lua to proper path. Neither. This problem is solved with an appropriate LUA_PATH or package.path. You should add something like '?/?.lua' to your package.path. According to the above error message, it seems your package.path is "?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua". I am not sure the exact directory where you installed soap.lua but the following should work:

package.path = package.path..";/usr/local/share/lua/5.1/?/?.lua"

An alternative is move soap.lua up one directory, so it should

match the line "no file '/usr/local/share/lua/5.1/soap.lua'".

Regards,
    Tomás
fabled commented 11 years ago

This is because client.lua does require'soap' but the soap.lua is installed to soap/soap.lua instead. Should change all require'soap' to require'soap.soap' or change makefile to install soap.lua to proper path. Neither. This problem is solved with an appropriate LUA_PATH or package.path. You should add something like '?/?.lua' to your package.path. According to the above error message, it seems your package.path is "?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua". I am not sure the exact directory where you installed soap.lua but the following should work: package.path = package.path..";/usr/local/share/lua/5.1/?/?.lua" An alternative is move soap.lua up one directory, so it should match the line "no file '/usr/local/share/lua/5.1/soap.lua'".

Yes, this would work. But is highly inconvenient for anyone using the package, or trying pre-package it for a distribution. Sane distributions do not have ?/?.lua in their default lua search path (Debian, Alpine Linux). This means you are adding package-specific global lua default requirements. It also makes it inconvenient to use the library as stand-alone in non-standard install, as you need to add two lua search paths instead of one.

Yes, I can move as packager the "soap.lua" to proper path. But that it would be preferable that "make install" is fixed, or the 'require':s so that things work without additional fiddling.

tomasguisasola commented 11 years ago
Hi Timo

Yes, this would work. But is highly inconvenient for anyone using the package, or trying pre-package it for a distribution. Sane distributions do not have ?/?.lua in their default lua search path (Debian, Alpine Linux). This means you are adding package-specific global lua default requirements. It also makes it inconvenient to use the library as stand-alone in non-standard install, as you need to add two lua search paths instead of one. This pattern (?/?.lua) was the standard some time ago...

Yes, I can move as packager the "soap.lua" to proper path. But that it would be preferable that "make install" is fixed, or the 'require':s so that things work without additional fiddling. You are right. I'll change that.

Thanks,
    Tomás
hishamhm commented 7 years ago

This one can be closed, as the rockspec does not have this issue.