Nextstrain-cli installation - permission error [Errno 13]

Hello everyone,
While following your instructions to install Nextstrain CLI via WSL2 on Windows, I encountered the permission error [Errno 13] at the end of the installation (see documentation below). All other steps worked perfectly fine.
I tried “>sudo chown -R $USER:$USER”, and as last resort also rooting via “>sudo -i” on Ubuntu, but nothing helped so far.

Any ideas on how this could be resolved are highly appreciated.
Thanks!
Ralf


here’s the string leading to the error code:

(nextstrain) PS C:\windows\system32> nextstrain check-setup --set-default
nextstrain-cli is up to date!

Testing your setup…

# docker is supported
✔ yes: docker is installed
✔ yes: docker run works
? unknown: containers have access to >2 GiB of memory
? unknown: image is new enough for this CLI version

# native is not supported
✘ no: snakemake is installed
✘ no: augur is installed
✘ no: auspice is installed

# aws-batch is not supported
✘ no: job description "nextstrain-job" exists
✘ no: job queue "nextstrain-job-queue" exists
✘ no: S3 bucket "nextstrain-jobs" exists

All good!  Supported Nextstrain environments: docker

Setting default environment to docker.
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\Scripts\nextstrain-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\__main__.py", line 10, in main
    return cli.run( argv[1:] )
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\__init__.py", line 31, in run
    return opts.__command__.run(opts)
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\command\check_setup.py", line 108, in run
    config.set("core", "runner", supported_runners[0])
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py", line 105, in set
    save(config, path)
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py", line 72, in save
    config.write(file)
PermissionError: [Errno 13] Permission denied
(nextstrain) PS C:\windows\system32>

Hi @ralfduerr, welcome! Sorry to hear you’re running into installation issues.

Could you try running the following and sharing the output?

python3 -c "from nextstrain.cli.config import CONFIG; print(CONFIG)"

Afterwards, try running:

cd ~

to change to your home directory and then try

nextstrain check-setup --set-default

again.

The error you’re seeing appears to occur when nextstrain check-setup tries to save to its config file the detected runner. (This is what --set-default asks it to do.)

I suspect the config file location points somewhere on the filesystem that’s not modifiable. This could happen, for example, if nextstrain doesn’t properly detect a home directory and the current directory is not writeable (like I suspect C:\windows\system32 is).

Hi Thomas,
Thanks for your prompt reply and help on that!
I just did what you suggested and copied the outcome below (still receiving the same error).
Very best,
Ralf


(nextstrain) PS C:\windows\system32> python3 -c "from nextstrain.cli.config import CONFIG; print(CONFIG)"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
(nextstrain) PS C:\windows\system32> conda -c "from nextstrain.cli.config import CONFIG; print(CONFIG)"
usage: conda-script.py [-h] [-V] command ...
conda-script.py: error: argument command: invalid choice: 'from nextstrain.cli.config import CONFIG; print(CONFIG)' (choose from 'clean', 'compare', 'config', 'create', 'help', 'info', 'init', 'install', 'list', 'package', 'remove', 'uninstall', 'run', 'search', 'update', 'upgrade')
(nextstrain) PS C:\windows\system32> cd ~
(nextstrain) PS C:\Users\Duerrr02> nextstrain check-setup --set-default
nextstrain-cli is up to date!

Testing your setup…

# docker is supported
✔ yes: docker is installed
✔ yes: docker run works
? unknown: containers have access to >2 GiB of memory
? unknown: image is new enough for this CLI version

# native is not supported
✘ no: snakemake is installed
✘ no: augur is installed
✘ no: auspice is installed

# aws-batch is not supported
✘ no: job description "nextstrain-job" exists
✘ no: job queue "nextstrain-job-queue" exists
✘ no: S3 bucket "nextstrain-jobs" exists

All good!  Supported Nextstrain environments: docker

Setting default environment to docker.
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\Scripts\nextstrain-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\__main__.py", line 10, in main
    return cli.run( argv[1:] )
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\__init__.py", line 31, in run
    return opts.__command__.run(opts)
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\command\check_setup.py", line 108, in run
    config.set("core", "runner", supported_runners[0])
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py", line 105, in set
    save(config, path)
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py", line 72, in save
    config.write(file)
PermissionError: [Errno 13] Permission denied
(nextstrain) PS C:\Users\Duerrr02>

Hmm. Does this work (using python instead of python3)?

python -c "from nextstrain.cli.config import CONFIG; print(CONFIG)"

Yes, using python instead of python3 worked, but the outcome remains the same:

(nextstrain) PS C:\Users\Duerrr02> python -c "from nextstrain.cli.config import CONFIG; print(CONFIG)"
C:\Users\Duerrr02\.nextstrain\config
(nextstrain) PS C:\Users\Duerrr02> cd ~
(nextstrain) PS C:\Users\Duerrr02> nextstrain check-setup --set-default
nextstrain-cli is up to date!

Testing your setup…

# docker is supported
✔ yes: docker is installed
✔ yes: docker run works
? unknown: containers have access to >2 GiB of memory
? unknown: image is new enough for this CLI version

# native is not supported
✘ no: snakemake is installed
✘ no: augur is installed
✘ no: auspice is installed

# aws-batch is not supported
✘ no: job description "nextstrain-job" exists
✘ no: job queue "nextstrain-job-queue" exists
✘ no: S3 bucket "nextstrain-jobs" exists

All good!  Supported Nextstrain environments: docker

Setting default environment to docker.
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\Scripts\nextstrain-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\__main__.py", line 10, in main
    return cli.run( argv[1:] )
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\__init__.py", line 31, in run
    return opts.__command__.run(opts)
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\command\check_setup.py", line 108, in run
    config.set("core", "runner", supported_runners[0])
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py", line 105, in set
    save(config, path)
  File "C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py", line 72, in save
    config.write(file)
PermissionError: [Errno 13] Permission denied
(nextstrain) PS C:\Users\Duerrr02>

Thanks for diligently troubleshooting! This output is what I was looking for:

This is the expected path, so I suppose the permissions on it just aren’t as expected. Not sure why at the moment. I don’t have a Windows install on which to test myself right now, but might be able to later.

What’s the output of the following two commands?

(Get-Acl C:\Users\Duerrr02\.nextstrain).Sddl | ConvertFrom-SddlString
(Get-Acl C:\Users\Duerrr02\.nextstrain\config).Sddl | ConvertFrom-SddlString

Thanks for your patience with this! Much appreciated!
Please find the output of the two commands below:

(nextstrain) PS C:\Users\Duerrr02> (Get-Acl C:\Users\Duerrr02\.nextstrain).Sddl | ConvertFrom-SddlString


Owner            : NYUMC\duerrr02
Group            :
DiscretionaryAcl : {NT AUTHORITY\SYSTEM: AccessAllowed Inherited (ChangePermissions, CreateDirectories, Delete, DeleteSubdirectoriesAndFiles, ExecuteKey, FullControl, FullControl, FullControl,
                   FullControl, FullControl, GenericAll, GenericExecute, GenericRead, GenericWrite, ListDirectory, Modify, Read, ReadAndExecute, ReadAttributes, ReadExtendedAttributes,
                   ReadPermissions, Synchronize, TakeOwnership, Traverse, Write, WriteAttributes, WriteData, WriteExtendedAttributes, WriteKey), BUILTIN\Administrators: AccessAllowed Inherited
                   (ChangePermissions, CreateDirectories, Delete, DeleteSubdirectoriesAndFiles, ExecuteKey, FullControl, FullControl, FullControl, FullControl, FullControl, GenericAll,
                   GenericExecute, GenericRead, GenericWrite, ListDirectory, Modify, Read, ReadAndExecute, ReadAttributes, ReadExtendedAttributes, ReadPermissions, Synchronize, TakeOwnership,
                   Traverse, Write, WriteAttributes, WriteData, WriteExtendedAttributes, WriteKey), NYUMC\duerrr02: AccessAllowed Inherited (ChangePermissions, CreateDirectories, Delete,
                   DeleteSubdirectoriesAndFiles, ExecuteKey, FullControl, FullControl, FullControl, FullControl, FullControl, GenericAll, GenericExecute, GenericRead, GenericWrite, ListDirectory,
                   Modify, Read, ReadAndExecute, ReadAttributes, ReadExtendedAttributes, ReadPermissions, Synchronize, TakeOwnership, Traverse, Write, WriteAttributes, WriteData,
                   WriteExtendedAttributes, WriteKey)}
