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

ERROR: attempt to write a readonly database #17660

Open
1 task done
vreddy10 opened this issue Jan 29, 2025 · 2 comments
Open
1 task done

ERROR: attempt to write a readonly database #17660

vreddy10 opened this issue Jan 29, 2025 · 2 comments
Assignees

Comments

@vreddy10
Copy link

What is your question?

Description:
We are facing attempt to write a readonly database when two users used the shared Conan directory in Linux with Conan v2 version 2.10.0.

Steps to reproduce:

Part-1: Run the below command login as the user has admin access.

  1. Create a common folder for conan tools chains to download and install:
    $ mkdir -p /data/conan/
  2. Create group:
    $ sudo groupadd conan_developers
  3. Change the Ownership of the common conan folder as mentioned below:
    $ sudo chown -R root:conan_developers /data/conan/
  4. Give the folder/file permission to the user and group as “770”
    $ sudo chmod -R 770 /data/conan/
  5. Perform the following command to add the user1 and user2 to the 'conan_developers' group and sets their primary group to 'conan_developers'.
    $ usermod -aG conan_developers -g conan_developers

Part-2: Run the below command login as - user1.

$ echo 'export PATH=${HOME}/.local/bin:${PATH}' >> ${HOME}/.bashrc
$ source ${HOME}/.bashrc
$ sudo apt-get update
$ sudo apt-get install python3-pip -y
$ python3 -m pip install pip==23.3.2
$ echo 'export CONAN_HOME=/data/conan/.conan2’ >> ${HOME}/.bashrc
$ echo 'umask 0007' >> ${HOME}/.bashrc
$ source ~/.bashrc
$ chmod 700 ~
$ python3 -m pip install conan==2.10.0
$ conan profile detect --force
$ conan profile show -pr default

conanfile.txt

[requires]
cmake/3.20.6

[generators]
VirtualRunEnv

Image

$ conan install .

Image

Part-3: Run the below command login as – user2.

$ echo 'export PATH=${HOME}/.local/bin:${PATH}' >> ${HOME}/.bashrc
$ source ${HOME}/.bashrc
$ echo 'export CONAN_HOME=/data/conan/.conan2’ >> ${HOME}/.bashrc
$ echo 'umask 0007' >> ${HOME}/.bashrc
$ source ~/.bashrc
$ chmod 700 ~
$ python3 -m pip install conan==2.10.0

user2@IND6LXPKL3:~/cmake$ conan install .

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux


======== Computing dependency graph ========
ERROR: Traceback (most recent call last):
  File "/home/user2/.local/lib/python3.8/site-packages/conan/cli/cli.py", line 307, in main
    cli.run(args)
  File "/home/user2/.local/lib/python3.8/site-packages/conan/cli/cli.py", line 192, in run
    command.run(self._conan_api, args[0][1:])
  File "/home/user2/.local/lib/python3.8/site-packages/conan/cli/command.py", line 180, in run
    info = self._method(conan_api, parser, *args)
  File "/home/user2/.local/lib/python3.8/site-packages/conan/cli/commands/install.py", line 63, in install
    deps_graph = gapi.load_graph_consumer(path, args.name, args.version, args.user, args.channel,
  File "/home/user2/.local/lib/python3.8/site-packages/conan/api/subapi/graph.py", line 148, in load_graph_consumer
    deps_graph = self.load_graph(root_node, profile_host=profile_host,
  File "/home/user2/.local/lib/python3.8/site-packages/conan/api/subapi/graph.py", line 180, in load_graph
    deps_graph = builder.load_graph(root_node, profile_host, profile_build, lockfile)
  File "/home/user2/.local/lib/python3.8/site-packages/conans/client/graph/graph_builder.py", line 55, in load_graph
    new_node = self._expand_require(require, node, dep_graph, profile_host,
  File "/home/user2/.local/lib/python3.8/site-packages/conans/client/graph/graph_builder.py", line 101, in _expand_require
    new_node = self._create_new_node(node, require, graph, profile_host, profile_build,
  File "/home/user2/.local/lib/python3.8/site-packages/conans/client/graph/graph_builder.py", line 367, in _create_new_node
    resolved = self._resolve_recipe(require.ref, graph_lock)
  File "/home/user2/.local/lib/python3.8/site-packages/conans/client/graph/graph_builder.py", line 264, in _resolve_recipe
    result = self._proxy.get_recipe(ref, self._remotes, self._update, self._check_update)
  File "/home/user2/.local/lib/python3.8/site-packages/conans/client/graph/proxy.py", line 26, in get_recipe
    resolved = self._get_recipe(ref, remotes, update, check_update)
  File "/home/user2/.local/lib/python3.8/site-packages/conans/client/graph/proxy.py", line 49, in _get_recipe
    self._cache.update_recipe_lru(ref)
  File "/home/user2/.local/lib/python3.8/site-packages/conan/internal/cache/cache.py", line 275, in update_recipe_lru
    self._db.update_recipe_lru(ref)
  File "/home/user2/.local/lib/python3.8/site-packages/conan/internal/cache/db/cache_database.py", line 44, in update_recipe_lru
    self._recipes.update_lru(ref)
  File "/home/user2/.local/lib/python3.8/site-packages/conan/internal/cache/db/recipes_table.py", line 72, in update_lru
    conn.execute(query)
sqlite3.OperationalError: attempt to write a readonly database

ERROR: attempt to write a readonly database
user2@IND6LXPKL3:~/cmake$

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Jan 29, 2025
@memsharded
Copy link
Member

Hi @vreddy10

Thanks for your report

We are facing attempt to write a readonly database when two users used the shared Conan directory in Linux with Conan v2 version 2.10.0.

I am afraid there is some misconception there.
The Conan cache is not concurrent, it is not designed to be concurrent, see https://docs.conan.io/2/knowledge/guidelines.html

for example different parallel CI jobs should use different caches (with CONAN_HOME env-var)

This also applies to any other system-level concurrency, like being accessed by different system users.

Some notes:

  • Conan is designed to run at the user level, not requiring sudo or root permissions
  • Conan cache should be owned by the user.
  • Package storage in the cache, including the DB should be owned by the user

In any case, it seems this might be more related to Python+sqlite behavior than something related to Conan, as Conan doesn't do any thing related to permissions or cache file permissions or putting the sqlite3 DB in read-only. So it looks like Python sqlite management doesn't like accessing a DB when Python is running under some user, unless there is some very specific configuration and permissions, see for example https://stackoverflow.com/questions/3319112/sqlite-error-attempt-to-write-a-readonly-database-during-insert, or https://forums.raspberrypi.com/viewtopic.php?t=285406.

Still, even if this was possible from the python+sqlite+system file permissions, sharing the cache is still very discouraged, so I wouldn't recommend doing it anyway.

@vreddy10
Copy link
Author

Hi @memsharded

Thank you for the quick response and information provided, Will check on the provided response and get back to you if any further info is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants