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

Nake Build Error #111

Open
raelite opened this issue Oct 18, 2021 · 14 comments
Open

Nake Build Error #111

raelite opened this issue Oct 18, 2021 · 14 comments

Comments

@raelite
Copy link

raelite commented Oct 18, 2021

Sadly the Stub looks inactive..

When I make Nake Build in Stub or Godot Nim it returns:

Godot Engine v3.3.4.stable.official.faf3f883d - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce GTX 960/PCIe/SSE2
OpenGL ES Batching: ON

ERROR: save_file: Condition "!file" is true. Returned: ERR_FILE_CANT_WRITE
   At: modules/gdnative/nativescript/api_generator.cpp:47
ERROR: init: Failed to generate C API

   At: modules/gdnative/nativescript/nativescript.cpp:1058
Failed to generate api.json

and idk what to do :(?
already tried to reinstall it, with depth and without etc like in (#62)..

I even tried it with an older Godot version..

@dsrw
Copy link
Contributor

dsrw commented Oct 18, 2021

This is happening because godot can't write the api.json file, which is required to generate the nim binding. This might be an issue with the current working directory, or something related to file permissions.

Try editing nakefile.nim to print out the full path of the api.json file, and verify that it's writable. Before this line: https://github.com/pragmagic/godot-nim-stub/blob/master/nakefile.nim#L21 add something like echo "api file: ", getCurrentDir()/jsonFile, then verify that the filename looks reasonable and that you can write to it. Ensure your path doesn't have any spaces or non-ascii characters. There could be an issue with the way the path is passed to godot.

If none of this helps, please post more info about your environment (os, location of project, location of godot) and I'll try to help you sort things out.

@raelite
Copy link
Author

raelite commented Oct 19, 2021

Well this was kinda hard and I gave up, since I am a beginner in such stuff~
Yes Path is a problem because it has spaces in it. So I packed everthing to another user and public etc.. nothing of this both things worked~ rn everything is in C:\Users\Public

Windows, Godot is in C:\Users\Public\Godot

@dsrw
Copy link
Contributor

dsrw commented Oct 27, 2021

I don't specifically know that spaces in the path are a problem, it's just the sort of thing that can cause trouble.

Your error is because Godot can't write the json.api file, so to move forward, you're going to need to know the file name that's being passed, so you can figure out why it can't be written. The path could be wrong. The directory could be read-only.

Assuming you're using godot-nim-stub, you should edit nakefile.nim to print out the path.

Change:

  if not fileExists(jsonFile) or
     godotBin.getLastModificationTime() > jsonFile.getLastModificationTime():
    direShell(godotBin, "--gdnative-generate-json-api", getCurrentDir()/jsonFile)

To:

  if not fileExists(jsonFile) or
     godotBin.getLastModificationTime() > jsonFile.getLastModificationTime():
    # print path to api.json:
    echo "api file: ", getCurrentDir()/jsonFile
    direShell(godotBin, "--gdnative-generate-json-api", getCurrentDir()/jsonFile)

Then look at what path it prints out and see if it makes sense. Verify that you can write to the file. I'm not a windows user, but assuming the path it printed out was C:\Users\Public\godot-nim-stub\src\godotapi\api.json you should be able to run something like notepad C:\Users\Public\godot-nim-stub\src\godotapi\api.json to verify that it can be written.

If all of that looks good, you could try launching your command prompt using "Run as administrator". There could be something up with file permissions.

@Asarmir
Copy link

Asarmir commented Oct 30, 2021

I also had a issue with nake build. I enter your code:
if not fileExists(jsonFile) or
godotBin.getLastModificationTime() > jsonFile.getLastModificationTime():
# print path to api.json:
echo "api file: ", getCurrentDir()/jsonFile
direShell(godotBin, "--gdnative-generate-json-api", getCurrentDir()/jsonFile)

and I got the result:

C:\Users\randa\Documents\Code\godot-nim-stub>nake build
Compiling nakefile...
Hint: used config file 'C:\Users\randa.choosenim\toolchains\nim-1.6.0\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\randa.choosenim\toolchains\nim-1.6.0\config\config.nims' [Conf]
Hint: used config file 'C:\Users\randa\Documents\Code\godot-nim-stub\nakefile.nim.cfg' [Conf]
..........................................................................................................
C:\Users\randa\Documents\Code\godot-nim-stub\nakefile.nim(4, 12) Warning: import os.nim instead; ospaths is deprecated [Deprecated]
....................................
C:\Users\randa\Documents\Code\godot-nim-stub\nakefile.nim(57, 36) Error: undeclared identifier: 'jsonFile'
candidates (edit distance, scope distance); see '--spellSuggest':
(4, 3): 'nakefile' [module declared in C:\Users\randa\Documents\Code\godot-nim-stub\nakefile.nim(1, 2)]
(4, 4): 'copyFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(1814, 6)]
(4, 4): 'copyFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(1814, 6)]
(4, 4): 'endOfFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system\io.nim(543, 6)]
(4, 4): 'isNil' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system.nim(1595, 8)]
(4, 4): 'isNil' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system.nim(1602, 8)]
(4, 4): 'isNil' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system.nim(1606, 6)]
(4, 4): 'isNil' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system.nim(1608, 6)]
(4, 4): 'isNil' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system.nim(1609, 6)]
(4, 4): 'isNil' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system.nim(1610, 6)]
(4, 4): 'isNil' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system.nim(1611, 6)]
(4, 4): 'moveFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(2015, 6)]
(4, 4): 'moveFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(2015, 6)]
(4, 4): 'pcFile' [enumField declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(2243, 5)]
(4, 4): 'pcFile' [enumField declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(2243, 5)]
(4, 4): 'readFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system\io.nim(840, 6)]
(4, 4): 'sameFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(1555, 6)]
(4, 4): 'sameFile' [proc declared in C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\pure\os.nim(1555, 6)]

This is with windows 10, C:\Users\randa\Documents\Code\godot-nim-stub,
godot 3.2.exe located on desktop and nim 1.6

@dsrw
Copy link
Contributor

dsrw commented Oct 30, 2021

It looks like you added the code block to the end of the file, which isn’t going to work. You should be adding echo "api file: ", getCurrentDir()/jsonFile before the call to direShell. This isn’t going to fix anything, it’s just printing the path to api file it’s trying to generate so we can try to figure out why it can’t be written.

You could be having an entirely different issue though. Is your build also failing when Godot is trying to write api.json?

@Asarmir
Copy link

Asarmir commented Oct 30, 2021 via email

@Asarmir
Copy link

Asarmir commented Oct 31, 2021

C:\Users\randa\Documents\Code\godot-nim-stub>nake build
jsonFIle: ----> C:\Users\randa\Documents\Code\godot-nim-stub\src\godotapi\api.json
Verifying dependencies for [email protected]
Info: Dependency on godot@>= 0.7.21 & < 0.8.0 already satisfied
Verifying dependencies for [email protected]
Info: Dependency on compiler@>= 0.17.3 already satisfied
Verifying dependencies for [email protected]
Compiling ..\src\stub (from package stub) using c backend
stack trace: (most recent call last)
C:\Users\randa\Documents\Code\godot-nim-stub\src\config.nims(40, 11)
C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system\assertions.nim(38, 26) failedAssertImpl
C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system\assertions.nim(28, 11) raiseAssert
C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system\fatal.nim(53, 5) sysFatal
C:\Users\randa.choosenim\toolchains\nim-1.6.0\lib\system\fatal.nim(53, 5) Error: unhandled exception: C:\Users\randa\Documents\Code\godot-nim-stub\src\config.nims(40, 9) sizeof(int) == 8 [AssertionDefect]
Tip: 5 messages have been suppressed, use --verbose to show them.
Error: Execution failed with exit code 1
... Command: C:\Users\randa.nimble\bin\nim.exe c --noNimblePath -d:NimblePkgVersion=0.1.0 --path:C:\Users\randa.nimble\pkgs\godot-0.7.28 --path:C:\Users\randa.nimble\pkgs\compiler-1.6.0 --hints:off -o:.._dlls\nim_32.dll ..\src\stub

This is what I get. After I reCloned and added the new code.

const targetDir = "src"/"godotapi"
createDir(targetDir)
const jsonFile = targetDir/"api.json"
echo "jsonFIle: ----> ",getCurrentDir()/jsonFile
if not fileExists(jsonFile) or
godotBin.getLastModificationTime() > jsonFile.getLastModificationTime():
# print path to api.json:
echo "api file: ", getCurrentDir()/jsonFile
direShell(godotBin, "--gdnative-generate-json-api", getCurrentDir()/jsonFile)
if not fileExists(jsonFile):
echo "Failed to generate api.json"
quit(-1)