SystemAcl        : {}
RawDescriptor    : System.Security.AccessControl.CommonSecurityDescriptor



(nextstrain) PS C:\Users\Duerrr02> (Get-Acl C:\Users\Duerrr02\.nextstrain\config).Sddl | ConvertFrom-SddlString


Owner            : NYUMC\duerrr02
Group            :
DiscretionaryAcl : {NT AUTHORITY\SYSTEM: AccessAllowed Inherited (ChangePermissions, CreateDirectories, Delete, DeleteSubdirectoriesAndFiles, ExecuteKey, FullControl, FullControl, FullControl,
                   FullControl, FullControl, GenericAll, GenericExecute, GenericRead, GenericWrite, ListDirectory, Modify, Read, ReadAndExecute, ReadAttributes, ReadExtendedAttributes,
                   ReadPermissions, Synchronize, TakeOwnership, Traverse, Write, WriteAttributes, WriteData, WriteExtendedAttributes, WriteKey), BUILTIN\Administrators: AccessAllowed Inherited
                   (ChangePermissions, CreateDirectories, Delete, DeleteSubdirectoriesAndFiles, ExecuteKey, FullControl, FullControl, FullControl, FullControl, FullControl, GenericAll,
                   GenericExecute, GenericRead, GenericWrite, ListDirectory, Modify, Read, ReadAndExecute, ReadAttributes, ReadExtendedAttributes, ReadPermissions, Synchronize, TakeOwnership,
                   Traverse, Write, WriteAttributes, WriteData, WriteExtendedAttributes, WriteKey), NYUMC\duerrr02: AccessAllowed Inherited (ChangePermissions, CreateDirectories, Delete,
                   DeleteSubdirectoriesAndFiles, ExecuteKey, FullControl, FullControl, FullControl, FullControl, FullControl, GenericAll, GenericExecute, GenericRead, GenericWrite, ListDirectory,
                   Modify, Read, ReadAndExecute, ReadAttributes, ReadExtendedAttributes, ReadPermissions, Synchronize, TakeOwnership, Traverse, Write, WriteAttributes, WriteData,
                   WriteExtendedAttributes, WriteKey)}
SystemAcl        : {}
RawDescriptor    : System.Security.AccessControl.CommonSecurityDescriptor


(nextstrain) PS C:\Users\Duerrr02>

Well, those ACLs look ok to me given what context I know here. We’ll have to troubleshoot more.

As a workaround to try and unblock you for now, try putting the config in a different place?

$Env:NEXTSTRAIN_CONFIG = "C:\Users\Duerrr02\nextstrain.config"
nextstrain check-setup --set-default

Thanks for keeping trying!
The workaround didn’t work:

(nextstrain) PS C:\Users\Duerrr02> $Env:NEXTSTRAIN_CONFIG = “C:\Users\Duerrr02\nextstrain.config”
(nextstrain) PS C:\Users\Duerrr02> nextstrain check-setup --set-default
nextstrain-cli is up to date!

Testing your setup…

docker is supported

:heavy_check_mark: yes: docker is installed
:heavy_check_mark: yes: docker run works
? unknown: containers have access to >2 GiB of memory
? unknown: image is new enough for this CLI version

native is not supported

✘ no: snakemake is installed
✘ no: augur is installed
✘ no: auspice is installed

aws-batch is not supported

✘ no: job description “nextstrain-job” exists
✘ no: job queue “nextstrain-job-queue” exists
✘ no: S3 bucket “nextstrain-jobs” exists

All good! Supported Nextstrain environments: docker

Setting default environment to docker.
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\Duerrr02\Miniconda3\envs\nextstrain\Scripts\nextstrain-script.py”, line 9, in
sys.exit(main())
File “C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli_main_.py”, line 10, in main
return cli.run( argv[1:] )
File “C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli_init_.py”, line 31, in run
return opts.command.run(opts)
File “C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\command\check_setup.py”, line 108, in run
config.set(“core”, “runner”, supported_runners[0])
File “C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py”, line 105, in set
save(config, path)
File “C:\Users\Duerrr02\Miniconda3\envs\nextstrain\lib\site-packages\nextstrain\cli\config.py”, line 72, in save
config.write(file)
PermissionError: [Errno 13] Permission denied
(nextstrain) PS C:\Users\Duerrr02>

Hi @ralfduerr,

I am able to reproduce your error using nextstrain-cli=3.0.6. This is a new bug which @trs and I will work to solve. GitHub issue created: nextstrain/cli#151

However, I think there may be some confusion here. There are two ways to set up on Windows (see Installing Nextstrain for details):

  1. Direct via Anaconda PowerShell Prompt
  2. WSL on Windows

You mentioned installing via WSL2, but in your screenshot I see an Anaconda PowerShell prompt.

  1. Do you remember which installation instructions you followed?
  2. Can you try running nextstrain check-setup --set-default on a WSL2 prompt? That would be wherever you ran the sudo commands.

For comparison, I created a new conda environment with nextstrain-cli=3.0.6 and ran check-setup on both Anaconda PS (left) and WSL (right):

The bug only affects the direct install on Windows via Anaconda PS, so you should still be able to use WSL if installed properly.

-Victor

Hi Victor,

Thanks for your reply and I’m thrilled about your quick and thorough support!
Regarding your question: I’ve done all installation steps using 1. Direct via Anaconda PowerShell Prompt (as Administrator). I used the same link you shared, and I followed the instructions of the 3rd tab: WSL on Windows.
FYI, I also tried the native install under 6.b, but it did not work either and I kept going with Docker.
When I did my own troubleshooting, I came across these sudo commands that I listed, but I ran them in Ubuntu where I’ve done none of the other installation steps, so I guess this was useless.

That’s why I haven’t really tried the WSL prompt install so far, but I’m happy to try.
When I run the install on wsl prompt, I need to follow the 4th tab on the link you sent (Ubuntu Linux) and install the Docker for Linux software, correct?

Thanks so much,
Ralf

@ralfduerr no problem! I wrote the installation page a few months ago, so I’m happy to help clarify and fix any steps.

I see there are a few things to clarify:

  1. You should follow instructions in only one tab.
  2. When you use WSL2, you have the option of using Ubuntu there, but you should still be following the instructions under the WSL on Windows tab. The WSL on Windows tab is mostly similar to the Ubuntu Linux tab, but there are some differences with Windows being the host machine versus running Ubuntu directly on a computer.
  3. The Anaconda PowerShell prompt is only used for the Windows tab; it should not be used in the WSL on Windows tab.

Could you try just the WSL on Windows instructions again, then post the error output from WSL prompt? You can skip installing WSL2 (1) and Miniconda (3) if those are already done.

-Victor

Hi Victor,

Thanks for the clarification, and after some detour, the WSL on Windows installation indeed worked!!

  1. since the conda command was not found on my first try, I figured that I have to install MiniConda on Linux first (because I had it installed only on Windows)
  2. When I tried to install MiniConda on Linux on WSL, I received a permission error (see below), presumably because the Windows/system32 folder cannot be accessed, as you assumed in the earlier email:

duerrr03@ACLSW3LT001:/mnt/c/windows/system32$ conda install -n base -c conda-forge mamba --yes
conda: command not found
duerrr03@ACLSW3LT001:/mnt/c/windows/system32$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
–2022-02-19 23:18:48–

Miniconda3-latest-Linux-x86_64.sh: Permission denied

Cannot write to ‘Miniconda3-latest-Linux-x86_64.sh’ (Success).
duerrr03@ACLSW3LT001:/mnt/c/windows/system32$ bash Miniconda3-latest-Linux-x86_64.sh
bash: Miniconda3-latest-Linux-x86_64.sh: No such file or directory

  1. I then switched to Ubuntu, because I rooted it before (using the sudo -i command)
  2. MiniConda3 was then successfully installed on Ubuntu:
    Miniconda3 will now be installed into this location:
    /home/duerrr03/miniconda3
  3. After I followed the commands on your webpage (and after installation of docutils), the installation was completed:


(nextstrain) duerrr03@ACLSW3LT001:~$ nextstrain check-setup --set-default
nextstrain-cli is up to date!

Testing your setup…

docker is supported

:heavy_check_mark: yes: docker is installed
:heavy_check_mark: yes: docker run works
? unknown: containers have access to >2 GiB of memory
? unknown: image is new enough for this CLI version

native is not supported

✘ no: snakemake is installed
✘ no: augur is installed
✘ no: auspice is installed

aws-batch is not supported

✘ no: job description “nextstrain-job” exists
✘ no: job queue “nextstrain-job-queue” exists
✘ no: S3 bucket “nextstrain-jobs” exists

All good! Supported Nextstrain environments: docker

Setting default environment to docker.
(nextstrain) duerrr03@ACLSW3LT001:~$

Thanks so much Victor! You and Thomas are doing a great job!

Ralf

@ralfduerr

I’m glad WSL on Windows is working for you!

When I tried to install MiniConda on Linux on WSL, I received a permission error

You might be in /mnt/c/windows/system32 due to running WSL as Administrator. You should be able to run without Administrator, and it will bring you to your home directory. It’s best not to use sudo unless you really need it (not needed for installing/running Nextstrain).

Let us know if you have any other questions!

– Victor

Very helpful to know!
I’ll try that out and run it without administrator.
Is there actually a way to revert the sudo chown -i command on Ubuntu to bring it back to the original setting?

Thank you!
Ralf

The workflow works well and I’m currently customizing the output. While doing that, I wanted to run a dag plot (as shown in your video tutorial), however, it did not succeed:

The basic command “$nextstrain build . --configfile builds_first.yaml --dag” works fine, but the visualization using the pipe “$nextstrain build . --configfile builds_first.yaml --dag | dot -Tpdf > dag.pdf” caused a syntax error:

Error: : syntax error in line 1 near ’
Warning: syntax ambiguity - badly delimited number ‘33m’ in line 1 of splits into two tokens
Warning: syntax ambiguity - badly delimited number ‘0m’ in line 1 of splits into two tokens

GraphViz is installed.

Do you have an idea of how to fix that?

Thanks much,
Ralf

@ralfduerr

Is there actually a way to revert the sudo chown -i command on Ubuntu to bring it back to the original setting?

Yes if you can remember the directory it was run on, but you can just leave it if things are working fine. If something funny happens, you can always reinstall the Ubuntu WSL distribution.

The basic command “$nextstrain build . --configfile builds_first.yaml --dag” works fine, but the visualization using the pipe “$nextstrain build . --configfile builds_first.yaml --dag | dot -Tpdf > dag.pdf” caused a syntax error:

I have not seen this before, but it looks similar to ivan-m/graphviz#16.

If possible, could you send or attach these?

  1. builds_first.yaml file
  2. output of nextstrain build . --configfile builds_first.yaml --dag
  3. output of dot -V

– Victor

I wouldn’t expect piping directly to dot to work if there’s any output to stdout that isn’t part of the DOT language syntax. I’ve seen Snakemake produce extra output, for example, which means it needs trimming first before passing to dot.

The presence of 33m and 0m in the error messages imply to me that dot is getting ANSI terminal escapes (used for coloring output).

(For the future, please start a new topic for new issues unrelated the original post. This makes it easier to find later in search and folks not following the original topic will see it too.)

Indeed, here’s an example of the issue:

Looking a little more, it seems that for some reason that line is part of stdout when running nextstrain build but is part of stderr when running snakemake directly. Not sure what’s up there. Could be an issue with Nextstrain CLI and/or Snakemake.

1 Like

Ok, this is an issue with the Nextstrain CLI. I’ve filed a bug. Thanks for bringing this to our attention!