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

xmake create -lc -Phello will not replace FAQ and TARGETNAME #5138

Closed
Freed-Wu opened this issue May 24, 2024 · 16 comments
Closed

xmake create -lc -Phello will not replace FAQ and TARGETNAME #5138

Freed-Wu opened this issue May 24, 2024 · 16 comments
Labels

Comments

@Freed-Wu
Copy link
Member

Freed-Wu commented May 24, 2024

Xmake Version

v2.9.1+20240422,

Operating System Version and Architecture

Linux 6.9.1

Describe Bug

$ xmake create -lc -Phello
create Desktop ...
error: cannot open file: xmake.lua, Not access because it is busy
$ cat hello/xmake.lua
add_rules("mode.debug", "mode.release")

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

${FAQ}

Expected Behavior

$ xmake create -lc -Phello
create Desktop ...
$ cat hello/xmake.lua
add_rules("mode.debug", "mode.release")

target("hello")
    set_kind("binary")
    add_files("src/*.c")

Project Configuration

/

Additional Information and Error Logs

And xmake.lua generated by xmake create has permission r--r--r--. Why not use umask?

@Freed-Wu Freed-Wu added the bug label May 24, 2024
@waruqi
Copy link
Member

waruqi commented May 24, 2024

ruki:dddd ruki$ xmake create -lc -Phello
create dddd ...
  [+]: xmake.lua
  [+]: src/main.c
  [+]: .gitignore
create ok!
ruki:dddd ruki$ cat ./hello/xmake.lua
add_rules("mode.debug", "mode.release")

target("dddd")
    set_kind("binary")
    add_files("src/*.c")

it works for me.

@waruqi
Copy link
Member

waruqi commented May 24, 2024

you can try to change to another dir.

@Freed-Wu
Copy link
Member Author

I have tested in other OSs and it can work. I think it is the bug about NixOS.

@Freed-Wu
Copy link
Member Author

Freed-Wu commented Sep 4, 2024

We should have os.chmod(), then run os.chmod('file', '+w') after os.cp().

@waruqi
Copy link
Member

waruqi commented Sep 4, 2024

why?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


why?

@Freed-Wu
Copy link
Member Author

Freed-Wu commented Sep 4, 2024

See NixOS/nixpkgs#314313

@waruqi
Copy link
Member

waruqi commented Sep 4, 2024

os.cp(srcfile, dstfile)

it will add +w to open and create dstfile.
https://github.com/tboox/tbox/blob/553c32406a09e3e0a0a8e8dfed741b4888ba07ca/src/tbox/platform/posix/file.c#L80

and srcfile is only for readonly.

@waruqi
Copy link
Member

waruqi commented Sep 4, 2024

NixOS/nixpkgs#314313 (comment)

all xmake program files are only for readonly. we need not to write them.

@Freed-Wu
Copy link
Member Author

Freed-Wu commented Sep 4, 2024

No. It doesn't happened. If I sudo chmod -w /usr/share/xmake/templates/c/console/project/xmake.lua in other OS, the same error will be throw.

waruqi added a commit that referenced this issue Sep 4, 2024
@waruqi
Copy link
Member

waruqi commented Sep 4, 2024

try this patch. #5570

you need rebuild xmake core binary and reinstall it.

@waruqi
Copy link
Member

waruqi commented Sep 5, 2024

Does it work now?

@Freed-Wu
Copy link
Member Author

Yes, thanks!

@Freed-Wu
Copy link
Member Author

NixOS/nixpkgs#314313 (comment)

unset LD cannot work. Is it a bug?

@Freed-Wu
Copy link
Member Author

Oh, I must rm .xmake -rf.

@Freed-Wu
Copy link
Member Author

Can we allow use ld as $LD? I think it is nature.

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