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

Unable to run newly-created project #5307

Closed
thanhnguyen2187 opened this issue Jul 5, 2024 · 8 comments
Closed

Unable to run newly-created project #5307

thanhnguyen2187 opened this issue Jul 5, 2024 · 8 comments
Labels

Comments

@thanhnguyen2187
Copy link

thanhnguyen2187 commented Jul 5, 2024

Xmake Version

2.9.1

Operating System Version and Architecture

Linux nixos 6.9.4 #1-NixOS SMP PREEMPT_DYNAMIC Wed Jun 12 09:39:59 UTC 2024 x86_64 GNU/Linux

Describe Bug

Running xmake in a newly created project doesn't work

error: ./xmake.lua:7: unexpected symbol near '$'
checking for platform ... linux
checking for architecture ... x86_64
error: ./xmake.lua:7: unexpected symbol near '$'

Expected Behavior

The project is built successfully

Project Configuration

Minimal reproduce steps:

xmake create -P hello
# create hello ...
# error: cannot open file: xmake.lua, Not access because it is busy
cd hello
xmake
# error: ./xmake.lua:7: unexpected symbol near '$'
# checking for platform ... linux
# checking for architecture ... x86_64
# error: ./xmake.lua:7: unexpected symbol near '$'

Additional Information and Error Logs

Output of xmake -vD:

error: ./xmake.lua:7: unexpected symbol near '$'
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /home/thanh/.nix-profile/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
error: @programdir/core/main.lua:329: @programdir/core/sandbox/modules/import/core/base/task.lua:65: @programdir/core/project/project.lua:956: ./xmake.lua:7: unexpected symbol near '$'
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]:
    [@programdir/core/project/project.lua:956]: in function 'options'
    [...dir/core/sandbox/modules/import/core/project/project.lua:79]: in function 'check_options'
    [@programdir/actions/config/main.lua:367]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:275]:
    [@programdir/core/base/task.lua:491]: in function 'run'
    [@programdir/core/sandbox/modules/import/core/base/task.lua:63]: in function 'run'
    [@programdir/actions/build/main.lua:191]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:275]:
    [@programdir/core/base/task.lua:491]: in function 'run'
    [@programdir/core/main.lua:327]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:973: in function 'os.raiselevel'
        (...tail calls...)
        @programdir/core/main.lua:329: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>

Content of xmake.lua:

add_rules("mode.debug", "mode.release")

target("${TARGETNAME}")
    set_kind("binary")
    add_files("src/*.cpp")

${FAQ}
@thanhnguyen2187
Copy link
Author

Removing ${FAQ} helps, but I really wonder if it is the case 😅

@waruqi
Copy link
Member

waruqi commented Jul 5, 2024

try

xmake create test
cd test
tree
cat xmake.lua
xmake -vD

@thanhnguyen2187
Copy link
Author

Here you go

xmake create test
# create test ...
# error: cannot open file: xmake.lua, Not access because it is busy
cd test
tree
# .
# ├── src
# │   └── main.cpp
# └── xmake.lua
cat xmake.lua
# add_rules("mode.debug", "mode.release")
# 
# target("${TARGETNAME}")
#     set_kind("binary")
#     add_files("src/*.cpp")
# 
# ${FAQ}
xmake -vD
# error: ./xmake.lua:7: unexpected symbol near '$'
# checking for platform ... linux
# checking for architecture ... x86_64
# checking for gcc ... /nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/gcc
# checkinfo: cannot runv(zig version), No such file or directory
# checking for zig ... no
# checkinfo: cannot runv(zig version), No such file or directory
# checking for zig ... no
# checkinfo: cannot runv(nim --version), No such file or directory
# checking for nim ... no
# checkinfo: cannot runv(nim --version), No such file or directory
# checking for nim ... no
# error: @programdir/core/main.lua:329: @programdir/core/sandbox/modules/import/core/base/task.lua:65: @programdir/core/project/project.lua:956: ./xmake.lua:7: unexpected symbol near '$'
# stack traceback:
#     [C]: in function 'error'
#     [@programdir/core/base/os.lua:973]:
#     [@programdir/core/project/project.lua:956]: in function 'options'
#     [...dir/core/sandbox/modules/import/core/project/project.lua:79]: in function 'check_options'
#     [@programdir/actions/config/main.lua:367]:
#     [C]: in function 'xpcall'
#     [@programdir/core/base/utils.lua:275]:
#     [@programdir/core/base/task.lua:491]: in function 'run'
#     [@programdir/core/sandbox/modules/import/core/base/task.lua:63]: in function 'run'
#     [@programdir/actions/build/main.lua:191]:
#     [C]: in function 'xpcall'
#     [@programdir/core/base/utils.lua:275]:
#     [@programdir/core/base/task.lua:491]: in function 'run'
#     [@programdir/core/main.lua:327]: in function 'cotask'
#     [@programdir/core/base/scheduler.lua:406]:
# 
# stack traceback:
#         [C]: in function 'error'
#         @programdir/core/base/os.lua:973: in function 'base/os.raiselevel'
#         (...tail calls...)
#         @programdir/core/main.lua:329: in upvalue 'cotask'
#         @programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>

@waruqi
Copy link
Member

waruqi commented Jul 5, 2024

error: cannot open file: xmake.lua, Not access because it is busy

I don't know why. Maybe a file read/write permission issue

xmake cannot write xmake.lua and do replace vars

@thanhnguyen2187
Copy link
Author

thanhnguyen2187 commented Jul 5, 2024

I see. It seems plausible. Do you mean ${FAQ} of xmake.lua should be replaced when we run xmake create ...

@waruqi
Copy link
Member

waruqi commented Jul 5, 2024

I see. It seems plausible. Do you mean ${FAQ} of xmake.lua should be replaced when we run xmake create ...

it will create a template xmake.lua file with ${FAQ} string, then it will be replaced in xmake.lua file. but xmake write file failed.

io.gsub(configfile, "(" .. pattern .. ")", function(_, variable)

@thanhnguyen2187
Copy link
Author

Thanks. I was wondering if this is related to nix and the way xmake is packaged. I made it work by removing ${FAQ} from xmake.lua. Let's close this for now.

@star-hengxing
Copy link
Contributor

xmake v2.9.5 should work NixOS/nixpkgs#314313

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

No branches or pull requests

3 participants