premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

Premake5 trying to include /usr/bin/bitmap instead of folder with premake5 script

Open dankmolot opened this issue 2 years ago • 6 comments

What seems to be the problem?

Premake5 5.0-beta1 tries to include /usr/bin/bitmap instead of folder with premake5 script. This is because premake5 is located in /usr/bin. Here is result:

$ premake5 gmake --gmcommon="$HOME/garrysmod_common"
Selected version 3 of the project generator
Error: /usr/bin/bitmap:1: unexpected symbol near '<\127>'

What did you expect to happen?

Expected successful building of configuration.

What have you tried so far?

Renamed bitmap binary, so premake5 can't find it:

$ sudo mv /usr/bin/bitmap /usr/bin/bitmap.old
$ premake5 gmake --gmcommon="$HOME/garrysmod_common"
Selected version 3 of the project generator
Building configurations...
Running action 'gmake'...
Generated projects/linux/gmake/Makefile...
Generated projects/linux/gmake/gmsv_network.make...
Done (684ms).

Tried use locally located premake5

$ ./premake5 gmake --gmcommon="$HOME/garrysmod_common"
Selected version 3 of the project generator
Building configurations...
Running action 'gmake'...
Generated projects/linux/gmake/Makefile...
Generated projects/linux/gmake/gmsv_network.make...
Done (650ms).

How can we reproduce this?

Place premake5 at /usr/bin

$ cp ./premake5 /usr/bin/

Creating project with bitmap folder

-- premake5.lua
print('Including bitmap')
include('bitmap')

-- bitmap/premake5.lua
print('Hello from bitmap!')

Place premake5 to /usr/bin and build configuration

$ premake5 gmake
Including bitmap
Error: /usr/bin/bitmap:1: unexpected symbol near '<\127>'

What version of Premake are you using?

Premake 5.0-beta1 from releases

Anything else we should know?

Premake5 was running on debian 10

dankmolot avatar Dec 26 '21 16:12 dankmolot

Interesting fact. The problem is not with the premake5 version, but with the location of the binary. If premake5 is in /usr/bin, it will search /usr/bin first.

Upd: updated issue text (past was invalid)

dankmolot avatar Dec 26 '21 17:12 dankmolot

So it sounds like what you're expecting the behavior to be is for it to search the directory that premake was invoked from first for includes, rather than the directory that the premake executable is located in?

nickclark2016 avatar Feb 06 '22 23:02 nickclark2016

Exactly! Sorry for confusing description of problem. If something is missing, tell me.

Thanks for the answer!

dankmolot avatar Feb 07 '22 08:02 dankmolot

No worries, just trying to make sure I've got a full understanding of the problem. So if I'm correct, the folder structure is like:

/usr
    bin
        premake5
        bitmap

/proj
    premake5.lua
    bitmap
         premake5.lua

As a work around, could you try forcing it to include('bitmap/premake5.lua') and seeing if that is a temporary workaround. Per the locating scripts documentation, this is definitely incorrect behavior and should be addressed.

nickclark2016 avatar Feb 07 '22 12:02 nickclark2016

Made the project as you mentioned above. Here's what I got:

When I used include('bitmap')

$ premake5
Error: /usr/bin/bitmap:1: unexpected symbol near '<\127>'

When I used include('bitmap/premake5.lua')

$ premake5
Hello from Bitmap!
Type 'premake5 --help' for help

dankmolot avatar Feb 09 '22 11:02 dankmolot

Awesome. So at least we know that including explicit paths still works, just looks like our implicit path ordering is different than our documentation/spec says.

nickclark2016 avatar Feb 09 '22 13:02 nickclark2016