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

os.copyfile() fails on premake-5.0.0-alpha12 on Windows #918

Closed
pjohalloran opened this issue Oct 11, 2017 · 11 comments
Closed

os.copyfile() fails on premake-5.0.0-alpha12 on Windows #918

pjohalloran opened this issue Oct 11, 2017 · 11 comments

Comments

@pjohalloran
Copy link
Contributor

Hi,

I wrote a premake5 script for the OSX platform first which works as expected.

When i run the same script on Windows 10 on premake5 version 5.0.0-alpha12, i get an error when using os.copyfile().

The error is: unable to copy file to $path.

I checked and the target directory exists and is a directory. The file I am trying to copy also exists. I checked by manually inspecting my filesystem and also using os.isdir() and os.isfile() in my build script before i attempt the copy operation.

Any ideas?

@starkos
Copy link
Member

starkos commented Oct 12, 2017

That error message is written in os_copyfile.c

lua_pushfstring(L, "unable to copy file to '%s'", dst);

Based on your error message, it looks like you are passing in the literal string "$path" to the call. Windows isn't going to have any idea what to do with that. If you are trying to expand an environment variable, you will need to use "%path%".

I am going to make this as closed, since that is definitely what is tripping Windows up. But feel free to reopen with more information if you need help getting things working!

@starkos starkos closed this as completed Oct 12, 2017
@pjohalloran
Copy link
Contributor Author

pjohalloran commented Oct 12, 2017

Sorry my bad for confusing bug report. $path of course made it look like i was using environment variables. I was using absolute paths on both OSX where it works and on windows.

eg Target Directory = "C:\tmp\include"
File To Copy = "C:\tmp\src\project\MyHeader.h"

EDIT: Fixed typo in path.

@starkos
Copy link
Member

starkos commented Oct 12, 2017

Reopening…I'm not on a Windows box right now to test. The code for copyfile() is here if you want to try to figure out where it is falling down? Otherwise, we'll try to reproduce the issue. The paths in your previous comment are the ones we should using as a reproduction case?

@starkos starkos reopened this Oct 12, 2017
@pjohalloran
Copy link
Contributor Author

Cool thanks, ill have a look at that this evening. Code certainly looks like it should be ok... The paths above are not exactly the ones i used but are close.

@pjohalloran
Copy link
Contributor Author

I modifed the premake source to give extra information on why the copy failed on windows. Im getting error code back from CopyFileW (ERROR_ACCESS_DENIED).

This can happen if the file is marked as read only, except in my case, it is not. Not sure what to do to fix the error.

I can put in a pull request to add extra error information for when things fail for os.copyfile() at least?

@starkos
Copy link
Member

starkos commented Oct 14, 2017

I can put in a pull request to add extra error information for when things fail for os.copyfile() at least?

I think that would certainly be worthwhile!

@pjohalloran
Copy link
Contributor Author

How does this look?
#932

@pjohalloran
Copy link
Contributor Author

pjohalloran commented Oct 18, 2017

By the way, my error message, original problem is this:

Failed to copy C:/Users/pjoha/work/ember/src/thirdparty/filesystem/filesystem/fwd.h to target "C:/Users/pjoha/work/ember/include/filesystem"
Reason: unable to copy file to 'C:/Users/pjoha/work/ember/include/filesystem', reason: 'Access is denied.
'

It seems like some wierd Windows thing. :( I cant change the permissions on the folder to NOT be read only even though i am an admin and i have ownership permissions on the folder.

@samsinsane
Copy link
Member

According to this the second parameter to CopyFileW should be a file name. This stackoverflow post covers the issue, it's a bit annoying that it uses "access denied" instead of something sane like "destination is a folder".

@starkos
Copy link
Member

starkos commented Oct 19, 2017

This does look like the likely culprit. Regardless, I think we've identified that the issue is not with Premake per se so I am going to go ahead and mark this issue as closed for now. Feel free to reopen it if you have more questions though!

@starkos starkos closed this as completed Oct 19, 2017
@pjohalloran
Copy link
Contributor Author

Cool thanks.

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

No branches or pull requests

3 participants