genApi(targetDir, jsonFile)

After rereading everything it seems like it's messing up writing the .dll in the _dll folder.

@raelite
Copy link
Author

raelite commented Nov 4, 2021

so, im sorry the last days where thought..
well the cmd still says some errors occured and closed the cmd somehow~?

Ill set up an new user Account and try it there :/

nvm seems like I did something wrong..
ERROR: save_file: Condition "!file" is true. Returned: ERR_FILE_CANT_WRITE
At: modules/gdnative/nativescript/api_generator.cpp:47
ERROR: init: Failed to generate C API

At: modules/gdnative/nativescript/nativescript.cpp:1083
Failed to generate api.json

thats the output seems it really cant somehow acces..

and with admin right:
api file: C:\Users\Rage Quit\Documents\nim\godot-nim-stub\src\godotapi\api.json
Godot Engine v3.2.2.stable.official - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce GTX 960/PCIe/SSE2

Failed to generate api.json

yes I can run notepad C:\Users\Rage Quit\Documents\nim\godot-nim-stub\src\godotapi\api.json even without admin right~

@raelite
Copy link
Author

raelite commented Nov 4, 2021

so i tried it again with my double username account to acces a acc with a normal username, didnt worked, tried it on the account itself kinda worked..

C:\Users\digital\Documents\nim\godot-nim-stub>nake build
Error: Could not read package info file in C:\Users\digital\Documents\nim\godot-nim-stub\src\stub.nimble;
... Reading as ini file failed with:
... Invalid section: .
... Evaluating as NimScript file failed with:
... Error: cannot open 'C:\Users\Rage Quit.choosenim\toolchains\nim-1.4.8\lib\system.nim'
... printPkgInfo() failed.

and it seems like at the end it always still accessed

Error: cannot open 'C:\Users\Rage Quit\.choosenim\toolchains\nim-1.4.8\lib\system.nim'
now I need to look again how I change it again~ seems like I forgot how it works

@dsrw
Copy link
Contributor

dsrw commented Nov 5, 2021

@Asarmir it looks like you're using a 32 bit Nim install, but https://github.com/pragmagic/godot-nim-stub/blob/master/src/config.nims#L40 is ensuring that a 64 bit nim is being used. It's possible that if you delete that assertion things will work, but you're probably better off switching to 64 bit if you can.

Also, if you're using Nim 1.6.0, you'll need to change https://github.com/pragmagic/godot-nim-stub/blob/master/src/stub.nimble#L6 to something like requires "godot >= 0.8.2", since earlier versions don't work with nim 1.6.

Finally, if you're not using vcc, you should remove or comment out https://github.com/pragmagic/godot-nim-stub/blob/master/src/config.nims#L41. I just tested on Windows 10 and MinGW and everything seems to work on both nim 1.4.8 and 1.6.0 with the above changes.

@dsrw
Copy link
Contributor

dsrw commented Nov 5, 2021

@DigitalNXZ I just tested under windows and there's is an issue running from a directory with spaces in the path. Wrapping the path in double quotes by changing https://github.com/pragmagic/godot-nim-stub/blob/master/nakefile.nim#L21 to direShell(godotBin, "--gdnative-generate-json-api", "\"" & getCurrentDir()/jsonFile & "\"") fixed the problem for me.

Your current issue is something else. It looks like nimble is trying to find nim system libraries in the home directory of another user, but can't access them either because they're not there, or it doesn't have permission to read them. I'd suggest either switching back to your "Rage Quit" user and applying the fix above, or reinstalling nim with your new user and verifying that you don't have "C:\Users\Rage Quit" on your path.

@raelite
Copy link
Author

raelite commented Nov 5, 2021

verifying that you don't have "C:\Users\Rage Quit" on your path.
I dont have this in my path if i look in variables but ya ill try the one above and switching back to my acc with the double name.

where do I need to change https://github.com/pragmagic/godot-nim-stub/blob/master/nakefile.nim#L21 with diresehll(godotB...?

@Asarmir
Copy link

Asarmir commented Nov 6, 2021

Thank you. That seems to have worked. ChooseNim did a 32 bit install and so after correcting that. Plus all the suggestion it worked. I did get a small error that import fpscounter, import mainpanel weren't used. But it said it was still successful. Commenting them out also made it successful with no error msg. $src\stub.nim

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

4 participants
@dsrw @raelite @Asarmir and others