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

nikola init --demo fails with a permission error #3606

Open
nbraud opened this issue Mar 20, 2022 · 5 comments
Open

nikola init --demo fails with a permission error #3606

nbraud opened this issue Mar 20, 2022 · 5 comments
Labels

Comments

@nbraud
Copy link

nbraud commented Mar 20, 2022

Environment

Python Version: 3.9.10

Nikola Version: 8.2.0

Operating System: NixOS “unstable” 22.05pre-git

Description:

nikola init --demo fails, even when run in a clean environment and empty directory:

$ cd $(mktemp -d)  # Make a fresh, temporary directory, switch to it
$ nikola init --demo -q demo/
[2022-03-20 11:49:04] INFO: init: A new site with example data has been created at demo/.
[2022-03-20 11:49:04] INFO: init: See README.txt in that folder for more information.
Traceback (most recent call last):
  File "/nix/store/nbnxhr8lmw862z51xwm1kbbbkwyv77hp-python3-3.9.10-env/lib/python3.9/site-packages/doit/doit_cmd.py", line 295, in run
    return command.parse_execute(args)
  File "/nix/store/nbnxhr8lmw862z51xwm1kbbbkwyv77hp-python3-3.9.10-env/lib/python3.9/site-packages/doit/cmd_base.py", line 151, in parse_execute
    return self.execute(params, args)
  File "/nix/store/nbnxhr8lmw862z51xwm1kbbbkwyv77hp-python3-3.9.10-env/lib/python3.9/site-packages/nikola/plugin_categories.py", line 148, in execute
    return self._execute(options, args)
  File "/nix/store/nbnxhr8lmw862z51xwm1kbbbkwyv77hp-python3-3.9.10-env/lib/python3.9/site-packages/nikola/plugins/command/init.py", line 525, in _execute
    self.create_configuration(target)
  File "/nix/store/nbnxhr8lmw862z51xwm1kbbbkwyv77hp-python3-3.9.10-env/lib/python3.9/site-packages/nikola/plugins/command/init.py", line 285, in create_configuration
    with io.open(conf_path, 'w+', encoding='utf8') as fd:
PermissionError: [Errno 13] Permission denied: 'demo/conf.py'

Diagnosis:

I believe this is due to the newly-created folder (here ./demo) not being writeable by the user, as nikola init preserves the file mode from the data/samplesite resource, which is stored as read-only (even for its owner, root) by NixOS (like all other packages) :

$ ls -ld demo/
dr-xr-xr-x 9 nicoo users 200 janv.  1  1970 demo/

$ ls -ld /nix/store/nbnxhr8lmw862z51xwm1kbbbkwyv77hp-python3-3.9.10-env/lib/python3.9/site-packages/nikola/data/samplesite
dr-xr-xr-x 9 root root 10 janv.  1  1970 /nix/store/nbnxhr8lmw862z51xwm1kbbbkwyv77hp-python3-3.9.10-env/lib/python3.9/site-packages/nikola/data/samplesite
@nbraud nbraud added the bug label Mar 20, 2022
@nbraud
Copy link
Author

nbraud commented Mar 20, 2022

This looks like a quick fix, I am now writing a patch.

@Kwpolska
Copy link
Member

@nbraud Hi, what’s the status on your proposed patch? I can see you committed it to your repo, could you make a pull request with it?

@nbraud
Copy link
Author

nbraud commented May 7, 2022

@Kwpolska Apologies for the lack of answer, I was quite ill and not working further on redoing my website (which is what I was trying nikola for)

I'll check out later today whether my patchset is ready to be submitted as a PR.

@davidak
Copy link
Contributor

davidak commented Jun 25, 2023

This is still an issue. It is similar to #2962.

The created demo files can also not be removed. Sudo is needed!

[nix-shell:~/code/webseite]$ rm -rf demo/
rm: cannot remove 'demo/posts/1.rst': Permission denied
rm: cannot remove 'demo/listings/__pycache__/hello.cpython-37.pyc': Permission denied
rm: cannot remove 'demo/listings/hello.py': Permission denied
rm: cannot remove 'demo/README.txt': Permission denied
rm: cannot remove 'demo/images/frontispiece.jpg': Permission denied
rm: cannot remove 'demo/images/illus_001.jpg': Permission denied
rm: cannot remove 'demo/templates/book.tmpl': Permission denied
rm: cannot remove 'demo/pages/1.rst': Permission denied
rm: cannot remove 'demo/pages/path_handlers.rst': Permission denied
rm: cannot remove 'demo/pages/charts.rst': Permission denied
rm: cannot remove 'demo/pages/dr-nikolas-vendetta.rst': Permission denied
rm: cannot remove 'demo/pages/theming.rst': Permission denied
rm: cannot remove 'demo/pages/creating-a-theme.rst': Permission denied
rm: cannot remove 'demo/pages/social_buttons.rst': Permission denied
rm: cannot remove 'demo/pages/internals.rst': Permission denied
rm: cannot remove 'demo/pages/manual.rst': Permission denied
rm: cannot remove 'demo/pages/listings-demo.rst': Permission denied
rm: cannot remove 'demo/pages/bootstrap-demo.rst': Permission denied
rm: cannot remove 'demo/pages/quickref.rst': Permission denied
rm: cannot remove 'demo/pages/quickstart.rst': Permission denied
rm: cannot remove 'demo/pages/extending.rst': Permission denied
rm: cannot remove 'demo/files/favicon.ico': Permission denied
rm: cannot remove 'demo/files/images/nikola.png': Permission denied
rm: cannot remove 'demo/galleries/demo/tesla_tower1_lg.jpg': Permission denied
rm: cannot remove 'demo/galleries/demo/tesla2_lg.jpg': Permission denied
rm: cannot remove 'demo/galleries/demo/index.txt': Permission denied
rm: cannot remove 'demo/galleries/demo/exclude.meta': Permission denied
rm: cannot remove 'demo/galleries/demo/tesla_conducts_lg.jpg': Permission denied
rm: cannot remove 'demo/galleries/demo/tesla_lightning2_lg.jpg': Permission denied
rm: cannot remove 'demo/galleries/demo/tesla4_lg.jpg': Permission denied
rm: cannot remove 'demo/galleries/demo/tesla_lightning1_lg.jpg': Permission denied
rm: cannot remove 'demo/galleries/demo/metadata.sample.yml': Permission denied

@Kwpolska
Copy link
Member

We don't have the resources to figure out Nix. If anyone wants this fixed, patches are welcome.

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