Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: BlackHatCoiner on October 18, 2020, 06:44:48 PM



Title: Compiling error (chainparams.cpp: Permission denied)
Post by: BlackHatCoiner on October 18, 2020, 06:44:48 PM
I tried to change fPowNoRetargeting to false on chainparams.cpp (#line386), because I wanted to have regtest mode but mining blocks every 10 minutes.

I'm trying to achieve this with Ubuntu 18.04 LTS on Windows 10. I've successfully done everything github (https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md#building-for-64-bit-windows) says but I have a problem once I enter make.

https://i.imgur.com/KgPCnDe.png

I'm sure this has nothing to do with the changes I made on chainparams.cpp (the only thing I changed is a boolean). I undo the change, tried make again and still same issue.

Do you know what's the fault?


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: jackg on October 18, 2020, 06:53:09 PM
Are you able to find the file? It might be in src (or it'll be in its children if it's not in the root)...

If you locate it, ls -l on the folder and see what permissions it has. (this is just a general Linux punt though).


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: BlackHatCoiner on October 18, 2020, 06:55:19 PM
Are you able to find the file? It might be in src (or it'll be in its children if it's not in the root)...

If you locate it, ls -l on the folder and see what permissions it has. (this is just a general Linux punt though).

https://i.imgur.com/jZgs7rH.png


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: jackg on October 18, 2020, 07:10:48 PM
Can you run sudo chmod 640 Filename?
Putting the name of the chainparams thing where filename is...

Not sure why it isn't like that but essentially:
6 is read and write permission of the file (and zeroth order means it applies to the super user)
4 is read and applies to your account.
And 0 is for anyone else with access so they can't do anything with the file unless they can invoke the same superuser.

I'd also recommend searching the code before inputting it to not trust a "random".


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: HCP on October 18, 2020, 08:29:16 PM
It seems that after you edited that file, it was saved with permissions of 000... which is problematic, as it effectively has NO permissions, meaning the file is inaccessible, hence the "permission denied" error.

You'll want to figure out why the file permissions ended up like that, or you're likely to run into the same issue over and over with every file you edit.

What editor did you use to edit that file? ???


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: BlackHatCoiner on October 18, 2020, 08:37:55 PM
Everything is okay thanks to @jackg that helped me for another time. I don't know what was wrong. I had edited the file with Notepad++, do you think that this is the reason the permissions changed?


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: HCP on October 18, 2020, 08:49:34 PM
AFAIK, Notepad++ is Windows only... which likely means that you were editing it within the Windows environment. This will more than likely mess up the Linux file permissions. You're probably better off learning how to use "vi" or possibly "vim" (although I'm not sure if "vim" is supported under the Windows Subsystem for Linux/WSL), to prevent these issues from reoccurring.

Otherwise, you'll need to manually check/fix the permissions of every file that you edit.


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: NotATether on October 18, 2020, 09:48:09 PM
Everything is okay thanks to @jackg that helped me for another time. I don't know what was wrong. I had edited the file with Notepad++, do you think that this is the reason the permissions changed?

HCP is correct about Notepad++ messing up Linux file permissions. There is a known bug in WSL that removes the Linux permission bits from files you edit in Windows editors.

Important Caveats

There are a few things to make sure you’re aware of when tinkering with the new metadata:

1. Editing a file using a Windows editor may remove the file’s Linux metadata. In this case, the file will revert to its default permissions

Default permissions is determined from the umask (https://en.wikipedia.org/wiki/Umask) in WSL. And the umask is applied to file whenever it's created or modified, 0022 by default, removing the write bit from group and other. It sounds like your umask is set to 0777, which strips all permissions from the file. Did you accidentally set it to 0777? Umask that doesn't remove any permissions should be 0000.

AFAIK, Notepad++ is Windows only... which likely means that you were editing it within the Windows environment. This will more than likely mess up the Linux file permissions. You're probably better off learning how to use "vi" or possibly "vim" (although I'm not sure if "vim" is supported under the Windows Subsystem for Linux/WSL), to prevent these issues from reoccurring.

I just tested and vim and vi both work. But if OP is having a problem with the umask, then a Linux editor will also strip the permissions.


Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: HCP on October 18, 2020, 10:21:51 PM
I've been running some tests... and managed to replicate it wiping the file permissions once by editing the file in Notepad++... but then the other times it didn't change the permissions. ??? :-\

And my umask is definitely 0022... so I don't think umask is the issue, more just Windows writing to a "Linux FS", and it seems to be somewhat "random" as to when the file permissions get nuked.

At least OP knows how to fix the issue if it reoccurs ;)



Title: Re: Compiling error (chainparams.cpp: Permission denied)
Post by: bob123 on October 19, 2020, 08:48:18 AM
[...] but then the other times it didn't change the permissions. ??? :-\

Just like expected from windows. It does whatever it wants to ;D



[...] more just Windows writing to a "Linux FS", and it seems to be somewhat "random" as to when the file permissions get nuked.

Windows is known to mess up lots of stuff when accessing / writing to a linux filesystem.
It seems like microsoft didn't figure out how to properly read/write to other file systems. The other way around (accessing / writing other filesystems from within linux) works flawlessly tho.