Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luafilesystem (lfs) cannot be uninstalled under Windows (msys2/mingw) #1428

Closed
osch opened this issue Jul 21, 2022 · 0 comments · Fixed by #1616
Closed

luafilesystem (lfs) cannot be uninstalled under Windows (msys2/mingw) #1428

osch opened this issue Jul 21, 2022 · 0 comments · Fixed by #1616

Comments

@osch
Copy link

osch commented Jul 21, 2022

  • Platform:

    • Windows (msys2/mingw)
  • LuaRocks version:

    • 3.9.0
  • Configuration file:

    rocks_trees = {
       { name = "user", root = home .. "/.luarocks" };
       { name = "system", root = "C:/msys64/mingw64" };
    }
    lua_interpreter = "lua.exe";
    variables = {
       LUA_DIR = "C:/msys64/mingw64";
       LUA_BINDIR = "C:/msys64/mingw64/bin";
    }
  • Description:

    Luarocks cannot remove lfs.dll because it is used by luarocks itself and Windows does not allow to remove
    the file while it is open.

    This issue also raises the questions if it's a good idea that Luarocks uses lfs if luafilesystem is installed. This has also the implication of increased complexity because there are two implementations within Luarocks for handling files: one builtin and another one using lfs. This also could hide errors if the fallback implementation is not tested because lfs is arround, see for example Luarocks: use cmd mkdir msys2/MINGW-packages#12002

    Steps to reproduce:

    1. assure that lfs is not installed:
      $  luarocks show luafilesystem
      Error: cannot find package luafilesystem
      Use 'list' to find installed rocks.
      $  lua -e 'print(require"lfs")'
      C:\msys64\mingw64\bin\lua.exe: (command line):1: module 'lfs' not found:
      
    2. install lfs:
      $  luarocks install luafilesystem
      ...
      
    3. check that lfs is installed:
      $  luarocks show luafilesystem
      LuaFileSystem 1.8.0-1 - File System Library for the Lua Programming Language
      ...
      $  lua -e 'print(require"lfs")'
      table: 000001ade2579ef0 C:\msys64\mingw64\bin\..\lib\lua\5.4\lfs.dll
      
    4. remove lfs:
      $  luarocks remove luafilesystem
      Checking stability of dependencies in the absence of
      luafilesystem 1.8.0-1...
      
      Removing luafilesystem 1.8.0-1...
      Removal successful.
      
    5. now luarocks assumes that lfs is uninstalled, however it is still there:
      $  luarocks show luafilesystem
      Error: cannot find package luafilesystem
      Use 'list' to find installed rocks.
      $  lua -e 'print(require"lfs")'
      table: 0000025ce0519eb0 C:\msys64\mingw64\bin\..\lib\lua\5.4\lfs.dll
      
    6. re-installing lfs:
      $  luarocks install luafilesystem
      Installing https://luarocks.org/luafilesystem-1.8.0-1.src.rock
      luafilesystem 1.8.0-1 depends on lua >= 5.1 (5.4-1 provided by VM)
      gcc -O2 -fPIC -c -o src/lfs.o -IC:/msys64/mingw64/include src/lfs.c
      gcc  -shared -o lfs.dll src/lfs.o C:/msys64/mingw64/bin/lua54.dll -lm
      luafilesystem 1.8.0-1 is now installed in C:/msys64/mingw64 (license: MIT/X11)
      Warning: C:/msys64/mingw64/lib/lua/5.4/lfs.dll is not tracked by this installation of LuaRocks. Moving it to C:/msys64/mingw64/lib/lua/5.4/lfs.dll~
      
@osch osch added the bug label Jul 21, 2022
@hishamhm hishamhm added this to the LuaRocks 4 milestone Feb 18, 2024
@hishamhm hishamhm removed this from the LuaRocks 4 milestone Feb 26, 2024
hishamhm added a commit that referenced this issue Feb 26, 2024
Prevent LuaRocks itself from using installed modules and blocking their files from removal.

This is not an issue on luarocks.exe because its own copy of lfs is statically linked.
We need to eventually switch to using that always, but for now this is a workable
solution.

Fixes #1428.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants