FCP-INDI / cpac

A convenience wrapper for https://github.com/FCP-INDI/C-PAC that provides a simple command line interface.
https://fcp-indi.github.io/docs/latest/user/cpac
MIT License
4 stars 3 forks source link

🐛 `OSError: [Errno 30] Read-only file system` #21

Closed keithcdodd closed 5 months ago

keithcdodd commented 2 years ago

Describe the bug

cpac run --help runs into OSError: [Errno 30] Read-only file system: '/logs' after attempting to load docker. It is not always /logs but can be other folders such as /crash, it appears to be random. Full output from runningcpac run --help:

Loading 🐳 Docker Traceback (most recent call last): File "/opt/miniconda3/bin/cpac", line 8, in sys.exit(run()) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/main.py", line 397, in run main(parsed) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/main.py", line 307, in main Backends(arg_vars).run( File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/init.py", line 24, in Backends { File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 33, in init self._collect_config(kwargs) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 68, in _collect_config kwargs = self.collect_config_bindings(self.config, **kwargs) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/platform.py", line 125, in collect_config_bindings os.makedirs(inner_binding, exist_ok=True) File "/opt/miniconda3/lib/python3.9/os.py", line 225, in makedirs mkdir(name, mode) OSError: [Errno 30] Read-only file system: '/logs'

To reproduce

  1. MacOS Monterey 12.0.1
  2. Install Docker for Mac as described on Docker website
  3. pip install cpac (is successful)
  4. cpac run --help --> throws error as shown

Expected behavior

cpac run --help runs as expected without this error.

Acceptance criteria

cpac run --help runs without error. Note: cpac --help runs just fine. Other docker image wrappers and pulls work fine too (e.g. docker pull fmriprep works, and fmriprep-docker wrapper --help works without error as well).

Additionally cpac --version does not return version, but rather returns the whole help documentation for cpac. Same as cpac --help, although cpac run --version does give version number.

Screenshots

No response

C-PAC version

0.3.2.post1

Container platform

Docker

Docker and/or Singularity version(s)

Docker 20.10.10, build b485636

Additional context

As mentioned briefly before, interestingly cpac --help works, but cpac --version fails and just gives the cpac --help output. Meanwhile cpac run --help gives the error as reported in this post, but cpac run --version gives a version number just fine.

shnizzedy commented 2 years ago

Hi @keithcdodd, thanks for reporting these issues.

/logs and /crash are two of the paths in C-PAC's default pipeline.

cpac (the commandline wrapper) automatically binds these paths to a matching location on the local machine if not otherwise specified. We should definitely upgrade this wrapper to have a default fallback if those paths are not accessible and/or raise a clear exception.

Can you try

cpac -B ${PWD}/logs:/logs -B ${PWD}/crash:/crash run --help

and see if you get the C-PAC run usage string?

keithcdodd commented 2 years ago

Thanks, I tried what you suggested and unfortunately, I get the same type of errors:

cpac -B ${PWD}/logs:/logs -B ${PWD}/crash:/crash run --help Loading 🐳 Docker Traceback (most recent call last): File "/opt/miniconda3/bin/cpac", line 8, in sys.exit(run()) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/main.py", line 397, in run main(parsed) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/main.py", line 307, in main Backends(arg_vars).run( File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/init.py", line 24, in Backends { File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 33, in init self._collect_config(kwargs) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 68, in _collect_config kwargs = self.collect_config_bindings(self.config, **kwargs) File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/platform.py", line 125, in collect_config_bindings os.makedirs(inner_binding, exist_ok=True) File "/opt/miniconda3/lib/python3.9/os.py", line 225, in makedirs mkdir(name, mode) OSError: [Errno 30] Read-only file system: '/crash'

In case the information helps, I am running this on an account with administrator access, and I have tried it in sudo once which did not solve the issue. Everything being run here was installed on the same account with administrator access, so I am unsure how or why some paths may not be accessible.

Thanks!

keithcdodd commented 2 years ago

Hello, just wanted to check in again if there is anything else I should be trying or doing. Would love to use cpac. Thanks!

shnizzedy commented 2 years ago

:thinking:

What is your $PWD when you get this error? I've seen reports of similar errors trying to create directories in the root directory (/) in MacOS ≥ 10.15. If you're trying to run from /, can you try from another directory?

If you're already trying from somewhere other than /, maybe try

mkdir -p ${PWD}/crash

then repeat

cpac -B ${PWD}/logs:/logs -B ${PWD}/crash:/crash run --help

?

keithcdodd commented 2 years ago

Sorry I was away from my work computer for the holidays. My $PWD is my user folder so /Users/myusername. I tried what you said regardless with making the crash folder and then running the line with logs. It gives the same/similar error:

Loading 🐳 Docker
Traceback (most recent call last):
  File "/opt/miniconda3/bin/cpac", line 8, in <module>
    sys.exit(run())
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/__main__.py", line 397, in run
    main(parsed)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/__main__.py", line 307, in main
    Backends(**arg_vars).run(
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/__init__.py", line 24, in Backends
    {
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 33, in __init__
    self._collect_config(**kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 68, in _collect_config
    kwargs = self.collect_config_bindings(self.config, **kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/platform.py", line 125, in collect_config_bindings
    os.makedirs(inner_binding, exist_ok=True)
  File "/opt/miniconda3/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/logs'

For fun I tried the same command but with sudo and it gave me the error:

Loading 🐳 Docker
Traceback (most recent call last):
  File "/opt/miniconda3/bin/cpac", line 8, in <module>
    sys.exit(run())
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/__main__.py", line 397, in run
    main(parsed)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/__main__.py", line 307, in main
    Backends(**arg_vars).run(
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/__init__.py", line 24, in Backends
    {
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 33, in __init__
    self._collect_config(**kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 68, in _collect_config
    kwargs = self.collect_config_bindings(self.config, **kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/platform.py", line 125, in collect_config_bindings
    os.makedirs(inner_binding, exist_ok=True)
  File "/opt/miniconda3/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/crash'

which is interesting, because why would my new crash folder be read only right after I made it? And it's read only when I use sudo? But I didn't get that issue when I ran cpac without sudo... of course though the supposed /logs file was "read only".

Thanks!

keithcdodd commented 2 years ago

I also just tried making a logs directory with mkdir -p ${PWD}/logs

And then reran the cpac command you gave and I still get:

Loading 🐳 Docker
Traceback (most recent call last):
  File "/opt/miniconda3/bin/cpac", line 8, in <module>
    sys.exit(run())
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/__main__.py", line 397, in run
    main(parsed)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/__main__.py", line 307, in main
    Backends(**arg_vars).run(
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/__init__.py", line 24, in Backends
    {
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 33, in __init__
    self._collect_config(**kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/docker.py", line 68, in _collect_config
    kwargs = self.collect_config_bindings(self.config, **kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/cpac/backends/platform.py", line 125, in collect_config_bindings
    os.makedirs(inner_binding, exist_ok=True)
  File "/opt/miniconda3/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/logs'

So somehow even though I attempted to create my own logs file, it doesn't like it?

keithcdodd commented 2 years ago

I have also tried changing permissions for the crash and log directories that I made to be read and write access for everyone, and not just my user. It still gives the same error -- either crash is "read-only" or logs is "read-only". Even though those folders at my home directory are definitely read and write access for everyone now. Is it maybe trying to access a different logs and crash folder even though we specify it with the -B flag?

Can I ask about the cpac command being cpac -B ${PWD}/logs:/logs -B ${PWD}/crash:/crash run --help ? Because even if I make the logs directory and crash directory in my home directory, I can't cd into ${PWD}/logs:/logs or ${PWD}/crash:/crash since the paths are ${PWD}/logs and ${PWD}/crash -- did I make the directories incorrectly?

shnizzedy commented 2 years ago

I still suspect it's a Linux-in-Docker-on-MacOS≥10.15 issue, but I don't have a Mac, so I haven't figured out how to replicate :upside_down_face:

Maybe someone else (someone using Docker on Mac) can help?

shnizzedy commented 2 years ago

Related discussion on Neurostars: Error in installing c-pac on MacOS Monterey with Mac M1 chip

shnizzedy commented 2 years ago

Another one: CPAC error in creating data_settings.yml template file

shnizzedy commented 5 months ago

In 1.8.5